---
title: "WarpStream Kafka: a leader per client, a cache per zone"
description: "WarpStream (Agent v857): service discovery gives each client an Agent in its own zone as leader; a client with no ws_az gets any Agent, in any zone."
url: https://monedula.dev/kafka-simulator/scenarios/warpstream-zones-leader-per-client/
---

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

Scenario 10.1.2 · WarpStream: zones and a leader per client. 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 it: https://monedula.dev/kafka-simulator/playground/?scenario=10.1.2

## 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](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.2&t=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](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.2&t=1)
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](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.2&t=2)
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](https://monedula.dev/kafka-simulator/playground/?scenario=10.1.2&t=3)

## 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`](https://kafka.apache.org/44/configuration/producer-configs/#producerconfigs_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.

## Further reading

- [WarpStream documentation](https://docs.warpstream.com/warpstream/overview/architecture/service-discovery)
