Monedula

Scenario 10.1.2 · WarpStream: zones and a leader per client

WarpStream Kafka: a leader per client, a cache per zone

Diskless · Advanced · about 3 min · Apache Kafka 4.4 · WarpStream (Agent v857)

WarpStream (Agent v857) · service discovery names a leader for each client: an Agent in its zone when client.id sets ws_az, any Agent when it does not; each zone loads a file into its cache once.

Run this scenario in the playground

A client with no zone lands on an Agent in any zone. t+0.450s

p-x sets no ws_az, so discovery may name any Agent. For orders-0 it names agent-3 in az-c: a third leader for the same partition, and p-x's record waits in agent-3's buffer. Nothing tells the Agents which zone p-x runs in; unless it is az-c, each of its requests crosses zones, the traffic ws_az is there to avoid. The cross-AZ counter counts no request of a client with no zone: the simulator does not know where it runs, so it stays at 0.

Open at this step: step 3, A client with no zone lands on an Agent in any zone

What you start with

A WarpStream partition has no leader of its own: any Agent can serve it. Service discovery answers each client's Metadata request with an Agent in the zone named by ws_az in its client.id, and with any Agent when the client names no zone, so two clients can see two leaders for one partition. Three Agents run here, one per zone. Producer p-a sits in az-a, p-b in az-b, and p-x sets no zone; all three write partition 0 of orders. Consumer groups g-a, g-b and g-c read orders, one in each zone. Timings are slowed so each phase gets its own frame.

Step by step

  1. Three clients ask for the leader of orders-0 t+0.000s orders is a WarpStream topic (Agent v857): 3 partitions, every record in object storage, and no leader of its own: any Agent can serve any partition. One Agent runs in each zone: agent-1 in az-a, agent-2 in az-b, agent-3 in az-c. Producer p-a sets ws_az=az-a in its client.id, p-b sets ws_az=az-b, and p-x sets no zone. All three are about to write orders-0, so each first asks service discovery for its leader. Consumer groups g-a, g-b and g-c read orders, one in each zone. Open at this step: step 1, Three clients ask for the leader of orders-0
  2. Each gets the Agent in its own zone t+0.300s Discovery answers each Metadata request with an Agent in the client's zone: the leader of orders-0 is agent-1 for p-a and agent-2 for p-b. Two clients, two leaders for one partition. Each record now sits in the buffer of the Agent in its producer's zone, so neither request left its zone. Open at this step: step 2, Each gets the Agent in its own zone
  3. A client with no zone lands on an Agent in any zone t+0.450s p-x sets no ws_az, so discovery may name any Agent. For orders-0 it names agent-3 in az-c: a third leader for the same partition, and p-x's record waits in agent-3's buffer. Nothing tells the Agents which zone p-x runs in; unless it is az-c, each of its requests crosses zones, the traffic ws_az is there to avoid. The cross-AZ counter counts no request of a client with no zone: the simulator does not know where it runs, so it stays at 0. Open at this step: step 3, A client with no zone lands on an Agent in any zone
  4. Each zone that reads a file loads it into its own cache t+1.800s The control plane committed the three files in turn, agent-1's, agent-2's, then agent-3's, so orders-0 holds p-a's record at offset 0, p-b's at 1 and p-x's at 2. Each group reads through the Agent in its zone, and each zone loads every file it reads from object storage into its own cache, once: three files in three zones, nine loads, so each file carries a mark for every zone. A later read in a zone is served from its cache. Open at this step: step 4, Each zone that reads a file loads it into its own cache

The takeaway

Three clients asked for the leader of orders-0 and got three different Agents: p-a got agent-1 in az-a and p-b got agent-2 in az-b, each the Agent in its own zone, so their requests stayed in their zones. p-x set no ws_az, so discovery could name any Agent; it got agent-3 in az-c, and unless p-x runs in az-c its requests cross zones. Each zone then loaded every file it read into its own cache, once: three files in three zones, nine loads. WarpStream facts: service discovery names an Agent in the client's zone when ws_az is set in client.id, and any Agent otherwise; each zone's cache loads a file once. Simulator choices: the client's zone is its rack, shown as ws_az; the Agent within a zone, or among all Agents for a client with no zone, is picked by a stable hash; the cross-AZ counter counts no request of a client with no zone, since the simulator does not know where it runs; and the 500 ms batchTimeout, 600 ms upload and 200 ms commit are slowed figures so each phase is a frame.

Configs in this scenario

  • client.id A logical name the producer sends with every request - it shows up in broker logs, metrics, and quota enforcement so traffic can be attributed to an application.

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=10.1.2" title="Kafka Simulator: WarpStream: zones and a leader per client" 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/warpstream-zones-leader-per-client/">WarpStream Kafka: a leader per client, a cache per zone</a></p>

Further reading

WarpStream documentation

More in Diskless

All scenarios