Do I absolutely need a minimum of 3 nodes/servers for a Cassandra cluster or will 2 suffice?

z8000 picture z8000 · Feb 25, 2010 · Viewed 13.5k times · Source

Surely one can run a single node cluster but I'd like some level of fault-tolerance.

At present I can afford to lease two servers (8GB RAM, private VLAN @1GigE) but not 3.

My understanding is that 3 nodes is the minimum needed for a Cassandra cluster because there's no possible majority between 2 nodes, and a majority is required for resolving versioning conflicts. Oh wait, am I thinking of "vector clocks" and Riak? Ack! Cassandra uses timestamps for conflict resolution.

For 2 nodes, what is the recommended read/write strategy? Should I generally write to ALL (both) nodes and read from ONE (N=2; W=N/2+1; W=2/2+1=2)? Cassandra will use hinted-handoff as usual even for 2 nodes, yes?

These 2 servers are located in the same data center FWIW.

Thanks!

Answer

jbellis picture jbellis · Feb 25, 2010

If you need availability on a RF=2, clustersize=2 system, then you can't use ALL or you will not be able to write when a node goes down.

That is why people recommend 3 nodes instead of 2, because then you can do quorum reads+writes and still have both strong consistency and availability if a single node goes down.

With just 2 nodes you get to choose whether you want strong consistency (write with ALL) or availability in the face of a single node failure (write with ONE) but not both. Of course if you write with ONE cassandra will do hinted handoff etc as needed to make it eventually consistent.