Monedula

Scenario 11.1.4 · Redpanda: from L0 to L1, and who serves a read

Redpanda Kafka L0 to L1: the LRO and who serves a read

Diskless · Advanced · about 4 min · Apache Kafka 4.4 · Redpanda

Redpanda v26.2.2 Cloud Topics · the reconciler moves L0 records into an L1 object and advances the LRO through Raft; a fetch at or below the LRO reads L1, a newer one the leader's batch cache, and a follower in the consumer's zone downloads the whole L0 object once.

Run this scenario in the playground

A consumer in another zone reads its zone's follower. t+6.400s

g-zone runs in az-c with client.rack=az-c, and the cluster sets enable_rack_awareness=true, so its fetches go to broker-3, the follower in az-c, not to the leader in az-b. It joined at 4000 ms at the end of the log, offset 2. broker-3 learned the high watermark 3 at 5850 ms, one replica fetch after the leader, so the poll at 5800 ms read nothing. At 6400 ms broker-3 serves orders-1 offset 2. It holds the placeholder, not the record, and a follower gets no batch cache fill, so it downloads the whole L0 object l0-0003 from S3 into its disk cache and serves order-5 from it. The read stays in az-c: the cross-zone card counts no consumer hop.

Open at this step: step 4, A consumer in another zone reads its zone's follower

What you start with

Redpanda Cloud Topics write every record first to an L0 object, which mixes the partitions one broker leads. On each partition leader a reconciler reads from the last reconciled offset (LRO) + 1 to the last stable offset, writes those records to an L1 object, registers it in the L1 metastore, and writes the new LRO into each partition's Raft log. A fetch at or below the LRO reads L1; a newer one reads L0: from the leader's batch cache, filled when the placeholder was appended, or by downloading the whole L0 object into the broker's disk cache. Producer p1 (az-a) writes to orders-1 and orders-4, both led by broker-2 in az-b. g-tail (az-b) reads from the start; g-lag (az-b) joins later at the earliest offset; g-zone runs in az-c and sets client.rack=az-c, and the cluster sets enable_rack_awareness=true, so g-zone reads from broker-3, the follower in its zone. On classic Kafka that follower would hold the records it serves (scenario 02.1.5); here it holds only placeholders. Timings are slowed so each phase gets its own frame.

Step by step

  1. Records sit in L0 objects; the LRO is behind t+3.200s p1 (az-a) sent order-1 and order-2 at 100 ms and order-3 and order-4 at 1300 ms, to orders-1 and orders-4, both led by broker-2 in az-b. Each pair went into one L0 object holding both partitions, l0-0001 and then l0-0002; their placeholders took offsets 0 and 1, and once they reached the followers the high watermark moved to 2. g-tail (az-b) read each pair from broker-2's batch cache, at 1800 and 3000 ms. Nothing is reconciled yet: neither partition has an LRO, so every offset is served from L0. broker-2's first reconciler run is due at 3250 ms, 2 s after its first placeholder. Open at this step: step 1, Records sit in L0 objects; the LRO is behind
  2. The reconciler writes an L1 object and the LRO advances through Raft t+3.890s At 3250 ms broker-2's reconciler read offsets 0-1 of orders-1 and orders-4, from the LRO + 1 to the last stable offset, and uploaded them as one L1 object, l1-0001, which carries both partitions. At 3890 ms l1-0001 is registered in the L1 metastore, and the new LRO, 1, is written into the Raft log of each partition, a Raft write counted like a placeholder: the cross-zone card counts 4 more metadata hops, one per follower per partition. The simulator applies the new LRO in this tick, without timing a replication round. Offsets 0 and 1 are now read from L1. l0-0001 and l0-0002 stay in S3; garbage collection deletes an L0 object only after 12 h, not in this scene. Open at this step: step 2, The reconciler writes an L1 object and the LRO advances through Raft
  3. A lagging consumer reads L1; a tailing one reads the leader's cache t+6.000s g-lag (az-b) joined at 4000 ms at the earliest offset. Its first fetch, orders-1 offset 0 at 4600 ms, is at or below the LRO, so broker-2 read L1 object l1-0001 from S3 into its disk cache; offset 1 at 5200 ms came from that disk cache, with no GET. order-5 and order-6, sent at 4100 ms, went into L0 object l0-0003 and were placed at offset 2 at 5250 ms, above the LRO: g-lag read orders-1 offset 2 at 5800 ms from broker-2's batch cache, and g-tail read both records at 6000 ms from the same cache. g-lag catches up one record per poll and still has orders-4 to read. Open at this step: step 3, A lagging consumer reads L1; a tailing one reads the leader's cache
  4. A consumer in another zone reads its zone's follower t+6.400s g-zone runs in az-c with client.rack=az-c, and the cluster sets enable_rack_awareness=true, so its fetches go to broker-3, the follower in az-c, not to the leader in az-b. It joined at 4000 ms at the end of the log, offset 2. broker-3 learned the high watermark 3 at 5850 ms, one replica fetch after the leader, so the poll at 5800 ms read nothing. At 6400 ms broker-3 serves orders-1 offset 2. It holds the placeholder, not the record, and a follower gets no batch cache fill, so it downloads the whole L0 object l0-0003 from S3 into its disk cache and serves order-5 from it. The read stays in az-c: the cross-zone card counts no consumer hop. Open at this step: step 4, A consumer in another zone reads its zone's follower
  5. That follower downloads the whole L0 object once t+7.000s g-zone reads one record per poll (max.poll.records=1), and in the simulator a poll is one fetch, so it fetches one partition at a time; a real consumer would fetch both partitions in one request and buffer the second record, and Redpanda merges concurrent reads of one object into one GET. At 7000 ms it reads order-6 at orders-4 offset 2, which sits in the same L0 object, and broker-3 serves it from its disk cache: no second GET. One download of l0-0003 served both partitions. With enable_rack_awareness off, g-zone would have read both records from broker-2 in az-b, two cross-zone reads. g-lag reads orders-4 on, from l1-0001 in broker-2's disk cache; broker-2's next reconciler run, at 7250 ms, moves offset 2 to L1 after this frame. Open at this step: step 5, That follower downloads the whole L0 object once

The takeaway

broker-2's reconciler moved offsets 0-1 of orders-1 and orders-4 out of two L0 objects into one L1 object, registered it in the L1 metastore, and wrote the new LRO, 1, into each partition's Raft log, a Raft write counted like a placeholder. Which tier served a fetch followed from its offset: g-lag's first read, offset 0, was at or below the LRO and came from the L1 object in S3, while offset 2, above it, came from broker-2's batch cache, as every read of the tailing g-tail did. g-zone read from broker-3 in its own zone, so none of its reads crossed a zone. A follower gets no batch cache fill from the write path, so broker-3's first read of L0 object l0-0003 downloaded the whole object into its disk cache, and the next read of that object, for the other partition, was served from there: one GET for both. Redpanda v26.2.2 facts: the reconciler runs on each partition leader, writes multi-partition L1 objects and replicates the LRO through Raft; reads at or below the LRO go to L1, the rest to L0; a follower serves fetches, bounded by the leader's high watermark, when enable_rack_awareness is on (it is off by default) and the consumer sends client.rack; a cache miss downloads the whole L0 object; and an L0 object is deleted only once it is reconciled and at least 12 h old, so l0-0001 and l0-0002, and the unreconciled l0-0003, are still in S3 at the end. Simulator choices: the reconciler runs every 2 s (Redpanda adapts the interval between 250 ms and 10 s); the new LRO takes effect in the tick the L1 object is registered, and its Raft write is counted as metadata hops, not timed as a replication round; enable_rack_awareness switches follower fetching only, and each partition's replicas are placed over the three zones whether it is on or off (Redpanda also uses it to spread replicas over racks); the tier is decided by a fetch's first offset; an L1 object read once stays in the broker's disk cache; a follower learns the high watermark on its next replica fetch; a poll is one fetch, so g-zone's max.poll.records=1 also makes it fetch one partition at a time, where a real consumer fetches both partitions in one request and buffers the second record (Redpanda merges concurrent reads of one object, so that is still one GET); g-lag catches up one record per poll; and the buffer interval, the upload and the L1 registration are slowed to 500 ms, 600 ms and 40 ms.

Configs in this scenario

  • client.rack The consumer's rack ID; with enable_rack_awareness=true on the Redpanda cluster and a rack set on each broker, the partition leader looks for a replica, itself or a follower, whose rack ID matches the consumer's and returns records from that replica, and otherwise handles the fetch itself.
  • enable_rack_awareness A Redpanda cluster property that enables rack-aware replica assignment (default false); follower fetching also needs it set to true, with a rack on each broker and client.rack on each consumer.
  • max.poll.records The most records one poll() returns (default 500); a smaller value shortens the processing between two polls, which keeps a group member inside max.poll.interval.ms.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=11.1.4" title="Kafka Simulator: Redpanda: from L0 to L1, and who serves a read" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/redpanda-l0-to-l1-read-tiers/">Redpanda Kafka L0 to L1: the LRO and who serves a read</a></p>

Further reading

Redpanda v26.2.2 source on GitHub

More in Diskless

All scenarios