Skip to main content

Question 45 of 50

What are Leader and Follower?

Mid-levelSenior

Question

"What are Leader and Follower in the context of a Partition?"

What the interviewer wants to assess

Fundamental replication knowledge — usually the entry point for questions about failover and ISR.

Resposta rápida

A partition's leader is the broker that serves all of its reads and writes — producers and consumers only interact with the leader. The follower continuously replicates the leader's data, without serving clients directly, staying ready to take over as the new leader if the current one fails.

Resposta nível Sênior

Every partition has exactly one leader and zero or more followers, depending on the configured replication factor — never two replicas of the same partition on the same broker, which would defeat the protection against losing that broker. Not every follower is necessarily ready to become leader at any given moment: only the ones in the ISR (In-Sync Replicas) — replicas sufficiently caught up with confirmed data — are eligible. A lagging follower (due to a slow network, for example) is removed from the ISR until it catches up again, preventing an outdated replica from taking over and "forgetting" messages already confirmed to producers.

In-depth explanation

See "Leader and Follower" and "ISR" in Chapter 5.

Exemplo financeiro

On the cartao.transacoes topic, each partition has a leader responsible for serving the autorizacao-service (producer) and the antifraude-service (consumer), while the followers replicate passively, ready to take over if the leader broker fails.

"Followers also respond to read requests, to balance load"

In Kafka's default configuration, only the leader serves client reads and writes. Followers exist exclusively for replication and failover — it's not a distributed-read mechanism like in some databases.

Pode vir a seguir

Likely follow-ups: "what happens when the Leader goes down?" and "what is ISR?".