To ensure that systems that handle data can continue to operate even if one or more of the servers fail, copies of the data should be stored on multiple servers. Distributed systems employ a technique called replication to maintain multiple copies of data in order to ensure higher availability. To maintain consistency between these replicas, the system can use a quorum, which requires that most of the nodes participating in an operation agree before it is considered successful. However, this approach can also lead to decreased availability, as most replicas must be online and accessible for any operation to be executed. Additionally, quorum alone is not enough to prevent inconsistencies in data, as certain failure scenarios can still result in clients accessing inconsistent information.
A leader-follower pattern in a distributed system appoints one node, known as the leader, as the central point for coordinating the actions of other nodes, called followers. This pattern is implemented to enhance the system’s effectiveness and reliability by centralizing decision-making and task-allocation processes.
In a leader-follower model, the leader node handles client requests by determining the appropriate action and delegating tasks to the follower nodes. These follower nodes then carry out the assigned tasks and provide feedback to the leader on the progress.
We can improve our ability to handle a growing number of readers by adding additional followers and distributing the load of reading among them.
An additional benefit of using the leader-follower pattern is that it is able to sustain read operations even if the leader becomes unavailable. This means that followers can still handle read requests. This feature makes leader-follower replication a useful option for applications that require a lot of read operations.
Having a leader in a system can create a single point of failure. If an issue with the leader goes unnoticed, it can lead to the entire system becoming inaccessible.
In case the system needs to expand, it will require a complete overhaul of the architecture, as it is impossible to expand it beyond one leader.
In case of the failure of the leader, a follower can be appointed as a leader, which speeds up the process of recovering the initial leader node. There are two approaches to selecting the new leader: manual and automatic.
In a manual approach, an operator decides which node should be the leader and notifies all followers.
In an automatic approach, when followers find out that the leader has failed, they appoint the new leader by conducting an election known as a
Kafka: There are partitions in kafka. Every partition of a topic has a specified leader and multiple followers. The leader handles all incoming read and write requests for that specific partition, while the followers replicate the data from the leader passively. This way, if the leader goes down, a follower can take over and maintain the redundancy of messages within the partition.
Paxos: Paxos also applies leader-follower replication. It selects a leader at the start which performs replication.
Free Resources