adammokan

adammokan

Odd slowdowns with concurrent HTTPS requests / HTTP Client Concurrency

I have a system that is making a lot of HTTPS requests. I’m using HTTPoison (which has Hackney under the hood). All is well when I run things real slow, like 500 requests a minute.

However, when I start ramping up my work pools to make more transactions and increase concurrency, I notice a big jump with slow turnaround from pre-request logic until I get a response. I’m not aware of a way to get the actual request/response timing, but I just keep track of the time right before the request and right after - which it goes from 4-5 seconds on average to the high 30s or more. Sometimes I end up with spikes of 150-250 seconds. I’m unsure of is if the actual VM is being bottlenecked in some way or by something by the OS (Ubuntu 14.04).

What I also notice is that when I run into a chunk of slow requests, it seems to ‘cascade’ and effect the handling/response time of subsequent requests for a while. I could understand if I were seeing CPU or memory spikes, but I’m not. The VM queues look good as well when watching in observer.

My code is making the requests in a pool to limit the concurrency. I also know hackney is pooling requests. I’ve used both the default hackney pool as well as creating my own hackney pool with a large enough capacity, but tempted to disable the hackney connection pooling altogether. I have added some sleep logic to avoid making too many requests start up simultaneously, but that hasn’t helped a whole lot either.

If anyone could give me some ideas for monitoring these connections better or figuring out the long delays, I’m all ears.

Things I have done so far:

  • increased ulimits on Ubuntu
  • increased +Q and +A settings on the erlang vm.args
  • watched the tls_connection:init calls in Observer (they tend to jump up in memory usage when I hit these slowness spikes)
  • split connections across multiple hackney pools

Server Specs:

  • 8 cores
  • 16gb RAM

I’m hardly moving the CPU at all and ram usage is normally below 1gb on the VM side

Most Liked

stocks29

stocks29

I had a similar experience and the solution was to force hackney to use the default pool, which I believe allowed my app to reuse connections and not have to redo the handshake for each request. I documented it here: http://coderstocks.blogspot.com/2016/01/sqs-throughput-over-https-with-elixir.html

Hopefully that is helpful for you.

OvermindDL1

OvermindDL1

If you are running ubuntu in a virtual machine then the VM could definitely have some overhead depending on how its network is configured. But still, I’d say replicate the case in python/ruby/whatever and see if you have the same performance characteristics. It would definitely rule in one way or the other. Curious as to your results. :slight_smile:

OvermindDL1

OvermindDL1

And you are certain it is not the remote server as the first thing to check? Have you tried the same thing with python or something as a test to verify?

adammokan

adammokan

I am working on a test with Ruby/Mechanize as we speak. But no, I am not sure the remote host isn’t the issue here.

Having said that, is there a good way to really inspect the connections? I just want to be sure my VM settings are as good as they could be. Or, should it be assumed this should just work?

OvermindDL1

OvermindDL1

Hmm, did you test it with ruby to verify no system issues regardless? You should be able to do a lot more than 100 concurrent connections (I was testing my server with 60k concurrent connections)…

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lis...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement