Monedula

Scenario 09.1.1 · AutoMQ: the write path

AutoMQ diskless Kafka: one S3 WAL per broker, then ack

Diskless · Advanced · about 3 min · Apache Kafka 4.4 · AutoMQ 1.7.4

AutoMQ 1.7.4 · each partition has one leader and one replica; a broker writes one S3 WAL object for all its partitions, acks=all waits for that upload, and seconds later the WAL becomes an SSO.

Run this scenario in the playground

Seconds later the WAL becomes an SSO in the controller. t+6.000s

Seconds after the confirm (4 s here, the simulator's shortened figure) broker-1 turned its confirmed WAL object into an SSO and committed it to the controller. The WAL object is trimmed.

Open at this step: step 6, Seconds later the WAL becomes an SSO in the controller

What you start with

AutoMQ 1.7.4 is a fork of Apache Kafka 3.9.1 that keeps every topic in S3. Each partition has one leader, chosen by the KRaft controller, and a replication factor of 1. A broker writes one WAL object in S3 for all the partitions it leads: acks=all is answered when that upload finishes, acks=1 as soon as the record is appended in memory. Producer p-all sends acks=all, p-one sends acks=1, both to partitions broker-1 leads; consumer g1 sits in another zone. Timings are slowed so each phase gets its own frame.

Step by step

  1. AutoMQ cluster: one leader per partition, one WAL per broker t+0.000s orders is an AutoMQ topic (AutoMQ 1.7.4, a fork of Apache Kafka 3.9.1): 6 partitions, one replica each, every byte in S3. The KRaft controller chose one leader per partition, two on each broker, and each broker will write one WAL object for all the partitions it leads. Producer p-all sends acks=all, p-one acks=1; consumer group g1 has one member in az-b. Open at this step: step 1, AutoMQ cluster: one leader per partition, one WAL per broker
  2. The leader assigns offsets; acks=1 is answered at once t+0.200s The leader of each partition numbered its record at append. p-one (acks=1) was answered right there, before anything reached S3, and its record is not readable yet. p-all (acks=all) is still waiting: it is answered only when the upload finishes. Open at this step: step 2, The leader assigns offsets; acks=1 is answered at once
  3. One WAL object mixes two partitions and uploads to S3 t+0.700s The buffer of broker-1 closed after the 500 ms batch interval (the simulator's figure) and is uploading as one WAL object that holds the records of both partitions it leads, one from each producer. The upload takes 600 ms in the simulator. Open at this step: step 3, One WAL object mixes two partitions and uploads to S3
  4. Upload done: acks=all answered, nothing written to the controller t+1.300s The upload finished and the WAL object is confirmed: the high watermark rose and p-all was answered. Nothing was written to the KRaft controller for this ack. The SSO has not been committed yet. Open at this step: step 4, Upload done: acks=all answered, nothing written to the controller
  5. The consumer reads the records only now t+2.500s g1 in az-b fetched both records from broker-1 in az-a, a cross-zone fetch. The acks=1 record, answered long before, was not readable until the upload was confirmed. Open at this step: step 5, The consumer reads the records only now
  6. Seconds later the WAL becomes an SSO in the controller t+6.000s Seconds after the confirm (4 s here, the simulator's shortened figure) broker-1 turned its confirmed WAL object into an SSO and committed it to the controller. The WAL object is trimmed. Open at this step: step 6, Seconds later the WAL becomes an SSO in the controller

The takeaway

The leader numbered both records at append, and acks=1 was answered there, before anything reached S3; its record could not be read until the upload was confirmed. One WAL object held the records of two partitions, and acks=all was answered when its upload finished, with no write to the controller. Only seconds later did the broker turn the confirmed WAL object into an SSO, commit it to the controller and trim the WAL object. Consumer g1 in az-b read from the az-a leader, which counts as cross-zone traffic. Simulator choices: the 500 ms batch interval (AutoMQ's code closes the buffer after 250 ms), the 600 ms upload and the 4 s SSO interval are the simulator's (AutoMQ's sources give no upload time, and its code default for the SSO interval is 60 s).

Configs in this scenario

  • acks How many replicas must have a write before the producer counts it as sent: 0 (none), 1 (the leader only) or all (every in-sync replica, the default, and required for idempotence). How acks works

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=09.1.1" title="Kafka Simulator: AutoMQ: the write path" 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/automq-write-path/">AutoMQ diskless Kafka: one S3 WAL per broker, then ack</a></p>

Further reading

AutoMQ v1.7.4 source on GitHub

More in Diskless

All scenarios