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.

1 Like

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

1 Like

The documentation for HTTPoison explains it

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.