Reputation: 433
I am a bit confused about the difference between connect timeout and read timeout. I understand that redis may throw a connect timeout exception when the application starts and sets the initial connection. My questions is can redis throw a connect timeout after the application has started when executing a redis transaction?.
The way connection pooling works is that the running transaction request a redis connection from the connection pool. Will that be considered as the event where a connect timeout can be thrown if no connection is provided on time?. Then once the transaction has the connection, it will execute the redis operation and that's when the read timeout may arise.
An explanation on the following jedis elements relating to exceptions would be helpful:
jedis:
pool:
max-active: 5
max-idle: 5
max-wait: -1ms
min-idle: 3
I switched to the following default settings and the http requests seem to be executed faster in average from postman:
jedis:
pool:
max-active: 8
max-idle: 8
max-wait: -1ms
min-idle: 0
why does that happen?
what is the definition of an idle and active connections?
Upvotes: 1
Views: 1376
Reputation: 5388
Quoting from the doc
jedis.pool.max-active
Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit.
jedis.pool.max-idle
Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections.
jedis.pool.max-wait
Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely.
jedis.pool.min-idle
Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if both it and time between eviction runs are positive.
jedis.pool.time-between-eviction-runs
Time between runs of the idle object evictor thread. When positive, the idle object evictor thread starts, otherwise no idle object eviction is performed.
Increasing max-active
/max-idle
just means that you're going to have some additional connections. As you've increased the connection count to 8 from 5 so you can send 3 other requests in parallel. On another side, you have set max-wait
to -1 so you could be potentially waiting indefinitely.
Idle connection: When a connection is taken from the connection pool, once its usage is over it's put back in the connection pool. Connection pooling uses two parameters to decide whether the connection would be disposed of or can be used later. Based on the eviction timeout an active connection would be closed after the eviction timeout, for example, if the eviction timeout is 5 seconds and the connection was created 10 seconds ago then this connection can be closed to reach the max-idle
connections. If the number of active connections is below the max-idle
then this connection can be retained and reused.
Upvotes: 1