How did you design fallback logic for LLM or Redis failures?
Asked at
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.
Also asked at Бюро 1440
- What is GIL in CPython, how is it implemented, and why is it needed?
- What is an iterator and a generator, how do they differ?
- What are asynchronous, multithreading, and multiprocessing? How do they differ and when should each be used?
- Compare multithreading, multiprocessing, and asynchronous in Python: differences, advantages, and disadvantages.
- What are the key differences between synchronous and asynchronous programming in Python? Please answer this question orally.
Similar questions
- Have you ever had to implement fallback logic?
- Which patterns for ensuring microservice fault tolerance do you know?
- Briefly describe the Saga pattern with compensation: what happened if one of the steps failed?
- Can you tell me about a particular service that used asynchronous processing? Why did you choose that approach?
- What happened if a particular Redis cache instance went down?