feat(redis): Make connection pool configurable [INGEST-1557] #1413
feat(redis): Make connection pool configurable [INGEST-1557] #1413olksdr wants to merge 7 commits intogetsentry:masterfrom
Conversation
jan-auer
left a comment
There was a problem hiding this comment.
Looks good to me, please see the comment below on test_on_check_out.
CHANGELOG.md
Outdated
| - 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.
| - 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.
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.
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
| #[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.
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
|
closing in favour of #1418 |
Currently the maximum number of connections managed by the pool is
hardcoded and set to the magic number of
24which works, but we mustmake sure we have a posibility to finetune this parameter.
This change adds
max_connectionsoption into theClusterconfig,keeps the existing
Singleconfig server without changes for bakwardscompatibility and also introduces the
SingleOptsvariant 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
RedisConfigOptionswhich will be a single place to gatherall the configuration options, with sensible defaults.