DEV Community

Preston Pham
Preston Pham

Posted on • Originally published at Medium on

My 3 years using CAP Theorem in 5 minutes

A colorful painting of a mango tree wearing a cap, in the style of 1800s, pixel art

A simple and popular mention of the CAP Theorem in office work is:

It’s not possible to have Consistency, Availability, and Partition tolerance at the same time.

There are many other variants. I’m sure most engineers have heard at least one.

The more complex but rarely mentioned explanation of the CAP Theorem would be from its original author, in this keynote from July 2000: Brewer PODC Keynote.

The most complex and almost never discussed is CAP’s proof. For example, this nicely written paper: Brewer’s Conjecture And The Feasibility of Consistent, Available, Partition-Tolerance Web Services.

I think the Simple CAP is not suitable to convey its meaning accurately, at least not enough for software development work, especially when decisions need to be made.

💡 Dangerously, decisions that require mentioning CAP are often important ones.

On the other hand, the Complex CAP is too long and too technical. There are many details requiring an understanding of distributed system theory. In most cases outside research, we don’t actually need those. Needless to say, it is rarely used in offices.

I seek something in the middle for my own use and came up with what I call “Sweet CAP.” It is not a single sentence, but four. Here they are:

C in CAP is strong consistency.

With many servers, P is always needed so we simply choose C or A.

A is preferred in most cases not involving money, together with eventual consistency.

Simplicity first, you may not need to worry about CAP at a small scale.

Certainly, saying all four at the same time is weird. I choose to use each sentence when necessary. For example:

Jerry: Because of CAP, our service needs to shut down when we are doing this operation to maintain consistency.

Me: Wait a second, we only need to shut down if we need strong consistency. Is it this case?

I have used these in my work over the last three years in chats, talks, and design documents. My colleagues seem to be okay with it. Most don’t have a problem understanding the message I want to convey. Sometimes, it even ignites more enjoyable discussions.

That’s why it is Sweet CAP.


Top comments (0)