FloodSet Algorithm - Distributed Consensus even when processes crash



1069 views Distributed Systems



Reaching consensus is extremely important in any distributed network. For example, we cannot have two data nodes in a cluster where one thinks that price is $1000 while the other thinks it is $2000.

So, we need the nodes to talk to each other and reach a consensus and converge on the true value of price. Reaching consensus is easy when there are no failures - no network failures, or process failures.

Reaching a consensus

  • is impossible when the network is unreliable
  • is simple when there are no network/process failures
  • is tricky when we have to deal with process failures

FloodSet Algorithm

The core idea of the FloodSet algorithm is to keep track of all the values seen so far and use some decision rule such that all nodes choose the same value.

Every node maintains a set W to hold all the values seen so far. If we assume at max f nodes would fail then the FloodSet algorithm runs for f + 1 rounds, giving chances for processes to fail.

Every node starts with W = {v}, its own value. In each round, every node broadcasts W in the network. When a node receives the W from other nodes it updates its W by doing a set union.

After the f + 1 rounds, every node will have the same W that holds all possible values of the network participating in the transaction.

Decision Making

The decision-making is decentralized. If W contains just one value then the node converges to that value. If it contains more than one value, the node defaults to the last value.

This decision-making is use-case specific, so defaulting to the old value can mean that the transaction is aborted and the node is reverting to the old value.

Alternative Decision Strategy

Depending on the usecase, we may choose another decision strategy like picking the smallest value or the largest value or the oldest value, or the newest value.

So long as we have a total ordering of the values, we can define our own decision strategy.


Arpit Bhayani

Arpit's Newsletter

CS newsletter for the curious engineers

❤️ by 38000+ readers

If you like what you read subscribe you can always subscribe to my newsletter and get the post delivered straight to your inbox. I write essays on various engineering topics and share it through my weekly newsletter.




Other essays that you might like



Be a better engineer

A set of courses designed to make you a better engineer and excel at your career; no-fluff, pure engineering.


Paid Courses

System Design for Beginners

A masterclass that helps early engineers and product managers become great at designing scalable systems.

300+ learners

Details →

System Design Masterclass

A masterclass that helps you become great at designing scalable, fault-tolerant, and highly available systems.

1000+ learners

Details →

Redis Internals

Learn internals of Redis by re-implementing some of the core features in Golang.

98+ learners

Details →

Free Courses

Designing Microservices

A free playlist to help you understand Microservices and their high-level patterns in depth.

823+ learners

Details →

GitHub Outage Dissections

A free playlist to help you learn core engineering from outages that happened at GitHub.

651+ learners

Details →

Hash Table Internals

A free playlist to help you understand the internal workings and construction of Hash Tables.

1027+ learners

Details →

BitTorrent Internals

A free playlist to help you understand the algorithms and strategies that power P2P networks and BitTorrent.

692+ learners

Details →