System Design, Redis & Distributed Systems
10+ Years (Principal / Architect)
Expert
Production Scenario
How do you design an Idempotent Payment Processing Architecture with the Saga Pattern across Microservices?
Real-World Scenario / Incident Description
An e-commerce purchase requires 3 microservices: 1) Deduct Inventory, 2) Charge Credit Card, 3) Issue Invoice. How do you ensure consistency if Step 2 succeeds but Step 3 fails?
534 views
•
Updated 1 month ago
Choreography vs Orchestration Saga
Because 2-Phase Commit (2PC) blocks distributed databases, distributed systems use Saga Pattern:
- A sequence of local transactions where each step publishes an event.
- If any step fails, the Saga executes Compensating Transactions in reverse order (e.g.
RefundPayment,RestoreInventory).
[Order Created] -> (Deduct Inventory) -> (Charge Stripe) -> [Invoice Failed]
|
v
[Trigger Compensating Action]
Refund Stripe
Restore Inventory
Mark Order Cancelled
Idempotency Keys:
Each step checks if the order_id has already been processed to safely allow retries without duplicate charges.
Related Concepts:
#Saga Pattern
#Distributed Transactions
#Idempotency
#Compensating Actions
More System Design, Redis & Distributed Systems Interview Questions
How does the Redis Redlock Algorithm provide Fault-Tolerant Distributed Locking across independent Redis nodes?
Read →
Explain the 3 High-Scale Cache Failure Patterns: Cache Avalanche, Cache Breakdown (Dog-Piling), and Cache Penetration, with mitigations.
Read →
Compare Rate Limiting Algorithms: Token Bucket, Leaky Bucket, Fixed Window Counter, and Sliding Window Log/Counter.
Read →
How do you design a Real-Time Notification System delivering to 10M concurrent users with WebSockets and Redis Pub/Sub?
Read →
How does the Circuit Breaker Pattern prevent cascading failures in Microservice architectures?
Read →