Large scale distributed consensus approachesComputing with a hundred node cluster
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.
More posts in "Large scale distributed consensus approaches" series:
- (24 Nov 2014) Concurrent consistent decisions
- (20 Nov 2014) Large data sets
- (19 Nov 2014) Computing with a hundred node cluster
- (17 Nov 2014) Calculating a way out
Comments
I am very interressted in distributed systems in general and especially in implementing application logic that runs on clustered machines.
What books, web resources can you recommend for learning about this topic?(except Tannenbaums classic book)
David, That really depend on what you want to do. If you want to work with distributed systems, you usually use one of the existing solutions (for example, RavenDB, Cassandra, etc). The storage solution usually handle a lot of that. If you want communication, framework like NServiceBus really help.
If you want to understand how they work or how to build them, you need to look at the papers that actually describe this. Distributed consensus, gossip protocols, messaging patterns, etc.
Interesting. This is similar to the idea of "Chords", that is used in DHT's. Except that it now appears that you have several clusters all of which have more than one "Points of contacts" with other clusters in order to handle failure, and then once you sync with your "Point of contact", it ensures the cluster will gossip and be consistent with each other.
Thanks for the reply Ayende. I am already using a middleware that provides me both distributed/transactional storage and communication.
Now I need to build a framework on top of that (like NServiceBus).
The framework is going to help application developers to build their features on top of this so called "platform".
I am looking for resources how to build such a framework and most of all help the devs designing the long running processes (sagas).
Common questions are: How fine or coarse grained should the sagas be (I know it depends on the actual problem and requirements). How to handle fault tolerance and fail over.. and so on.
Its hard to find good resources for this, the only thing I can do is try, fail, try, fail, ... and look at open source projects.
David, What middleware are you using?
I have answered you directly to ayende@ayende.com.
Comment preview