Akka HTTP utilizes a connection pool to manage multiple concurrent connections, improving performance and resource utilization. The host-level API manages the pool, automatically reusing idle connections or creating new ones as needed.
To optimize performance, configure client connection settings in the
application.conf
file or programmatically using
ConnectionPoolSettings
. Key parameters include:
1. max-connections
: Maximum number of connections per target endpoint; increase for high concurrency.
2. min-connections
: Minimum number of connections kept alive; adjust based on expected load.
3. max-retries
: Number of retries for failed requests; balance between resilience and response time.
4. idle-timeout
: Duration before closing idle connections; decrease to free resources faster or increase to reduce connection overhead.
5. pipelining-limit
: Maximum number of requests sent over a single connection concurrently; set higher if server supports HTTP pipelining.
6. response-entity-subscription-timeout
: Timeout for consuming response entities; tune according to expected response times.
Example :
akka.http.host-connection-pool {
max-connections = 50
min-connections = 10
max-retries = 3
idle-timeout = 30s
pipelining-limit = 2
response-entity-subscription-timeout = 15s
}?