Database DesignACID vs BASEHard⏱️ ~3 min

Production Implementation Patterns

Blending ACID and BASE

Production systems choose consistency per boundary. Use ACID within a service (orders, payments) and BASE across services (catalog, sessions). Change Data Capture (CDC) streams changes from ACID source to BASE projections, accepting 100ms-2s staleness for derived views. This isolates transactional complexity while scaling reads.

Saga Pattern

Sagas replace distributed transactions with a sequence of local transactions plus compensating actions. Checkout saga: (1) reserve inventory, (2) charge payment, (3) confirm order. If payment fails, compensation releases inventory. Each step must be idempotent (safely retryable) using unique operation IDs. Expect temporary inconsistencies during execution (seconds to minutes); design UIs to show "processing" states.

Quorum Tuning

With N replicas, R (read quorum) and W (write quorum) control consistency. If R + W > N, reads see latest writes. Example: N=3, R=2, W=2 ensures overlap, guaranteeing consistency but doubling latency. R=1 gives faster reads but may return stale data.

Observability

Track latencies per consistency level: eventual P99, strong P99. Monitor replication lag. For ACID, track lock wait time, deadlock rate, abort rate. Set SLOs per operation type.

💡 Key Takeaways
CDC from ACID source to BASE projections accepts 100ms-2s staleness, isolating transactional writes while scaling reads
Sagas: sequence of local transactions with compensating actions; each step must be idempotent using unique operation IDs
Quorum math: R + W > N ensures reads see latest writes; N=3, R=2, W=2 guarantees consistency but doubles latency
Track metrics per consistency level: eventual read P99, strong read P99, replication lag, deadlock rate
📌 Interview Tips
1Explain CDC flow: ACID database emits change events to message queue, consumers update read-optimized projections
2For saga idempotency: store operation_id before processing, check existence before retry, return cached result on duplicate
3Quorum example: N=3, W=2, R=2 means any 2 replicas overlap on both reads and writes, guaranteeing fresh reads
← Back to ACID vs BASE Overview