The CAP theorem

Eric Brewer, professor at UC Berkeley came up with the CAP theorem. CAP stands for Consistency, Availability, and Partitioning or Distributability. He says out of the 3, the maximum you can achieve is 2.

For example, if you’re Amazon and you want various servers distributed all over the world for better availability, then you must forfeit consistency. If you buy a book in New York while I buy one in Singapore from two different servers, then these two databases are out of sync and not consistent. Eric calls this “eventually consistent”, as they will be synchronized later.

Another example is of a major bank, where billions of dollars get transferred between accounts. Consistency is so important besides availability that you forfeit “distributability”. Hence you centralize everything out of one data center.

I somehow like this “maximum 2 out 3” theorem. A friend who went to MIT for undergraduate as well as graduate school had told me that between sleep, grades, and friends you can only have two. If you want to sleep and do well in studies, then forget friends. If you like to socialize and also sleep, then forget grades. If you like friends and want to keep good grades, then forget sleep.

Another “2 out of 3” example is an entrepreneur who has to pick two out of the 3 variables – work, family, and socializing. It’s well-known that founders of start-ups with families have to give up socializing. Some do the mistake of too much work and socializing and neglect the family.

In the new world of Web 2.0, Eric’s CAP theorem is very insightful. He defined BASE as opposed to ACID (atomicity, consistency, isolation, durability) as another end of the spectrum. BASE stands for Basically Available, Soft state, Eventually consistent. One must examine where the application fits in the scale between ACID and BASE and decide accordingly.


2 responses to “The CAP theorem

  1. Interesting, especially the entrepreneur perception.

  2. Thanks!

    Nice to see that you have a blog. Hope you are well.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s