03 / 03

In a network partition, would you choose Availability or Consistency for a banking app? What about for a Twitter/X 'Like' counter?

Difficulty: 7/10
CAP theorem, availability vs consistency, partition handling

During a network partition, a banking app must choose Consistency over Availability to prevent data corruption and financial errors, while a Twitter 'Like' counter can choose Availability over Consistency because temporary inaccuracies are acceptable for user experience.

The choice between Availability and Consistency during a network partition depends entirely on the business domain and the consequences of each trade-off. For a banking app, the cost of inconsistency is catastrophic—duplicate transactions, incorrect balances, and financial losses. For a Twitter 'Like' counter, the cost of unavailability is user frustration, while temporary inconsistency is barely noticeable. The CAP theorem forces this explicit trade-off, and different systems make opposite choices for good reason.

Banking App: Choose Consistency (CP System)
  1. 1

    Why Consistency Wins: In banking, data correctness is paramount. If a network partition occurs, showing a user an incorrect balance or allowing a double-spend could have legal and financial consequences. The system must prioritize consistency even if that means rejecting transactions until the partition heals.

  2. 2

    What Happens During Partition: The system becomes partially unavailable. Some users may see errors when trying to transfer money or check balances. However, any transaction that completes is guaranteed to be correct.

  3. 3

    Real-World Example: When a bank's network partition occurs, ATM withdrawals might be limited or declined, and online banking might show a "service unavailable" message rather than risking displaying incorrect balances. This matches CP behavior—consistency is preserved at the cost of availability.

  4. 4

    Write Concern Configuration: In MongoDB, a banking app would use { w: 'majority', j: true }. During a partition, if a majority of nodes cannot acknowledge writes, the system rejects writes rather than committing potentially unreplicated data.

Twitter 'Like' Counter: Choose Availability (AP System)
  1. 1

    Why Availability Wins: Like counters are eventually consistent by nature. A user might see a slight discrepancy between the number of likes shown and the actual count for a few seconds, but this has no material impact. Users would rather the app work and show a slightly stale count than see an error or timeout.

  2. 2

    What Happens During Partition: The system continues to accept and show likes, even if nodes can't immediately synchronize. When the partition resolves, counts reconcile. Users experience no interruption.

  3. 3

    Real-World Example: During a network issue, you can still like a tweet, and the counter increments immediately (eventually consistent). Even if the number shown differs slightly across users, the core functionality remains available. Twitter/X explicitly prioritizes availability for these non-critical counters.

  4. 4

    Write Concern Configuration: A social media app might use { w: 1 } with no journal requirement, allowing writes to proceed as long as one node accepts them, maximizing availability during network issues.

Implementation Comparison
The Business Impact Analysis
  1. 1

    Banking App Cost of Inconsistency: Regulatory fines, customer lawsuits, fraud, incorrect interest calculations, reconciliation failures. Severity: Critical.

  2. 2

    Banking App Cost of Unavailability: Customer frustration, missed transactions, support calls. Severity: Significant but temporary.

  3. 3

    Twitter Like Counter Cost of Inconsistency: Slightly inaccurate display for seconds/minutes. Severity: Minimal, users rarely notice.

  4. 4

    Twitter Like Counter Cost of Unavailability: Inability to engage with content, degraded user experience, reduced engagement metrics. Severity: Moderate for user retention.

  5. 5

    Decision Framework: If temporary inconsistency causes legal/financial harm, choose consistency. If unavailability harms user engagement more than temporary inaccuracy, choose availability.

Modern systems often mix these trade-offs at different layers. A banking app might use CP for core ledger operations but AP for displaying transaction history with eventual consistency. Twitter uses CP for direct messages (you don't want messages lost) but AP for likes and follower counts. Understanding these trade-offs is critical to designing systems that meet business requirements while using the right tools for each workload.

Scenario Questions

0-2 years experience

  1. 1Suppose a network partition occurs between two data centers serving our banking transaction service. Would you prefer the system to keep processing new transfers or to reject them until the partition heals? Explain your choice.
  2. 2If the same partition happens for a simple 'Like' counter on a social feed, what would you let the user see during the outage? Why?

2-5 years experience

  1. 1Our banking app uses a distributed ledger replicated across three regions. During a partition, we observed some accounts showing different balances. Walk me through how you would redesign the system to favor consistency, and what impact that has on availability.
  2. 2The 'Like' count on a high‑traffic tweet is backed by an eventually consistent cache. After a partition, the count diverges from the true total. How would you detect and reconcile the discrepancy without hurting user experience?
  3. 3We tried to switch the banking service to an AP‑oriented NoSQL store and saw transaction failures. What debugging steps would you take to pinpoint whether the issue is due to consistency guarantees or something else?

5-8 years experience

  1. 1Design a partition‑tolerant architecture for a banking platform that must guarantee ACID properties for transfers. Discuss the trade‑offs you’d make between synchronous replication, quorum writes, and fallback modes.
  2. 2For a global 'Like' service that must stay available even under network splits, propose a design that balances eventual consistency with user‑perceived correctness. Include how you’d handle write conflicts and roll‑backs.
  3. 3Imagine we need to migrate our banking backend from a CP‑oriented relational DB to a more scalable AP system. Outline a phased migration plan that preserves consistency guarantees for critical operations.

8+ years experience

  1. 1At the organization level, we need a policy for choosing consistency vs availability across all services. How would you create a framework that guides teams—like payments vs social features—to make the right trade‑offs during partitions, and how would you enforce it?
  2. 2Our company plans to unify logging and monitoring for partition events across microservices. Describe an architecture that provides real‑time visibility, supports automated failover decisions, and aligns with regulatory requirements for financial data.
  3. 3Consider a long‑term scenario where we must support both strict consistency for financial transactions and high availability for social interactions on the same platform. How would you structure the data layer, service contracts, and deployment pipelines to accommodate both SLAs without excessive duplication?

Follow-up Questions

  • What would happen if you chose availability for the banking service during a prolonged partition?
  • How would you measure the impact of eventual consistency on user trust for the Like feature?
  • Can you think of any hybrid approach that gives both services acceptable guarantees?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.