Skip to content
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

Closed

Conversation

olksdr
Copy link
Contributor

@olksdr olksdr commented Aug 15, 2022

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.


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 gather
all the configuration options, with sensible defaults.

@olksdr olksdr self-assigned this Aug 15, 2022
@olksdr olksdr requested a review from a team August 15, 2022 05:52
@jan-auer jan-auer changed the title feat(redis): make connection pool configurable [INGEST-1557] feat(redis): Make connection pool configurable [INGEST-1557] Aug 16, 2022
Copy link
Member

@jan-auer jan-auer left a 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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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))


/// 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,
Copy link
Member

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.

24
}

/// Additional configuration options for a redis client
Copy link
Member

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.

@jan-auer
Copy link
Member

cc @beezz

@olksdr olksdr force-pushed the feat/config-for-redis-pool-size branch from 6eb322e to 42fe91b Compare August 16, 2022 11:19
@olksdr olksdr requested review from jan-auer and a team August 16, 2022 11:19
olksdr added 7 commits August 16, 2022 15:32
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
@olksdr olksdr force-pushed the feat/config-for-redis-pool-size branch from a01f7d2 to 702f9f2 Compare August 16, 2022 13:35
Copy link
Member

@jjbayer jjbayer left a 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")]
Copy link
Member

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

#[derive(Serialize, Deserialize, Debug)]
#[serde(default)]
struct Http {
.

@olksdr
Copy link
Contributor Author

olksdr commented Aug 16, 2022

closing in favour of #1418

@olksdr olksdr closed this Aug 16, 2022
@olksdr olksdr deleted the feat/config-for-redis-pool-size branch August 16, 2022 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants