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

DM-42093: Adjust the Redis connection pool parameters #913

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/20231208_105820_rra_DM_42093.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Bug fixes

- Adjust the Redis connection pool parameters to hopefully improve recovery after a Redis server restart.
4 changes: 2 additions & 2 deletions src/gafaelfawr/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@
REDIS_RETRIES = 10
"""How many times to try to connect to Redis before giving up."""

REDIS_POOL_SIZE = 10
REDIS_POOL_SIZE = 25
"""Size of the Redis connection pool."""

REDIS_POOL_TIMEOUT = 10
REDIS_POOL_TIMEOUT = 30
"""Seconds to wait for a connection from the pool before giving up."""

REDIS_TIMEOUT = 5
Expand Down
27 changes: 13 additions & 14 deletions src/gafaelfawr/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,22 @@ async def from_config(cls, config: Config) -> Self:
client.set_credentials("GSSAPI")
ldap_pool = AIOConnectionPool(client)

redis_client: Redis = Redis(
connection_pool=BlockingConnectionPool.from_url(
config.redis_url,
password=config.redis_password,
max_connections=REDIS_POOL_SIZE,
retry=Retry(
ExponentialBackoff(
base=REDIS_BACKOFF_START, cap=REDIS_BACKOFF_MAX
),
REDIS_RETRIES,
redis_pool = BlockingConnectionPool.from_url(
config.redis_url,
password=config.redis_password,
max_connections=REDIS_POOL_SIZE,
retry=Retry(
ExponentialBackoff(
base=REDIS_BACKOFF_START, cap=REDIS_BACKOFF_MAX
),
socket_keepalive=True,
socket_timeout=REDIS_TIMEOUT,
timeout=REDIS_POOL_TIMEOUT,
REDIS_RETRIES,
),
retry_on_timeout=True,
socket_keepalive=True,
socket_timeout=REDIS_TIMEOUT,
timeout=REDIS_POOL_TIMEOUT,
)
redis_client = Redis.from_pool(redis_pool)

return cls(
config=config,
Expand All @@ -176,7 +176,6 @@ async def aclose(self) -> None:
a different configuration.
"""
await self.redis.aclose()
await self.redis.connection_pool.disconnect()
if self.ldap_pool:
await self.ldap_pool.close()
await self.uid_cache.clear()
Expand Down