Friday, April 6, 2012

The CAP Theorem is Wrong! (Not really)

I've been having this long argument w/ a colleague about the merits of SQL vs NoSQL, which I'm anot going to get into here, but recently it devolved into claims along the lines of "The CAP Theorem is Wrong" (no, thats not my quote).
It took me a while to figure out his point, but it turned out to be a fairly common misunderstanding, viz.,
If you have predictable Network Partitions, you can guarantee C, A, and P.
i.e., if you know, beforehand, exactly how your network is going to get blowed up, then you can protect against it, and have Consistency and Availability and Partition Tolerance.  This is absolutely true!

Huh?
Say what?

Well, yeah.  Note the weasel phrase "if you know, beforehand".  This is not unlike saying, "If you know, beforehand, what the winning lottery numbers are going to be, you can win the lottery every time".

The point about Partition Tolerance is that it needs to handle arbitrary / random scenarios.  Limiting your problem space almost certainly helps in the short run, but complexity theory being what it is, its going to cause some fairly comprehensive damage in the long run (Exhibit A:  VaR and the financial crisis).

Stupid example time - you've got this brilliant monitoring system that looks for network issues, and automatically removes any nodes that get disconnected.  Brilliant, right?  Except, what happens if your monitoring system goes down? (And no, the answer isn't, (monitor the monitoring system").

To summarize, if you put bounds around your problem space, you can seemingly "break" the CAP theorem.  But its not broken.  And it'll probably bite your butt really hard.

Update: Yeah, yeah, I know all about PACELC, but just imagine the entertainment associated with trying to explain that to someone who is having a hard enough time with CAP...

0 comments: