Cassandra Internals

What this lesson covers

This lesson uses the internal architecture of Cassandra to explain common design patterns in NoSQL key-value databases. The example cluster has five nodes, each owning a range of values. Instead of numeric IDs, requests carry keys, which may be strings or UUIDs, so each key is passed through a hash function and the result decides which node handles it, moving clockwise to the next node on the ring. With a uniformly distributed hash function, each of the five nodes gets roughly 20 percent of the load and can be used to full capacity. A poor hash function can send most requests to one node, which then becomes the bottleneck for the whole cluster. If the hash function cannot be changed, that node can forward requests to a second cluster that uses a different hash, a form of multi-level sharding. The video gives a hypothetical map service sharded by country, where one country's traffic spikes during a festival. The same ring decides replication: the nodes after the owning node keep copies, so data survives a crash and any replica can serve reads. The lesson ends by showing why replicas need distributed consensus, since a slow replica can make a recently created profile look missing, and introduces quorum as one solution.

  • Keys are hashed and mapped to the next node clockwise on a ring of nodes
  • A uniform hash function spreads load evenly so every node can run near full capacity
  • Multi-level sharding with a second hash function can relieve a node overloaded by a poor hash
  • Replicas are placed on the nodes following the owner, improving durability and read distribution
  • Replicas that lag behind can return wrong answers, which is why consensus mechanisms like quorum are needed