Made StackObjectPool's maxIdle parameter configurable in RedisClientPool#34
Merged
debasishg merged 1 commit intodebasishg:masterfrom Sep 1, 2012
Merged
Conversation
The maxIdle in StackObjectPool determines that when an object is returned to the pool and there is more than maxIdle objects idle, then the bottom object is destroyed and the returned object is inserted at the top of the stack. With its default value of 8 and enough concurrent usage (more than 8 threads) you can easily start creating and destroying a lot of objects in sequence. In high concurrency contexts one can increase maxIdle to the number of threads to avoid this unnecessary destroying/creating. The high number of creating/destroying can lead to exhausting ports causing: java.lang.RuntimeException: java.net.NoRouteToHostException: Cannot assign requested address
Author
|
An alternative is to do something like: One problem is that RedisClientFactory is private[redis] |
debasishg
added a commit
that referenced
this pull request
Sep 1, 2012
Made StackObjectPool's maxIdle parameter configurable in RedisClientPool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commit message says it all, but trying to explain better:
I was using RedisClientPool in a environment with 24 threads heavily using Redis (and doing other stuff). The problem is that, as maxIdle of StackObjectPool defaults to 8, when more than 8 objects were borrowed and then returned to the pool, this maxIdle threshold was hit. As ~24 objects are borrowed but pool only maintains up to 8 idle objects. That means that every time an object is returned and there is more than 8 idle objects in the pool, the bottom object in the stack pool is destroyed. Then causing a gigantic destroy-create-destroy-create cycle. As the number of Sockets being opened and closed to Redis increased, I guess, it also exhausted the ephemeral port range giving the error:
Changing the maxIdle parameter to 30 stopped all the problems. I've also check in the Redis log that a huge number of connections were being dropped and accepted again and again and again.