What is Multi-Leader Replication?

In replication there are specific scenarios where replication patterns are more suitable than others, depending on an applications use case. Subsequently, multi-leader replication is an alternative from single leader replication, as previously mentioned in my initial post on what replication is.

Why Multi-Leader Replication Over Single Leader Replication?

Firstly, I will outline the major floors with single leader replication, so that we can understand why you may consider this alternative approach.

Disadvantage of Single Leader Replication

🤔 All writes must go through it.

  • For instance, if the database is partitioned, each partition has one leader…
    • Although, different partitions may have there leaders on different nodes…
    • So for any reason you cannot connect to the leader…
      • ❌ For example, if there is a network disruption between you and the leader, you cannot write to the database

The Solution Multi-Leader Replication

This is considered a natural extension to the leader-based replication model

  • Aka… Multi leader replication, master master or active active replication.
    • In this setup each leader simultaneously acts as a follower to the other leaders
  • ✅ It allows more than one node to accept writes
  • ✅ Replication still occurs in the same way
  • ⚙️ Each node that processes a write, must forward that data change to all the other nodes

Use Cases for Multi-Leader Replication

⚠️ It rarely makes sense to use a multi-leader set up within a single data centre. Because usually, the benefits outweigh the added complexity,

🤔 However, there are some situations when this configuration is reasonable…

  • Multi-Data-Centre Operation
    • Consider a scenario where you have a database with replicas in several different data centres
      • Perhaps you can tolerate a failure of an entire data centre
      • Or perhaps you want to be closer to your users

Normal Follower and Leader Replication

🟡 The leader has to be in one of the data centres and all writes must go through that data centre.

Multi Leader Configuration

🟡 You can have a leader in each of the data centres, while you may have a normal follower and leader replication in each data-centre.

🟡 The leaders of these data centre can replicate its changes to leaders in other data centres.

Comparison: Multi-Data Centre Deployments… Single Leader vs Multi-leader Configuration

📈 Performance?

  • Single leader configuration for multi data centres?
    • Every write must go over the internet to the data centre with the leader
      • This can add significant latency to writes
      • May even contravene the purpose of having multiple data-centres in the first place!
  • Multi-leader configurationfor multi data centres?
    • Every write can be processed in the local data centre and this is replicated asynchronously to other data centres.
      • Thus, the inter-data centre network delay are hidden, which means, perceived performance is improved visibly for end users.

🛡 Tolerance of Data Centre Outages?

  • Single leader configuration tolerance?
    • If a data centre with the leader fails… failover can be used to promote a follower to a leader in another data centre.
    • More reading behind node failure election process found here: Replication – what is it?
  • Multi-leader configurationtolerance?
    • Each data centre can operate independently between each other, replication catches up when a failed data centre comes back online.

🕸 Tolerance of network problems?

  • Single leader configuration network?
    • ❌ Traffic between data centres usually goes over the the public network
      • Which maybe less reliable in a local network data centre
    • ❌ Single leader configuration is very sensitive to problems in this inter data centre link set up
      • As write are made synchronously over this link
  • Multi-leader configurationwith asynchronous network?
    • ✅ Can usually tolerate network problems better
    • ✅ A temporary network interruption does not prevent writes from being processed

How do I get my hands on multi leader configurations?

Some databases support multi leader replication by default.

⚠️ Before jumping in there is a disclaimer…

Although multi-leader replication has advantages it does have disadvantages…

  • 🤔 Issues to consider
    • The same data maybe concurrently modified in two different data centres
      • Thus those write conflicts must be resolved
    • As multi-leader replication is typically a retro fitted feature in many databases…
      • ❌ There are drawbacks in other database features!
        • These features can somewhat be problematic
          • Auto incrementing keys
          • Triggers
          • Integrity constraints

Footnote

For the reasons highlighted in the section above, multi-leader replication is actually considered dangerous, and should be avoided if at all possible. Although, I am not completely disregarding this, the multi-leader configuration set up is an important concept to understand as this is reused in other areas of an application where clients want offline operations… Stay tuned, as this will be covered in my next post.

📚 Further Reading & Related Topics

If you’re exploring multi-leader replication in distributed data-intensive systems, these related articles will provide deeper insights:

• Distributed Data-Intensive Systems: What Is a Conflict? – Learn how multi-leader replication can lead to conflicts and how those conflicts are managed to ensure data consistency in distributed systems.

• Distributed Data-Intensive Systems: Reading and Writing Quorums – Explore how quorum-based replication strategies work alongside multi-leader replication to maintain consistency and availability in distributed systems.

7 responses to “What is Multi-Leader Replication?”

  1. Distributed Data Intensive Systems: Clients with Offline Operation – Scalable Human Avatar

    […] handling offline operations between devices, the Multi-Leader Replication architecture is suitable to achieve […]

    Like

  2. Distributed Data Intensive Systems: Collaborative Editing – Scalable Human Avatar

    […] is also brings all the challenges of multi-leader replication… including conflict […]

    Like

  3. Distributed Data Intensive Systems: Resolving Write Conflicts – Scalable Human Avatar

    […] of the largest problems with multi-leader replication is handling conflicts. This is why conflict resolution is […]

    Like

  4. Distributed Data Intensive Systems: Multi-Data Centre Operations – Scalable Human Avatar
  5. What is Replication? – Scalable Human Avatar

    […] Multi-leader replication […]

    Like

Leave a comment

I’m Sean

Welcome to the Scalable Human blog. Just a software engineer writing about algo trading, AI, and books. I learn in public, use AI tools extensively, and share what works. Educational purposes only – not financial advice.

Let’s connect