简体   繁体   中英

PoolingHttpClientConnectionManager and keep-alive setting

I have performance critical application with http requests pool. My application service is bursty processing batch files. Does PoolingHttpClientConnectionManager re-use connection for multiple requests? If yes, how do i calculate optimal keep-alive time? My http request response time is avg 25 ms.

Yes, it will reuse connections for multiple requests. Note that it pools connections with a maximum number per route and the default is 2, so you will almost certainly want to increase that or it will become a bottleneck!

Calculating the best keep-alive time is non-trivial as it depends on many things. How often are the bursts, what keep-alive time does the web front or application server support and so on. Generally I would start with something like 5-10 seconds and measure. If you know that the bursts are 8 seconds apart, aim for something slightly larger. If the bursts are more than a few minutes apart, keeping the connections alive for that long will be problematic as they tend to time out (firewalls, server-side close, ...).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM