SeniorDatabases

Explain the CAP theorem and what it means when choosing a distributed datastore.

What they are really testing: Senior signal: understands that during a network partition you must trade consistency against availability, and can apply CP vs AP to real choices rather than reciting the acronym.

A real interview question

Explain the CAP theorem and what it means when choosing a distributed datastore.

What most people say

drag me

CAP says you can only pick two of consistency, availability, and partition tolerance.

The "pick two" phrasing is the common oversimplification. Partition tolerance is mandatory in a distributed system, so the real choice is C vs A during a partition. A senior applies CP/AP to actual data needs, not recites the triangle.

The follow-ups they ask next

  • Why is "pick two" a misleading way to state CAP?

    Partition tolerance is not optional in a distributed system, partitions will happen, so you do not really get to drop P. The genuine choice is C vs A during a partition; the rest of the time you have both.

  • Give an example of when you would pick CP over AP.

    Data where serving stale/conflicting values is worse than being briefly unavailable, account balances, inventory, bookings. You would rather reject a request during a partition than double-sell or show a wrong balance.

What the interviewer is listening for

  • Knows P is mandatory, so the choice is C vs A during a partition
  • Explains CP vs AP behavior
  • Maps the choice to real data needs (+ PACELC)

What sinks the answer

  • Recites "pick two" uncritically
  • Thinks you can drop partition tolerance
  • Cannot apply CP/AP to a real choice

If you genuinely do not know

Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.

CAP: [Consistency (reads see latest write), Availability (always a response), Partition tolerance (works despite network splits)]. Since [partitions are unavoidable, P is mandatory], the real choice during a partition is [C vs A]. [CP refuses/blocks to stay correct; AP keeps serving, possibly stale, and reconciles]. Choose [by the data: CP for balances/inventory, AP for feeds/carts]. (PACELC adds the [latency vs consistency] trade-off.)

Keep going with databases

All 336 cloud engineer questions

Knowing the answer is not the same as recalling it under pressure

Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.

Start free