bharadwaj

bharadwaj

HTTPoison connection pools

can someone please explain me how the connection pools work in HTTPoison (hackney), how does it effect the latency of http requests.

Most Liked

jola

jola

The documentation for HTTPoison explains it GitHub - edgurgel/httpoison: Yet Another HTTP client for Elixir powered by hackney · GitHub

Normally hackney opens and closes connections on demand, but it also creates a default pool of connections which are reused for requests to the same host. If the connection and host support keepalive, the connection is kept open until explicitly closed.

In other words, assuming the host supports it, subsequent requests reuse the same connection and avoid the overhead of establishing a connection. As an example of the kind of difference we’re talking about, when I make requests crossing the Atlantic to a service I have there I often see an initial latency of 500 ms for the first request, but the requests after that, to the same host, take about 100 ms.

Those numbers depend on all kinds of things, like HTTPS, distance between server and client etc. The only way to know if it helps your use case is to try it.

The connection pool also limits the number of concurrent requests you can make.

anthonator

anthonator

I’m also interested in this question. Specifically for hackney. I don’t use HTTPoison.

Where Next?

Popular in Questions Top

Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31525 112
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49134 226
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement