I want to create a Jersey Client for a multithreaded project. Do i need to create a connection pool for the Client ?
There is 500 TPS traffic on the server .How to calculate the below parameters for best performance.
ConnectionTimout,SocketTimeout,ReadTimeout,MaxConnectionPerHost,MaxConnections.
What is concept of reset connection pool and when to use it?
Jersey Client is thread-safe for multiple request executions. Documentation
It is recommended that the same instance of
Clientclass is reused for multiple request executions. ChangingClientconfiguration is not thread save and must be handled appropriately.Do I need to create a connection pool for the Client ?
Short answer Yes.
By default Jersey Client use
BasicHttpClientConnectionManager. DocumentationFor multithread application, you need to override the default value with
PoolingHttpClientConnectionManager.For details Apache Connection Management
Configuration
The general recommendation is to avoid the infinity timeouts, which Jersey set by default. It can produce threads stuck in case of problems. See Best practices for web service timeouts choose the correct value. There are no specific values, they should be set based on services and environment performance. The correct timeouts and connection size will come thru the time after performance testing or real-time usage.
Just implement it flexible, add the ability to adjust settings on the fly.
Read Timeout
You can set 1 minute like the initial value. Also, you can override timeout per request in case of exceptional cases.
Connection Timeout
Set 500 - 1000 milliseconds like the initial value.
MaxConnectionPerHost
Set 20 connections like initial value.
MaxConnections
Set 200 connections like initial value.