-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow more redis connection options #419
Conversation
Codecov Report
β Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #419 +/- ##
==========================================
- Coverage 30.77% 30.63% -0.14%
==========================================
Files 24 24
Lines 4569 4579 +10
==========================================
- Hits 1406 1403 -3
- Misses 2987 2996 +9
- Partials 176 180 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
datastore/redis.go
Outdated
|
||
if redisConnectionPoolSize > 0 { | ||
redisOpts.PoolSize = redisConnectionPoolSize | ||
redisOpts.MinIdleConns = redisConnectionPoolSize / 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add some more information about this value. If the PoolSize
value is high and the redis service is shared across multiple instances you could end up maxing out the available connections on redis and see random connection errors.
Results from a quick google, but probably better resources out there to explain this:
Redis nodes can have up to either 10,000 simultaneous connections or 4 simultaneous connections per megabyte of memory, whichever is larger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. What I could find was
In Redis 2.6 and newer, this limit is dynamic: by default it is set to 10000 clients, unless otherwise stated by the maxclients directive in redis.conf.
However, Redis checks with the kernel what the maximum number of file descriptors that we are able to open is (the soft limit is checked). If the limit is less than the maximum number of clients we want to handle, plus 32 (that is the number of file descriptors Redis reserves for internal uses), then the maximum number of clients is updated to match the number of clients it is really able to handle under the current operating system limit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it would be better to configure poolSize and minIdleConnections separately π€
π Summary
Inspired by https://github.com/bloXroute-Labs/mev-relay/blob/develop/datastore/redis.go
β I have run these commands
make lint
make test-race
go mod tidy
CONTRIBUTING.md