PACELC theorem

CAP plus latency · Part of Databases

Key idea

Practice

6 questions · about 3 min

Explained step by step

PACELC theorem

PACELC extends the CAP theorem. It says: if there's a Partition (P), you choose between availability (A) and consistency (C); else (E), with the system running normally, you choose between latency (L) and consistency (C). It was described by Daniel J. Abadi. It's like a delivery: if the street is blocked, you choose between another route or waiting; and with the street clear, you still choose between arriving fast or checking the order twice.

PACELC was created to fill a gap in CAP: CAP says nothing about performance or latency. By CAP, a database is 'available' even if it answers a query after 30 days. Obviously that's useless for anything real. PACELC brings speed into the discussion. It's like a restaurant that says 'we always serve': if your dish arrives a week later, it's technically true, but it doesn't help you.

With PACELC you can describe any distributed database with 2 choices: what it does with a partition (A or C) and what it does without one (L or C). A database that always prioritizes answering fast chooses A with a partition and L without. One that always prioritizes correct data chooses C in both cases. It's like describing someone by how they drive: in a storm and on a sunny day.

To remember PACELC, read it as a sentence: 'if there's a Partition, A or C; Else, L or C'. The first half is CAP; the second is what's new. Since the network works almost all the time, the second half is the one you feel day to day. It's like car insurance: a crash (partition) is rare, but fuel consumption (latency) you pay every day.

Latency

The new part of PACELC is the E: even with no network cut at all, you must choose between latency and consistency. To be consistent, each write waits until every copy has it, which takes longer. To answer fast, you reply before every copy is up to date. It's like emailing 5 people: either you wait for all 5 to confirm they read it, or you move on right away.

Choosing latency means answering fast even if some copy doesn't have the latest change yet. Choosing consistency means waiting until all copies have it and answering more slowly. For a photo feed, latency fits: nobody notices a post from 1 second ago. For a payment, consistency fits: better to take 100 ms longer than to charge twice. It's like a waiter: they can bring the bread right away or wait until all the dishes are ready.

Terms in this lesson

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.

Key idea

CAP plus latency