-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat(redis): Make connection pool configurable [INGEST-1557] #1413
Conversation
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.
Looks good to me, please see the comment below on test_on_check_out
.
CHANGELOG.md
Outdated
@@ -9,6 +9,7 @@ | |||
- Filter events in external Relays, before extracting metrics. ([#1379](https://github.com/getsentry/relay/pull/1379)) | |||
- Add `privatekey` and `private_key` as secret key name to datascrubbers. ([#1376](https://github.com/getsentry/relay/pull/1376)) | |||
- Explain why we responded with 429. ([#1389](https://github.com/getsentry/relay/pull/1389)) | |||
- Make Redis connection pool configurable ([#1413](https://github.com/getsentry/relay/pull/1413)) |
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.
- Make Redis connection pool configurable ([#1413](https://github.com/getsentry/relay/pull/1413)) | |
- Make Redis connection pool configurable. ([#1413](https://github.com/getsentry/relay/pull/1413)) |
relay-redis/src/config.rs
Outdated
|
||
/// If true, the health of a connection will be verified before it's checked out of the pool | ||
#[serde(skip, default)] | ||
pub test_on_check_out: bool, |
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.
This behavior was initially introduced as a workaround for suboptimal behavior of the r2d2
bindings in the redis
crate. See #1394
As discussed offline, the proper fix for this would be debouncing in the redis
crate directly, so we better not make this configurable.
relay-redis/src/config.rs
Outdated
24 | ||
} | ||
|
||
/// Additional configuration options for a redis client |
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.
Ideally, please use punctuation on all sentences in doc comments.
cc @beezz |
6eb322e
to
42fe91b
Compare
Currently the maximum number of connections managed by the pool is hardcoded and set to the magic number of `24` which works, but we must make sure we have a posibility to finetune this parameter. This change adds `max_connections` option into the `Cluster` config, keeps the existing `Single` config server without changes for bakwards compatibility and also introduces the `SingleOpts` variant to configure single server with additional options (with e.g. `max_connections`). The default number of redis connetions in the pool is kept to `24`. This should allow us to keep existing configs without changes and still give the posibility for finetunning connections in the future.
Since there is already configuration for few different types of the connection pools and redis clients, also most of the settings are repeatable - it is time to move all those config options if one place. Introducing `RedisConfigOptions` which will be a single place to gather all the configuration options, with sensible defaults.
* moved the redis tests into the redis crate * added serde-yaml in relay-redis crate as dev deps * keep docs properly formatted * removed the option from the config which should not be configured
a01f7d2
to
702f9f2
Compare
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.
Looks good to me!
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)] | ||
pub struct RedisConfigOptions { | ||
/// Maximum number of connections managed by the pool. | ||
#[serde(default = "default_max_connections")] |
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.
nit: You could put #serde(default)
on top of RedisConfigOptions
, then any missing value would be derived from the Default
impl below:
https://serde.rs/container-attrs.html#default
See for example
relay/relay-config/src/config.rs
Lines 657 to 659 in 25fee32
#[derive(Serialize, Deserialize, Debug)] | |
#[serde(default)] | |
struct Http { |
closing in favour of #1418 |
Currently the maximum number of connections managed by the pool is
hardcoded and set to the magic number of
24
which works, but we mustmake sure we have a posibility to finetune this parameter.
This change adds
max_connections
option into theCluster
config,keeps the existing
Single
config server without changes for bakwardscompatibility and also introduces the
SingleOpts
variant to configure singleserver with additional options (with e.g.
max_connections
).The default number of redis connetions in the pool is kept to
24
.This should allow us to keep existing configs without changes and still
give the posibility for finetunning connections in the future.
Also taking opportunity to refactor it a little bit .
Since there is already configuration for few different types of the
connection pools and redis clients, also most of the settings are
repeatable - it is time to move all those config options if one place.
Introducing
RedisConfigOptions
which will be a single place to gatherall the configuration options, with sensible defaults.