Bitpath

Lesson 1 · Unit 02

One leader

Writes to one node, copies on the rest

12 exercisesabout 3 min

What you practise

  • Writes go to the leader and stream to followers, sync vs async replication, replication lag and reading your own writes, failover and split brain

Try a question from this lesson

Pick one

To survive a crash you keep two copies of a database, and both accept writes. Ana sets price = 10 on copy 1 while Bo sets price = 12 on copy 2. What is the problem?

The ideas

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

One leader, many followers

All writes go to one node, the leader. It records each write in a log and streams the log to the followers, which apply the same writes in the same order.

Reads can go to any node, so followers also spread the read load. If the leader dies, a follower is promoted.

           writes
client ----------> [ leader ]
                    |      |
                log v      v log
           [follower]  [follower]

client <---- reads from any node

Concept

Failover and split brain

Followers watch for the leader's heartbeat. If it stops for long enough, one follower is promoted and clients are pointed at it. That is failover.

But silence is not proof of death. If the old leader was only slow or cut off, it may come back still believing it leads. Two leaders taking writes is called split brain.

9 more exercises in the app

  • 1× order the lines
  • 4× multiple choice
  • 1× true or false
  • 2× type the answer
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy