August 13, 2020

Distributed Consensus and Data Replication strategies on the server

We talk about the Master Slave replication strategy for reliability and data backups. This database concept is often asked in system design interviews with discussions on consistency and availability tradeoffs.

Very closely tied to the master slave architecture is the concept of distributed consensus. When designing a system, we must make sure that the individual components can agree on a particular value. (Leader election, distributed transactions, etc…) Some popular techniques are 2 phase commit, Multi Version Concurrency Control, SAGAs and Quorum.

0:00 Problem Statement
0:53 Replication
1:24 Synchronous replication vs. Asynchronous replication
3:36 Peer to Peer data transfer
4:44 Split brain problem

Also useful when used with Master Slave replication is sharding. You can check out the video mentioned below.


Made by engineers from Google and Uber, this site helps you build your algorithmic skills using code and white board explanations.
Be sure to use the code ‘gaurav’ for the discount. You get 15% off!

System Design Course:

System Design Playlist:
Designing Data Intensive Applications –

You can follow me on:

#SystemDesign #Databases #Replication


Xem thêm bài viết khác:

in Game
Related Posts

Peregrino – Wings | A YOUNGER MAN'S GAME Live Session

July 26, 2020

July 26, 2020

Peregrino is a Folk Music/Americana band formed in 2014 in Mexico City (by way of Oklahoma). Due to the roots...

Super BinGo 2 – Android Gameplay – World 81-90 – Part8

July 25, 2020

July 25, 2020

Super BinGo 2 – Android Gameplay – World 81-90 – Part8 Playlist: For more Android Gameplay, Sub to my Channel:...

Mummified Child Sacrifice | National Geographic

July 22, 2020

July 22, 2020 23

Working under a tight deadline, scientists extract samples that will help describe their young mummy’s life. ➡ Subscribe: #NationalGeographic #Mummies...

I Finally Won The Impossible Ring Toss Carnival Game!

July 26, 2020

July 26, 2020 44

I play this new carnival ring toss game that’s much harder than one’s I’ve played here before! I FINALLY win...

1. Evolution of Sex and Reproductive Strategies

July 23, 2020

July 23, 2020

Global Problems of Population Growth (MCDB 150) Reproduction is not simple or easy, nor is it fair. Females often bear...

Juice WRLD Eats Spicy Wings LIVE | Hot Ones

July 25, 2020

July 25, 2020 21

Juice WRLD joined Sean Evans LIVE at ComplexCon Chicago this past weekend, just hours before shutting down the Pigeons &...


July 21, 2020

July 21, 2020


Funny Table Game-Wooden Mini Desktop Parent-child Fun Bowling Game Toy Set

July 20, 2020

July 20, 2020 2

Indoor Wooden Mini Desktop Fun Bowling Developmental Parent-Child Interact Toy Set Product link: More choice: General Form Color Brown Material...

100 Sega Genesis / Mega Drive Games (Taken From an Original Genesis)

July 20, 2020

July 20, 2020 20

This is a vid of 100 Sega Genesis games as played on an original Sega Genesis, and recorded with a...

Nạp 8Tr5 ATM Chơi BINGO Thanh Niên May Mắn : Lấy Hoopa Đầu Tiên Server – Cuối Năm Triệu Hồi Hoopa

July 18, 2020

July 18, 2020 20

Cám Ơn Các Bạn Đã Xem Video – Clip – Của Mình….. – Facebook Miu Lì Ham Chơi : –...

McDonalds Math Problem – Only For Genius

July 17, 2020

July 17, 2020 25

This video shows the solution to the mcdonalds riddle that can be found all over the internet. drink + drink...

Hope Is Reborn | Xena: Warrior Princess

July 20, 2020

July 20, 2020 32

Despite Xena’s efforts, Ares and Callisto manage to revive Hope. Season 3, Episode 21 ‘Sacrifice I’. This is the official...

How to build a beanbag toss game

July 25, 2020

July 25, 2020

Download the free plans at Build an indoor/outdoor beanbag toss game with your child using basic tools and materials available...


July 27, 2020

July 27, 2020

THE ONE AND ONLY “ORIGINAL FASTFOODTOYREVIEWS!” The Lego Movie 2: The Second Part is a 2019 computer-animated science fiction comedy...

SQUAD Alpha – Render Test [60FPS – 4K downscaled]

July 26, 2020

July 26, 2020 9

Recently I updated my recording software for Squad to Dxtory with UtVideo YUV422 BT.709 codec, which allows a nearly loseless...

  • Hey man, awesome Videos on important topics! Actually, I haven't come across any other good source on Systems Design.

    Can you recommend some literature or a crash course on Systems Design? Or maybe you can make a whole course, going from topic to topic in a structured manner, more like how the topics are structured in a book, so that it can serve as a starter basic overview on the whole field.
    Cheers 😉

  • In many Amazon interviews, they usually ask Command execution framework design and play store design. Can i have material for that?

  • If there is single database, my application is scaling up in terms of user then the load balancer will not help, all the load will be in single database, for that how to serve fast in terms of user experience(read/write), how to scale or design the database??? i m seeking help for sql server

  • 06:00 The balance deduction thing, the 2 messages deduction 100 and deduction 50 are different messages right ? so what's wrong with deducting 150 ? I think I am missing a key point.

  • Hi Gaurav.
    I have been going through your blogs for a while now and they helped me ace my WalmartLabs interview where i started a couple of months back.
    Litlle context on the practical application of this video, this is a very common problem in distributed systems where solution to the problem through only sharding is prettymuch rare as data is expected to be available anywhere and everywhere.
    I have been using Microsoft's offering of AZURE COSMOS DB which is a planet scale document based db solution where you get triggers or events when the state of your data changes so that it can be asynchronously communicated to other nodes/clusters. So, AZURE COSMOS DB offer's the option of multiple master for writes which asynchronously sync with each other and in case if a conflict there are 2 options _ the last write wins / you can execute a stored proc for some custom logic. So all of this is very relevant.

  • Great content (upvoted and subbed). Don't see any other channel with short and precise summaries of fairly complicated concepts.

    One more benefit of Master-Slave – Move replicated data closer (geographically) to the end user. For better user experience – lower latency.
    Also sharding and replication scheme are tangential and often work in tandem. Generally you will have sharded databases with each shard replicated. Replicated shard could be a slave or a master (consensus based).

    I vote for distributed consensus. In fact this would cover the meat of distributed systems and could be broken down into multiple smaller introductory videos
    Video 1> Inherent problems with distributed systems (failure detection, n/w partitions, byzantine(non) faults, clock skews).
    Video 2> Why do we need consensus ? Protocols to tackle #1 and what they tradeoff to offer consensus (CAP axis). Protocols – 2pc, 3pc, paxos (intro).
    Video 3> Real applications and tradeoff they make for better performances. (Why distributed acid applications are hard and to be avoided).

    I see lot of interviewees(i'm interviewer in one of the FANG) have surface knowledge of these concepts and often incorrectly adjust to a constraint (been guilty myself). Content like yours can help someone find gaps in their understanding.

  • Hi Gaurav, awesome video.
    Do you happen to know which system design is probably used in the scenario when you run out of locks during distributed consensus pretty fast. Something like rate limiting for acquiring locks ?

  • If our system has 'n' replicas, which replica amongst those 'n' stand chance to be master? What is the criteria for selecting one single replica amongst pool of replicas?

  • Excellent video as always gaurav.
    A few points from my side.
    1. Taking snapshots at regular intervals of the db is one way to avoid the single point of failure.
    2. Log reconstruction is one more way. Before writing to the db first flush to a log file. So if the db crashes the log file can be used to restore the db.
    3. I think when you talk about the databases communicating with each other , you mean there is an API that sits in front of them and these API's communicate with each other.
    Or is it that there is an API in front of the db which writes to a queue and another process that polls the queue and talks to the second db.
    4. One way to deal with the split brain problem is through the paxos algorithm.

    Great job and thanks !!! 🙂

  • Why don't you make a technical meme page. Where we get knowledge with laughter. haha 😛
    Amazing video and amazing memes in between 😛

  • Hi Gaurav,
    Nice video. I have some elementary doubts.
    1) how communication between two DB could get broken which results in Split brain problem. My guess is they communicate on particular port. Closing of port is only way to cause this issue.

    2) how master master architecture is achieved in DB. Bcz server would be configured to sent data to particular DB say DB1, howcome data could be dynamically sent to DB2. As much I know there is no load balancer behind DB set up.

    Thanks lot.

  • hey can you slow down your speed a bit. looks like its 1.3x instead of 1.0x. i know you get excited but if you can tone down your speed people can follow a bit better.

  • Hey, another great video. But i have some doubts regarding how states are maintained. Say there are 3 nodes(A,B,C), each at state S0. Link between A and B is broken. A gets an update and propogates it to C and now both of them are on state S2. Now if C gets an update and tries to propogate it to B, B will take note the C's state is not the same as its own. So….how will it be decides who is ahead and who is behind? According to your example, B will just tell C to rollback and force its own state onto C which is not right. So how will this work?

  • Hello Gaurav. Just want to ask what is your view on data science in industry field? Are you planning to switch to data science field in the near future?

  • HI! i love your competitive programming videos. do u think you can make a serie of fendwick tree (some applications of it in problems, not the theory). i think it is hard to conceptualize a problem and using fendwick tree to solve it, so it would be really helpful.

  • Hi Gaurav , this was very helpful video to understand master slave architecture , I have few queries like what if load balancer itself goes down , how master and slave notify each other I mean what mechanism they will use so that both with will be in synch? I am facing one problem with load balancer I have posted the question in stackoverflow
    could you please suggest me here what I am doing worng ?

  • Nice work Gaurav! This is the only channel for which I have enabled notifications. You are helping the whole community. Thanks a lot.
    PS: start an instagram page and post all these memes there also.😀

  • Your videos are great and you've done a great job in your explanations. You should do a video on book recommendations that aid people on learning about systems design thinking in this way.

  • Hi Gaurav, good video. Can you make a video over "how large scale Indian Unified Payment Interface works"? Focus on technical/Networking and Database aspects. Thanks !!!

Leave a Reply

Your email address will not be published. Required fields are marked *