Jedis with NIO #3271
Replies: 1 comment 2 replies
-
@yangbodong22011 First of all, thank you for this detailed conversation starter. Secondly, if we are doing NIO, it should be a library like Netty. I do think about this time to time but I wasn't sure about dropping IO socket completely. I was trying to support both which was making it too complex. My alternate idea was to introduce a new library, say However, that's mostly before Jedis 4 where Connection class was a super class for Jedis class. Now that Connection is an object/resource, it could be easier. (Again, rambling my thoughts here.) Anyways, I am all for the idea. The first key decision for us could be whether to support NIO as an option alongwith IO or to completely replace IO with NIO. LBNL, do you plan to implement this? |
Beta Was this translation helpful? Give feedback.
-
Background
Jedis currently uses apache common-pool2 to manage connections. Users need to configure the three parameters
maxTotal/maxIdle/minIdle
to control the size of the connection pool. Since Redis is usually used as a cache to help reduce the burden on the database, it needs to bearvery large concurrency
, so When the business concurrency is greater than maxTotal, the error "Could not get a resource from the pool" will be encountered.The current solution is that the user can increase the maxTotal parameter, but Redis usually only supports links below 10k, otherwise the performance will drop a lot. Assuming that the user has 100 machines, it is recommended that this parameter not exceed 100(10k/100=100), while the concurrency of the user may be much greater than 100. In addition, since JedisCluster will establish a pool for each node, this results in the excess number of connections on the user machine being
maxTotal * cluster nodes number
in cluster mode.Therefore, it is necessary for us to introduce the NIO mode for Jedis to solve the problem of too many connections.
Existing plans
#647 and #713 have made some attempts, But it has not been merged. I have studied its related codes. I think there is still a certain gap between them and the production environment (especially in design). Compared with the advanced IO library, using the native NIO API is much more complicated. (But Jedis has always advocated simplicity and does not introduce too many dependencies).
New possible solutions
Our achievements and goals
Possible difficulties
RST
packet failures lettuce#2082Looking forward to getting more feedback from the community.
Beta Was this translation helpful? Give feedback.
All reactions