I'm a beginner to request/response service programming using apache HTTP clients and am trying to understand how a client with a connection pool to a server might have some connections go stale in that pool.
Here's what I currently understand:
- stale connections are a result of the server disconnecting the connection but the client not knowing
- trying to use a stale connection on a request could result in
org.apache.http.NoHttpResponseException
- connection pools should have an eviction policy to clean up stale connections and remake new ones, however there is a tradeoff for performance because new connections are expensive to make
I currently have a service that is getting called about 20 req/second and I get org.apache.http.NoHttpResponseException
(presumably due to stale connections) about 15 times an hour. How can I calculate my eviction policy?
I'm using a threadpool of 10 threads. Current eviction policy is to scan the pool every 5 seconds and remove threads that are idle for 30 seconds or more.
I'm interested in if there is a rough estimation process for structuring my eviction policy?