Monedula

Scenario 13.1.2 · Ursa for Kafka: zones and the zonal owner

Ursa for Kafka zones: the zonal owner and the zone cache

Diskless · Advanced · about 3 min · Apache Kafka 4.4 · StreamNative Ursa for Kafka

StreamNative Ursa for Kafka · each zone has its own zonal owner for a partition, a client with zone_id talks only to its zone's owner, and each zone reads a WAL object through its own cache broker, once.

Run this scenario in the playground

Each zone that loads the object adds its mark. t+1.900s

g-a polled at 1800 and read both records from broker-1's memory: broker-1 is az-a's owner and wrote wal-0001, so az-a loaded nothing and adds no mark. g-c polled at 1900 through broker-3, az-c's owner and cache broker, which loaded wal-0001 into az-c's cache: a second GET, and the mark c. The object now carries a mark for each zone that read it through its cache broker: b and c.

Open at this step: step 4, Each zone that loads the object adds its mark

What you start with

In Ursa for Kafka a diskless partition has no single broker of its own. A client names its zone in client.id (zone_id=az-a), and its broker for a partition is that partition's zonal owner in its zone, so each zone has its own owner for the same partition. The owner that wrote a WAL object serves its tail from memory; in another zone the object is read through the zone's cache broker, which fetches it from object storage for that zone. Three brokers run here, one per zone. Producer p-a (az-a) writes two records to orders-0, and consumer groups g-a, g-b and g-c, one member each in az-a, az-b and az-c, read them; g-b and g-c join later. Producer p-x sets no zone_id. The timings are slowed so each phase gets its own frame (a simulator choice).

Step by step

  1. One partition, three zonal owners: one per zone t+0.000s Three brokers, one in each zone (az-a, az-b, az-c), and three KRaft controllers for the cluster metadata. orders has three partitions and ursa.storage.enable=true, so it is diskless and no partition has a single broker of its own: each has a zonal owner in every zone, the broker a client in that zone talks to. With one broker per zone, the zonal owners of orders-0 are broker-1 for az-a, broker-2 for az-b and broker-3 for az-c. Producer p-a sets client.id: zone_id=az-a, and producer p-x sets no zone_id. Consumer group g-a (zone_id=az-a) reads orders; g-b (az-b) and g-c (az-c) join later, one member each, reading from the earliest offset. Open at this step: step 1, One partition, three zonal owners: one per zone
  2. Each zone's clients talk only to their zone's owner t+1.450s p-a sent k10 and k13, which both hash to orders-0, to broker-1, its zonal owner in az-a. broker-1 uploaded them as one WAL object, wal-0001, Oxia committed it and assigned offsets 0 and 1, and p-a was acked: no request left az-a. g-b has joined in az-b and g-c in az-c, and each will fetch orders-0 from its own zone's owner, broker-2 and broker-3, so no fetch crosses a zone either. Open at this step: step 2, Each zone's clients talk only to their zone's owner
  3. A WAL object is read in az-b: the zone's cache broker loads it once t+1.600s g-b polls first. Its zonal owner, broker-2, did not write wal-0001, so it reads the object through az-b's cache broker, which loads it from object storage once (one GET) and keeps it for the zone. With one broker per zone, broker-2 is both az-b's owner and its cache broker. wal-0001 now carries the mark b. g-b joined behind, so it catches up one record per poll (the simulator's pace): it read offset 0. Open at this step: step 3, A WAL object is read in az-b: the zone's cache broker loads it once
  4. Each zone that loads the object adds its mark t+1.900s g-a polled at 1800 and read both records from broker-1's memory: broker-1 is az-a's owner and wrote wal-0001, so az-a loaded nothing and adds no mark. g-c polled at 1900 through broker-3, az-c's owner and cache broker, which loaded wal-0001 into az-c's cache: a second GET, and the mark c. The object now carries a mark for each zone that read it through its cache broker: b and c. Open at this step: step 4, Each zone that loads the object adds its mark
  5. A later read in the same zone hits the zone cache t+2.200s g-b's next poll reads offset 1, which is in wal-0001 too. az-b's cache broker already holds the object, so broker-2 serves the record from the zone cache: no GET, and no new mark. Three zones have read the object with two GETs, one per zone that read it through a cache broker. Open at this step: step 5, A later read in the same zone hits the zone cache
  6. A client with no zone_id lands on any broker (the simulator's choice) t+2.350s p-x sets no zone_id, and Ursa's sources do not say where such a client goes; the simulator hashes it over every alive broker. Its k17 (orders-0) went to broker-1 in az-a and its k22 (orders-1) to broker-3 in az-c: one client, two zones. Wherever p-x runs, at least one of these requests crosses a zone. The cross-AZ counters count no request of a client with no zone, since the simulator does not know where it runs. Open at this step: step 6, A client with no zone_id lands on any broker (the simulator's choice)

The takeaway

orders-0 had three zonal owners, one per zone. p-a and g-a in az-a talked only to broker-1, g-b only to broker-2 in az-b and g-c only to broker-3 in az-c, so no request of a client with zone_id left its zone. g-a read both records from broker-1's memory, because broker-1 wrote wal-0001. g-b and g-c read the object through their zone's cache broker, which loaded it from object storage once per zone: two GETs and the marks b and c. g-b's second read in az-b came from the zone cache, with no GET. p-x set no zone_id, and its two records went to brokers in two zones. Ursa facts: a client with zone_id talks to a zonal owner in its own zone; the owner that wrote the tail serves it from memory, and a WAL object is otherwise read through one cache broker per zone. Simulator choices: the zonal owner is a stable hash over the brokers of the zone, standing in for Ursa's consistent hash ring; the cache broker is a stable hash of the object key over the zone's brokers; a client with no zone_id is hashed over every alive broker, since the sources do not say where it goes; 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.

Configs in this scenario

  • client.id 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.
  • ursa.storage.enable A topic setting of Ursa for Kafka: a topic created with ursa.storage.enable=true is a diskless topic whose data is stored in object storage, while the other topics of the same cluster keep classic local disks.

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=13.1.2" title="Kafka Simulator: Ursa for Kafka: zones and the zonal owner" 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/ursa-zones-zonal-owner/">Ursa for Kafka zones: the zonal owner and the zone cache</a></p>

Further reading

StreamNative documentation

More in Diskless

All scenarios