Large Scale Distributed Consensus Approaches: Computing with a Hundred Node Cluster
Join the DZone community and get the full member experience.Join For Free
i’m using 100/99 node cluster as the example, but the discussion also apply for smaller clusters (dozens of nodes) and bigger clusters (hundreds or thousands). pretty much the only reason that you want to go with clusters of that size is that you want to scale out your processing in some manner. i’ve already discussed why a hundred node cluster isn’t a good option for safety reasons.
consensus algorithm create a single consensus in the entire cluster, usually about an order set of operations that are fed to a state machine. the easiest such example would be a dictionary. but it make no sense to have a single dictionary spread across hundred nodes. why would you need to do that? how would it give you the ability to make full use of all of the power of all those nodes?
usually nodes are used for either computing or storage purposes. computing is much easier, so let us take that as a good example. a route calculating system, need to do a lot of computations on a relatively small amount of information (the map data). whenever there is a change in the map (route blocked, new road open, etc), it needs to send the information to all the servers, and make sure that it isn’t lost.
since calculating routes is expensive (we’ll ignore the options for optimizations and caching for now), we want to scale it to many nodes. and since the source data is relatively small, each node can have a full copy of the data. under this scenario, the actual problem we have to solve is how to ensure that once we save something to the cluster, it is propagated to the entire cluster.
the obvious way to do this is with a hierarchy:
basically, the big icons are the top cluster, each of which is responsible for updating a set of secondary servers, which is then responsible for updating the tertiary servers.
to be perfectly honest, this looks nice, and even reasonable, but it is going to cause a lot of issues. sure, the top cluster is resilient to failures, but relying on a node to be up to notify other nodes isn’t so smart. if one of the nodes in the top cluster goes down, then we have about 20% of our cluster that didn’t get the notice, which kind of sucks.
a better approach would be to go with a management system and a gossip background:
in other words, the actual decisions are down by the big guys (literally, in this picture). this is a standard consensus cluster (paxos, raft, etc). once a decision has been made by the cluster, we need to send it to the rest of the nodes in the system. we can do that either by just sending the messages to all the nodes, or by selecting a few nodes and have them send the messages to their peers. the protocol for that is something like: “what is the like command id you have? here is what i have after that.” assuming that each processing node is connected to a few other servers, that means that we can send the information very quickly to the entire cluster. and even if there are errors, the gossiping server will correct it (note that there is an absolute order of the commands, ensured by the consensus cluster, so there isn’t an issue about agreeing to this, just distributing the data).
usually the gossip topology follows the actual physical distribution. so the consensus cluster will notify a couple of servers on each rack, and let the servers in the rack gossip among themselves about the new value.
this means that once we send a command to the cluster, the consensus would agree on that, then we would distribute it to the rest of the nodes. there is a gap between the consensus confirming it and the actual distributing to all the nodes, but that is expected in any distributed system. if it is important to sync this on a synchronized basis across the entire cluster, the command is usually time activated (which require clock sync, but that is something that we can blame on the ops team, so we don’t care ).
with this system, we can have an eventually consistent set of data across the entire cluster, and we are happy.
of course, this is something that is only relevant for compute clusters, the kind of things were you compute a result, return it to the client and that is about it. there are other types of clusters, but i’ll talk about them in my next post.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
A Comprehensive Guide To Testing and Debugging AWS Lambda Functions
How To Use Geo-Partitioning to Comply With Data Regulations and Deliver Low Latency Globally
Manifold vs. Lombok: Enhancing Java With Property Support
Hiding Data in Cassandra