Live data from Hacker News

The CAP theorem. The Bad, the Bad, & the Ugly

blog.dtornow.com

41–50 of 81 posts

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#41
post #8

This conflict comes up everywhere: Newtonian physics/mechanics: good enough in a lot of cases. Einstein accurate, but unnecessary in most cases. In many cases CAP is good enough for us to have the conversation about how the system works. One can then formulate plan for when it doesn't. The fact that it's imperfect at a formal level is academically interesting, but technically irrelevant for a LOT of conversations whe…

[dead]

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#42

Doesn't strong consistency always imply some form of explicit locking that collides with availability? As in a distributed system it needs to go something like: 1. Get write request to a node 2. Node sends lock on that updated data to rest of nodes 3. After they send back OK the write happens 4. Propagate to rest of nodes 5. After receiving OK on the update from all of the nodes send notification to nodes to lift the…

If by "strong consistency" you mean "linearizability" then no, you can build a distributed atomic register without locking (ABD algorithm[0][1]). The trick is to force readers to complete a possibly-incomplete write returned from a read quorum by writing it to a write quorum before they can return their result (in practice you can elide the write-on-read in the common case where the result from the read quorum already is written to a write quorum). Similarly, writers must find the latest possibly-written version from a read quorum to obtain the version number for their write.

If you need stronger primitives than atomic read/write (e.g. CAS), then ABD is insufficient and you need consensus in the asynchronous model (although synchronized clocks can allow even CAS to be implemented with ABD + leader election with leases[2]).

[0] https://dl.acm.org/doi/pdf/10.1145/200836.200869

[1] https://www.cl.cam.ac.uk/teaching/2223/ConcDisSys/dist-sys-n...

[2] https://arxiv.org/pdf/1702.04242.pdf

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#43

I worked on a wide-area distributed system on 2010-2012. CAP and NoSQL was all the rage then (MongoDB is webscale, after all). The approach we took was to have a single database node be the primary and another replicating from it asynchronously. When a node went offline, a third monitoring node made a decision to promote the backup to primary and communicate this decision to all clients. The three nodes were located…

> Lastly, the approach I never explored but was curious about is the idea of the client being responsible for pushing all values to all nodes rather than replication happening in the background.

You can client replication at industrial scale by having clients push writes to Kafka and then have multiple, independent systems read and apply them. You still have a SPOF on Kafka of course. Another practical issue is that if you take this approach you'll likely need a utility to detect and correct data drift. That's been a feature of the systems I've seen that use this approach successfully.

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#44
post #35

A very common failure mode I see even among experienced senior engineers is to talk about the availability only of their endpoint, not the user experience of the system to meaningfully address user requests. Well-intentioned SLOs around error rate, 99th latency, etc. become meaningless if you don't understand how they affect the various objectives of various production clients. We generally accept that clients may ha…

Latency eventually becomes availability eventually becomes durability. The difference is only quantitative not qualitative.

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#45
There is a theorem called CALM[1] (Consistency as Logical Monotonicity) that shows that systems are eventually consistent iff they are monotonic.

I find that reasoning about consistency is much easier from that perspective, for example it immediately gives you an intuition on why individual CRDTs work.

1: https://arxiv.org/abs/1901.01930

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#46
> Since you have to account for network partitions, you have to choose between consistency and availability if and when a partition occurs. In other words, the CAP divides the world into CP and AP systems.

No, it's two out of three. CA systems don't use a network. Consider a database and a work queue which communicates with the database, where they run on the same server. You can achieve consistency and availability in such a system, but only by eliminating partitioning, and there's only the one way to do that: don't run the systems on a network. Nor is this an unrealistic architecture! Far from it, it is in fact the one you should choose if you need both consistency and availability.

The parts of the article about the CAP theorem and its consequences are on fairly solid ground as I see it. But the observation about the CAP conjecture is bootless, the conjecture that CAP is "pick two" holds up to scrutiny. Not that it proves the conjecture, just that all three of the "pick two" options describe meaningful systems.

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#47
post #5

In my opinion this dead horse is beat. Anyone working on distributed systems knows that CAP is not useful in isolation. See Eric Brewer's followup article from 2012: https://www.infoq.com/articles/cap-twelve-years-later-how-th...

I had an interview question about it, I tried to cite Kleppmann from the distributed systems book and the interview manager got quite offended.

care to elaborate? Not picking apart anything you said but am curious. I am slowly making my way through DDIA. Nothing he says is particularly egregious (so far).

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#48

Doesn't strong consistency always imply some form of explicit locking that collides with availability? As in a distributed system it needs to go something like: 1. Get write request to a node 2. Node sends lock on that updated data to rest of nodes 3. After they send back OK the write happens 4. Propagate to rest of nodes 5. After receiving OK on the update from all of the nodes send notification to nodes to lift the…

My favorite mental framework to reason about consistency in distributed systems, Invariant Confluence, was formulated by Peter Bailis at al in Coordination Avoidance in Database Systems (overview and link to paper http://www.bailis.org/blog/when-does-consistency-require-coo...)

Invariant confluence, determines whether an application requires coordination for correct execution.

You can tailor the invariants to your requirements making invariant confluence a much better tool than CAP

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#49

The ‘network partitions are not optional’ interpretation of CAP is forgetting about the fact that non-distributed-systems are a thing . Sure, as soon as you decided to distribute your system across a network you opted into a world where partition can happen, and you will have to give up consistency or availability. Mainframes, though, provide consistency and availability by being unpartitionable except through use of…

They don't provide availability, because if they go down, they are down. For example, if there is a fire, the whole thing is gone. That's a choice you make.

It's essential to rule out certain happenings when performing analysis, and acts of God are commonly among them.

For example, if you need to account for cosmic rays, you can't prove anything meaningful about software. Redundancy won't get you out of this: you add redundancy, I'll add more cosmic rays.

All that does is force a useful analysis into a muddy and probabilistic one. It's actually pretty important to account for cosmic rays! But you do that on top of an analysis which presumes that the hardware performs correctly. It's not a useful reality to expose to a proof assistant.

To anticipate an objection: yes, you absolutely can rule out network partitions in an analysis, if that's a useful thing to do. For a packet-switched network, it isn't useful. But different network topologies exist, or at least used to, ones where once a circuit is negotiated, you can say useful things about the network without accounting for the kind of equipment failure which might break that circuit. For packet switching, you're going to have a really bad time if you don't account for partitions, because those are expected behavior, one of the properties of the system under consideration.

Re: The CAP theorem. The Bad, the Bad, & the Ugly

#50
This blog post felt unsatisfying. I’m not sure I’ve talked to anyone in the last decade about distributed systems where:

- CAP came up

- all parties immediately agreed that CA was impossible

I still think it’s a useful model for forcing people to think about their failure modes though. Systems, largely, tend to fall into either CP or AP or be horrendously expensive.

You have to choose your trade offs.

I wish the author had expounded a little further on better options. I’ll read the paper linked, but there’d be more punch with more inline content.

Post reply on HN