- Which you choose: Consistency (C) or Availability (A) during a partition.
- Why this choice makes sense for user experience and business correctness.
- How you will implement it (replication strategy, consensus or async replication, reconciliation, etc.).
- What the user will see during a partition and how you will recover or reconcile afterwards.
Always answer per operation. Explain the user-visible behavior during a partition, the trade-offs, and the reconciliation or protection mechanisms you will use.
Example: High-throughput, Non-critical Actions — Prefer Availability
Operations like “likes”, many types of social feed writes, or analytics events usually prioritize availability. The goal is to keep the service responsive even when some nodes or network segments are down. If you choose availability, be explicit that the system accepts writes locally and reconciles state later, so users may see temporarily inconsistent or stale data.
- Asynchronous replication: accept local writes and propagate them to replicas later.
- Conflict resolution: use strategies like last-write-wins, domain-specific merge functions, or CRDTs.
- Reconciliation jobs: background read-repair, anti-entropy, or periodic convergence processes.
- Idempotency and monotonic counters: make retries safe and reconciliation deterministic.
- Clear UX messaging: show eventual states (e.g., “Saved locally — syncing…”) where appropriate.
Example: Critical Operations — Prefer Consistency
Operations that can cause financial loss or data corruption—charging a customer, reserving the last inventory item, or transferring funds—usually prefer consistency. In these cases you must avoid conflicting updates and enforce a single source of truth even if it reduces availability during a partition.
- Synchronous replication or quorum-based reads/writes so acknowledged writes are durable and visible immediately.
- Leader-based replication and consensus protocols (e.g., Raft, Paxos) to maintain a single agreed-upon history.
- Distributed transactions or two-phase commit where necessary; use compensating transactions and idempotent retries for failure handling.
- Strategies to reduce unavailability windows: strong cache invalidation, circuit breakers, or graceful degraded modes with explanatory UI.
How to Structure Your Interview Answer (Template)
When asked in an interview, be explicit and structured. For each operation:- Pick a specific operation (e.g., “like”, “feed read”, “payment”, “inventory reservation”).
- State your choice: Consistency (C) or Availability (A) during a partition.
- Explain why: user experience and correctness rationale.
- Describe the implementation: replication, consensus/quorum, reconciliation, retries, idempotency.
- Describe user-visible effects during a partition and how you recover or reconcile afterward.
Quick Comparison Table
Links and References
- CAP theorem — Wikipedia
- Quorum (distributed computing)
- Raft consensus algorithm
- Paxos consensus algorithm
- Conflict-free replicated data type (CRDT)
- Last-write-wins
- Idempotence
- Circuit Breaker pattern — Martin Fowler