NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior1 view

How did you design fallback logic for LLM or Redis failures?

Practice

AI answer

First, I determined what could be safely lost or replaced in the event of a failure, and handled LLM and Redis errors separately. For the LLM, I set timeouts, a limited number of retries with exponential backoff and jitter, and then a circuit breaker. If the service is unavailable, the system can return a cached response, switch to a backup model, or provide a clear, simplified response; requests must not be retried indefinitely.

For Redis, I considered its role: if it is a cache, the application can usually access the source of truth directly, but with load limits and a timeout; if Redis stores critical state, it must not be silently treated as optional—reliable storage or a proper failure response is required. I designed for graceful degradation without cascading failures, idempotent retries, failure and latency metrics, logs, and alerts. I tested fallback behavior with failure and recovery tests.