Skip to content

Redis backend: with Redis down each cached request waits ~7 s on redis-py's default retry #325

Description

@allen0099

Problem

When Redis is down, @cache fails open as documented, but each cached request takes about 7.4 s. redis-py 8's default Retry (several retries with exponential backoff) makes each get and set take about 3.7 s before the error reaches the library:

GET /x -> 200 in 7.40 s    (Redis unreachable)
AppCache.get -> 500 in 3.83 s

Passing retry=Retry(NoBackoff(), 0) through the backend's **kwargs brings it back to about 0 s. Neither "When the backend fails" (HTTP_CACHING.md) nor BACKENDS.md mentions this, so "fail open" still looks like an outage.

Proposal

  • Document the retry and timeout settings (retry=, socket_timeout, socket_connect_timeout) next to fail-open, with an example.
  • Consider a smaller default retry budget in AsyncRedisCacheBackend when the caller passes none. That would be a behaviour change, so it needs a note in the changelog.
  • A circuit breaker could follow later as a separate issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendsCache backends and their atomic primitivesdocumentationImprovements or additions to documentation

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions