New Survey: Leveraging real-time data delivers higher revenue growth and increased developer productivity. Learn more.
Let’s talk about the analogy of Apache Cassandra Datacenter & Racks to actual datacenter and racks. I kind of enjoy the use of the terms datacenter and racks to describe architectural elements of Cassandra. However, as time moves on the relationship between these terms and why they’re called datacenter and racks can be obfuscated.
Take, for instance, a datacenter could just be a cloud provider, an actual physical datacenter location, a zone in Azure, or region in some other provider. What an actual Datacenter in Cassandra parlance actually is can vary, but the origins of why it’s called a datacenter remains the same. The elements of racks also can vary, but also remain the same.
Origins: Racks & Datacenters?
Let’s cover the actual things in this industry we call datacenter and racks first, unrelated to Apache Cassandra terms.
Racks: The easiest way to describe a physical rack is to show pictures of datacenter racks via the ole’ Google images.
A rack is something that is located in a data-center, or even just someone’s garage in some odd scenarios. Ya know, if somebody wants serious hardware to work with. The rack then has a number of servers, often various kinds, within that rack itself. As you can see from the images above there’s a wide range of these racks.
Datacenter: Again the easiest way to describe a datacenter is to just look at a bunch of pictures of datacenter, albeit you see lots of racks again. But really, that’s what a datacenter is, is a building that has lots and lots of racks.
However, in Apache Cassandra (and respectively DataStax Enterprise products) a datacenter and rack do not directly correlate to a physical rack or datacenter. The idea is more of an abstraction than hard mapping to the physical realm. In turn, it is better to think of datacenter and racks as a way to structure and organize your DataStax Enterprise or Apache Cassandra architecture. From a tree perspective of organizing your cluster, think of things in this hierarchy.
- Node (vnode)
Apache Cassandra Datacenter
An Apache Cassandra Datacenter is a group of nodes, related and configured within a cluster for replication purposes. Setting up a specific set of related nodes into a datacenter helps to reduce latency, prevent transactions from impact by other workloads, and related effects. The replication factor can also be set up to write to multiple datacenters, providing additional flexibility in architectural design and organization. One specific element of the datacenter to note is that they must contain only one node type:
- Transactional: A standard Cassandra node.
- DataStax Enterprise Graph: The Graph database offering from Datastax.
- DataStax Enterprise Analytics: An integration with Apache Spark.
- DataStax Enterprise Search: Integration with Apache Solr.
- DataStax Enterprise Search Analytics: Search queries within analytics jobs.
Depending on the replication factor, data can be written to multiple datacenters. Datacenters must never span physical locations. Each datacenter contains only one node type. The node types are:
- Transactional: Previously referred to as a Cassandra node.
- DSE Graph: A graph database for managing, analyzing, and searching highly-connected data.
- DSE Analytics: Integration with Apache Spark.
- DSE Search: Integration with Apache Solr. Previously referred to as a Solr node.
- DSE SearchAnalytics: DSE Search queries within DSE Analytics jobs.
Apache Cassandra Racks
An Apache Cassandra Rack is a grouped set of servers. The architecture of Cassandra uses racks so that no replica is stored redundantly inside a singular rack, ensuring that replicas are spread around through different racks in case one rack goes down. Within a datacenter, there could be multiple racks with multiple servers, as the hierarchy shown above would dictate.
To determine where data goes within a rack or sets of racks Apache Cassandra uses what is referred to as a snitch. A snitch determines which racks and datacenter a particular node belongs to, and by respect of that, determines where the replicas of data will end up. This replication strategy which is informed by the snitch can take the form of numerous kinds of snitches, some examples include;
- SimpleSnitch – this snitch treats order as proximity. This is primarily only used when in a single-datacenter deployment.
- Dynamic Snitching – the dynamic snitch monitors read latencies to avoid reading from hosts that have slowed down.
- RackInferringSnitch – Proximity is determined by rack and datacenter, assumed corresponding to 3rd and 2nd octet of each node’s IP address. This particular snitch is often used as an example for writing a custom snitch class since it isn’t particularly useful unless it happens to match one’s deployment conventions.
In the future, I’ll outline a few more snitches, how some of them work with more specific detail, and I’ll get into a whole selection of other topics. Be sure to subscribe to the blog, the ole’ RSS feed works great too, and follow @CompositeCode for blog updates. For discourse and hot takes follow me @Adron.
The article was cross-posted from Adron's personal blog, Composite Code.