YugabyteDB

YugabyteDB Raft, tablet leadership, and CAP behavior.

YugabyteDB applies Raft per tablet so the database can combine strong consistency with horizontal scale.

Architecture

YugabyteDB does not use one global Raft log.

Tables are split into tablets. Each tablet is replicated by its own Raft group with one leader and followers. This lets many tablet leaders coordinate writes in parallel across the cluster.

Tablet Raft Groups

Every tablet has a replica set spread across nodes or zones. That tablet elects its own leader, maintains its own log, commits independently, and can be rebalanced separately.

Tablet ALeader: Node 1
Tablet BLeader: Node 2
Tablet CLeader: Node 3
Tablet DLeader: Node 1

Leader Distribution

Healthy deployments spread tablet leaders so one tserver does not absorb too much write coordination. Poor leader distribution causes hotspots, queue buildup, and CPU imbalance.

  • Too many leaders on one tserver can skew latency.
  • Leader rebalancing improves write distribution.
  • Placement awareness matters across zones and regions.
  • Monitor leader counts, follower lag, and tablet movement.

CAP Theory

How Raft supports YugabyteDB's consistency story.

CAP says that during a network partition, a distributed system must choose between availability and consistency for operations that require coordination. Raft-backed tablet groups choose consistency for writes: without quorum, the tablet will not safely commit new writes.

Consistency

Raft enforces one committed order of writes per tablet. A successful write is confirmed only after the tablet leader reaches majority replication.

Partition Behavior

If a tablet leader is isolated in a minority partition, it cannot commit. The majority side can elect a new leader and continue safely.

Availability Tradeoff

A tablet that loses quorum becomes unavailable for new writes until enough replicas return. This protects correctness over unsafe availability.

Production Scenarios

What YugabyteDB Raft issues look like operationally.

Leader-heavy node

If one tserver owns too many hot leaders, write coordination concentrates there. Expect high CPU, queueing, and uneven latency.

Frequent elections

Look for packet loss, disk stalls, overloaded RPC workers, CPU starvation, and aggressive timeout settings.

Follower catch-up

After outage, replicas catch up through log replay, snapshot, or remote-bootstrap style recovery depending on lag and log retention.

Zone outage

Tablet availability depends on whether each tablet's remaining replicas still form quorum, not just whether the overall cluster has many nodes alive.

YugabyteDB Interview Questions

How does YugabyteDB scale writes with Raft if Raft has a single leader?

By sharding into many tablets. Each tablet has its own leader, so the cluster has many leaders in parallel.

Why does leader balancing matter more than replica balancing?

Replica balancing spreads storage. Leader balancing spreads write coordination work.

How does CAP apply to a YugabyteDB tablet?

During a partition, a tablet needs quorum to preserve consistency. Without quorum it should reject or stall writes instead of risking divergence.

What metrics would you inspect during Raft trouble?

Leader changes, vote requests, replication latency, under-replicated tablets, follower lag, disk latency, and CPU saturation.

Tuning And Troubleshooting Areas

  • Heartbeat and election timing.
  • Tablet leader balancing and placement policy.
  • RPC pressure and consensus queue growth.
  • WAL fsync latency and compaction throughput.
  • Remote bootstrap and follower catch-up behavior.