Share a client connection pool across the cluster

Hi,

We are using ClusterSharding for our deployment and are now trying to integrate AkkaHttp Client into it. First we thought of using the CachedHostConnectionPool but it seems like it opens a pool for every node in the cluster and not sharing this pool in the cluster. So if we set the max-connections to 20 and have three nodes, then it will actually be a max-connections of 60.

Is there a way to have a cluster-wide connection pool for the http client?

The pool itself is inherently node/JVM-local since it contains actual TCP connections. There is no feature out of the box in Akka HTTP that would introduce a cluster global pool connection limit, and also no way to partition requests to one or a few specific nodes.

To achieve that you would have to implement that yourself somehow, either as a global/distributed limit (there is no dynamic control of pools, so tricky, but perhaps their lifecycle could be managed), or using just one or controlled number of nodes of the cluster (for example using cluster roles) for the logic triggering the requests against a specific host so that the limits does not need to be dynamic. Neither option seems trivial, I’m afraid.

1 Like