---
title: "Ursa for Kafka compaction: from WAL objects to Parquet"
description: "Ursa for Kafka: the compaction service rewrites WAL objects as Parquet, one Oxia commit repoints the offset index, and a lagging consumer reads the files."
url: https://monedula.dev/kafka-simulator/scenarios/ursa-wal-to-parquet/
---

# Ursa for Kafka compaction: from WAL objects to Parquet

Scenario 13.1.3 · Ursa for Kafka: from WAL to Parquet. Diskless · Advanced · about 4 min · Apache Kafka 4.4 · StreamNative Ursa for Kafka.

StreamNative Ursa for Kafka · the compaction service rewrites WAL objects as Parquet files, one Oxia commit repoints the offset index at them and the WAL objects are deleted; a lagging consumer reads the files, a tailing one read the owner's memory.

Run it: https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3

## What you start with

In Ursa for Kafka a diskless topic's records first land in WAL objects, each holding the batches of many partitions, and the offset index in Oxia maps every partition's offsets to the object that holds them. The compaction service, which runs outside the brokers, rewrites those WAL objects as Parquet files, repoints the index at the files and, once they are verified, deletes the WAL objects. Here producer p-b writes six records through broker-2, its zonal owner in az-b, three into each of two WAL objects. Consumer group g-tail, also in az-b, reads from the start; group g-late joins in az-c after the first compaction run, with auto.offset.reset=earliest. The timings are slowed so each phase gets its own frame (a simulator choice).

## Step by step

1. **WAL objects pile up; the offset index points at them** (t+2.400s): Producer p-b (client.id: zone_id=az-b) sent three records at 100 and three more at 800, one to each partition of orders each time. broker-2, its zonal owner in az-b, put each three into one WAL object: Oxia committed wal-0001 at 1450 and wal-0002 at 2150. The offset index now maps offset 0 of every partition to wal-0001 and offset 1 to wal-0002, so one WAL object holds pieces of three partitions and each partition is spread over two objects. Consumer group g-tail (zone_id=az-b) has read all six records as they were committed, at 1800 and 2400, from broker-2's memory (frame 5). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3&t=0)
2. **The compaction service writes one Parquet file per partition; one Oxia commit repoints the index** (t+4.250s): The compaction service, which runs outside the brokers, started a run at 3450, 2 s after the first Oxia commit. It took both committed WAL objects and wrote one Parquet file per partition, each with that partition's records from both objects: pq-0001 for orders-0, pq-0002 for orders-1 and pq-0003 for orders-2, offsets 0-1 each. Until now the index pointed at the WAL objects. At 4250 the upload and one Oxia commit land together, and the commit repoints the offset index of all three partitions at the files: offsets 0-1 of orders-0 now map to pq-0001, those of orders-1 to pq-0002 and those of orders-2 to pq-0003. The offsets do not change, only the file behind them. The 2 s interval, one file per partition per run and the upload and commit landing together are the simulator's choices. The WAL objects leave the bucket in the same step (next frame). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3&t=1)
3. **The WAL objects are deleted** (t+4.400s): With every range of wal-0001 and wal-0002 now pointing at a Parquet file, the run deleted both WAL objects at 4250, and they left broker-2's memory: the bucket holds only the three Parquet files, and the canvas marks the two objects as compacted for one second. Ursa deletes the WAL objects once the files are verified; the simulator deletes them in the same step as the commit. Consumer group g-late joins now in az-c (zone_id=az-c) with auto.offset.reset=earliest, so it starts at offset 0, which is only in Parquet now. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3&t=2)
4. **A lagging consumer reads the Parquet file, converted back to records** (t+5.000s): g-late's first poll goes to broker-3, its zonal owner in az-c. The index maps offset 0 of orders-0 to pq-0001, so broker-3 fetches the Parquet file from object storage (one GET) and converts it back to records: order-1 at offset 0, the record broker-2 first wrote to wal-0001. The first offset of a fetch decides where it is served from, and g-late, joining behind, reads one record per poll (simulator choices). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3&t=3)
5. **A tailing consumer reads the owner's memory; both see the same records** (t+8.600s): g-late read the rest one per poll, each through broker-3 from a Parquet file with its own GET: six GETs, two per file, since Parquet reads are not cached (a simulator choice). It committed offset 2 on every partition at 8600. g-tail read the same six records at 1800 and 2400, before the run, from broker-2's memory: broker-2 is its zonal owner in az-b and wrote both WAL objects, so the tail was still in its write buffer and needed no object storage read. Both groups read order-1 to order-6 at the same offsets: the tier changed, the records did not. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=13.1.3&t=4)

## The takeaway

broker-2 wrote two WAL objects, wal-0001 and wal-0002, each with one record of every partition, and the offset index pointed offsets 0 and 1 of each partition at them. 2 s after the first Oxia commit the compaction service ran: it wrote one Parquet file per partition, pq-0001 to pq-0003, each holding offsets 0-1 of its partition from both objects, and one Oxia commit repointed the index at the three files. The two WAL objects were then deleted, and left broker-2's memory. g-late, which joined after the run, read every record from the Parquet files, converted back to records, with one GET per read. g-tail had read the same six records from broker-2's memory before the run, so both groups read order-1 to order-6 at the same offsets. Ursa facts: the compaction service rewrites WAL objects as Parquet files and deletes them once the files are verified; the offset index maps offsets to the WAL object or Parquet file that holds them; the owner that wrote the tail serves it from memory. Simulator choices: the service runs every 2 s, writes one Parquet file per partition per run, lands its upload and its Oxia commit together and deletes the WAL objects in the same step as that commit; the first offset of a fetch decides where it is served from; Parquet reads are not cached, so each one is a GET; a group that joins behind reads one record per poll; and the 500 ms buffer close, the 600 ms upload and the 200 ms Oxia commit are slowed. StreamNative's lakehouse tables are a separate feature the simulator does not draw: Stream Delivered Tables, which have shipped, write a separate copy of the data to a lakehouse table, while zero-copy Stream Backed Tables are marked "Coming Soon" in its docs.

## Configs in this scenario

- [`auto.offset.reset`](https://kafka.apache.org/44/configuration/consumer-configs/#consumerconfigs_auto.offset.reset): Where a consumer starts when its group has no committed offset or the offset no longer exists: latest (the default), earliest, by_duration (a time back from now, such as by_duration:PT1H), or none to throw an exception instead. [How auto.offset.reset works](https://monedula.dev/kafka/configs/auto-offset-reset/)
- [`client.id`](https://docs.streamnative.io/cloud/build/kafka-clients/config/config-kafka-client): On Ursa for Kafka a client asks for zone affinity by starting its client.id with zone_id= and its zone (zone_id=az-a, or zone_id=az-a,key1=value1 with other entries after it), and at least one broker must run in that zone.

## Further reading

- [StreamNative blog](https://streamnative.io/blog/ursa-for-kafka-deep-dive-write-path-read-path-and-data-compaction)
