esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

Availability vs Consistency: What to Protect When the Network Splits

When servers cannot reach each other, a system must choose between answering now with old data and waiting to be sure. Learn how to choose for each feature.

In short

When servers cannot reach each other, a system must choose between answering now with old data and waiting to be sure, and that choice is made per feature.

11 min readFree

Start here

Imagine a shopping site that runs computers in two cities. A customer asks for a product page, but the two cities have lost their link. What should the site do? It could show what it knows right now, even if that is a little old. Or it could wait until it can check with the other city. This lesson explains that choice. You will learn what availability and consistency mean, why a broken link forces you to pick one, and how to decide for each feature.

Key words

Node
One computer or server that runs part of a system.
Replica
A copy of the same data, kept on another node.
Network partition
A break where some nodes cannot reach other nodes, even though each side still runs.
Availability
Every request sent to a working node gets a response.
Consistency
Every read returns the most recent write, so people see the same up-to-date value.
Stale data
An old value that has not been updated yet.
CP
Consistent and partition tolerant. During a split, the system protects correct data, even if some requests wait or fail.
AP
Available and partition tolerant. During a split, the system keeps answering, even if some answers are stale.

Partition tolerance is a term you will see often. It means the system keeps running when a split happens. Both CP and AP systems have it. The real question is what they do about the data.

What are the two promises a system can make?

A system that runs on many nodes can make promises to the people who use it. Two of the most important promises are about availability and consistency. The words sound alike, but they measure different things.

  • The availability promise

    Every request that reaches a working node gets a response. The answer might not be the newest one, but the user is not turned away. A feed that loads with some old posts still keeps this promise.

  • The consistency promise

    Every read returns the latest write. If someone changes a price, the next person who reads that price sees the new one. This promise is about being right, not about being quick.

  • Why they are not the same

    A system can answer fast with old data. That is available but not consistent. It can also hold a request until it is sure. That is consistent but may not answer in time. Both matter, and you cannot always have both.

Tip

A fast answer is not automatically a correct answer. When you read a design, ask two separate questions: will it respond, and will the response be the newest value?

Why does a partition force a choice?

When the network is healthy, nodes talk all the time. A write on one node is sent to its replicas, so every read gets the same answer. Most systems can be both available and consistent in that state. The trouble starts when a split happens. A node cannot hear from the nodes it used to talk to, so it cannot tell whether it has the newest write. It must then pick one promise to keep. It can answer from its own copy, which keeps it available but may be stale. Or it can refuse or wait, which keeps the data right but makes the request fail or slow down.

What happens during a partition?

  1. 1

    The network splits

    The nodes form two groups. Each group can talk within itself, but not across the break.

  2. 2

    A write lands on one side

    A shopper or staff member changes a value on one side. The other side never hears about the change.

  3. 3

    A read arrives on the other side

    The other side must decide what to return. Its own copy may now be out of date.

  4. 4

    The system picks a side

    It either answers with what it holds, or it holds the request back. This is the trade-off at the heart of this lesson.

Should a system refuse or answer with old data?

  • CP: protect the right answer

    A CP system refuses or delays requests that could return wrong data. Users may see an error or wait longer, but they will not get a wrong answer.

  • AP: keep answering

    An AP system keeps replying during the split. Some replies may be stale. Once the network heals, copies that disagree must be reconciled by the system's own rule, such as keeping the write with the latest timestamp, or by returning the conflicting writes to the client to merge.

Neither choice is free. CP costs some availability. AP costs some consistency. Your job as a designer is to decide which cost the feature can carry.

Why is the choice made per feature?

A common mistake is to label a whole system as CP or AP. In practice, the choice is made feature by feature, and sometimes operation by operation. One product can have a part that favors consistency and another part that favors availability. A shop might show product reviews that are a little old, while the stock count at checkout must be exact.

Why split it this way? Each feature has a different cost when it is wrong. A stale review costs very little. A wrong stock count can cost money, trust, and a refund. The cost of being wrong should decide the rule, not the name of the whole system.

Tip

When you describe a design, name the choice for each feature. Say 'payments favor consistency and the feed favors availability.' That is clearer than saying 'the system is CP.'

Same product page, two answers

Take one product page. The product name and photo can come from a copy kept close to the shopper, because a slightly old photo does no harm. The number of items left should come from a source that can confirm it, because a wrong number can sell the same item twice. The page is one screen, but it has an AP part and a CP part. Designers split it this way on purpose.

A rule of thumb for choosing

How do you decide which side a feature should favor? Ask one question: what does it cost to show stale data, compared with showing an error or making someone wait? The answer usually points to a side.

  • Money and inventory lean consistency

    If a wrong number lets someone spend money twice or sell the last item twice, stale data is very costly. Choose CP and accept some waiting or errors.

  • Feeds and counters lean availability

    If a like count is off by a few for a short time, few people notice and nothing breaks. Choose AP and let the number catch up later.

  • Look at whether the mistake can be fixed

    If a wrong answer can be repaired later with little harm, AP is often fine. If it cannot be undone, such as a payment that was already sent, lean toward CP.

  1. 1

    Name the action

    Write the exact action, such as withdraw cash or show the like count.

  2. 2

    Name the worst stale case

    Ask what happens if the answer is old by a few seconds or a few minutes.

  3. 3

    Name the cost of an error or a wait

    Ask whether users can accept an error and retry, or whether waiting would hurt them.

  4. 4

    Pick the side and explain it

    If stale data is worse, choose CP. If an error or wait is worse, choose AP. Write one sentence that says why.

Worked example: a shopping site in a split

Let us walk through a shopping site during a partition between two data centers. A data center is a building full of servers. Each one holds a copy of the product data, and the link between them has broken. Two parts of the same site behave differently.

  1. 1

    The link breaks

    The east data center cannot reach the west one. Both still serve customers, so the site stays up.

  2. 2

    The likes count is read

    A shopper opens a product page. The page asks for the like count. The east copy has an older count, and the page shows it. Nobody is turned away, and the number is only a little old. Likes are an AP feature.

  3. 3

    Checkout checks the stock

    The shopper clicks buy on the last item. Checkout must check the remaining stock. If the east side cannot confirm the count with the west side, checkout refuses or waits. It does not risk selling the same item twice. Stock is a CP feature.

  4. 4

    The link heals

    The data centers reconnect. The like count catches up to the true number. The item was never sold twice, because checkout waited for proof. The shopper who was asked to wait can try again.

Notice what each choice protected. The likes count protected the shopper's experience. The checkout protected the shop from selling one item twice.

Try the idea in code

The sample below is a tiny model, not a real database. It shows how the same read can give a stale answer, an error, or the newest value, depending on the mode and on whether the network is split.

Python
def read_value(partitioned, mode, local_copy, latest):
    if not partitioned:
        return str(latest)
    if mode == "CP":
        return "error: cannot confirm"
    return "stale: " + str(local_copy)


print(read_value(True, "AP", 90, 100))
print(read_value(True, "CP", 90, 100))
print(read_value(False, "AP", 90, 100))

Output

stale: 90
error: cannot confirm
100

Read the output line by line. During the split, the AP mode answers with the old copy. The CP mode refuses to answer. When there is no split, both modes return the newest value.

Quick checks

Try these two short scenarios. Each one needs the idea from this lesson to answer.

Quick check

A banking app runs servers in two regions. The regions lose contact with each other. A customer asks to withdraw cash at an ATM connected to region A. Region A's copy of the balance may be out of date. What should the system do?

Quick check

A video site shows view counts from two regions. The regions are split. Region A shows 1,190 views and region B shows 1,204. A viewer asks why the numbers differ. Which design fits the cost of being wrong?

Common mistakes to avoid

  • One label for the whole system

    Most products mix choices. Payments and feeds in the same app can follow different rules, so do not label the whole app with one word.

  • Thinking available means correct

    An available system can still answer with old data. Availability promises a response, not the newest value.

  • Thinking stale data is always a bug

    Some features accept stale data by design. It becomes a bug only when the feature needed the newest value, such as a stock count at checkout.

Tip

For every feature, ask two questions: what is the worst stale answer, and what is the worst error or wait? Answer both before you choose a side.

Where to go next

This lesson gave you the trade-off and a way to decide. Later lessons go deeper. They cover the formal CAP theorem, the different consistency models, ways to keep services up such as fail-over (moving work to a backup when a main node fails) and replication, the math behind uptime figures, and how to choose a database for each trade-off. As you read them, keep one question in mind: what does a wrong answer cost?

Sources

How is this lesson?

Last updated on 17 November 2026

Learn with me

Every lesson is free. I add new ones as I learn. Have a question, or want help with your own work? Book a short call.