Repository navigation
Description
Describe the bug
With 100,000 MQTT clients each publishing one 1 KB QoS 1 message per second (100,000 msg/s offered), Zilla writes
only about 6,100 msg/s to Kafka, steadily for 30 minutes. PUBACKs come back after 8–19 seconds, so each client
can only publish about once every 15 s. Zilla uses about 3 of 32 cores and Kafka is almost idle, so neither side is
out of CPU.
Every message that was sent did reach Kafka (sent 6,083/s, written 6,090/s); the problem is throughput and PUBACK
latency, not loss.
To Reproduce
Setup (AWS us-east-1, one subnet, cluster placement group):
- Zilla
ghcr.io/aklivity/zilla:2.7.2-rc1on c6i.8xlarge (32 vCPU),start -e -w 31,examples/mqtt.kafka.proxy
config (routesdevice/#tomqtt-devices), stdout log exporter only. - Kafka
apache/kafka:4.1.1, single broker on a separate c6i.8xlarge with a gp3 volume (16,000 IOPS, 1,000 MB/s);
mqtt-deviceswith 16 partitions, replication factor 1,retention.ms=900000. - Two load generators (c6i.2xlarge), each with 50,000 publishers connecting at 50/s (100/s in total, to stay
below the CONNACK limit in mqtt-kafka: CONNACK throughput tops out at ~180–350/s on a 32-vCPU host, with the host mostly idle #3305):docker run --network host emqx/emqtt-bench:0.6.3 pub -h <zilla-ip> -p 7183 -V 4 -k 300 -C true \ -c 50000 -R 50 -n <1 | 50001> --prefix <run>-p- -t 'device/%i' -q 1 -s 1024 -I 1000 -F 1 -w true
- Publish response time measured by 100 extra MQTT 3.1.1 connections, each publishing one QoS 1 message per second
and timing PUBLISH → PUBACK (10 s timeout).
Actual behavior
30-minute window after all 100,000 clients connected:
| Metric | Value |
|---|---|
| Offered | 100,000 msg/s (100,000 clients × 1 msg/s) |
| Sent by clients | 6,083 msg/s (each client waits for its PUBACK; pub_overrun = every publish) |
Written to mqtt-devices |
6,090 msg/s, steady (5,600–6,400 per sample) |
| PUBACK latency, probe | 1,819 PUBACKs timed: avg 10.2 s, p50 8.4 s, p90 16.5 s, p99 18.6 s, max 19.6 s. For the other 12,402 of 14,221 publishes (87%), nothing at all came back from Zilla for 10 s, so the probe gave up on them. |
| Zilla host CPU | 9% average (about 2.9 of 32 cores) |
| Zilla memory | 16.2 → 17.6 GiB over the window |
| Kafka host CPU | 0.5% average |
| Load generator CPU | about 12% |
During the run, 2–3 of Zilla's Kafka connections again had about 24,650 bytes of unread data in their receive queue,
as in #3306.
Expected behavior
With the host and broker this idle, ingest close to the offered 100,000 msg/s (EMQ reports 100,000+ msg/s into Kafka
on the same class of machine) and PUBACK latency in milliseconds.
Notes
- PUBACK is sent only after Kafka has acknowledged the message (fix(binding-mqtt-kafka): acknowledge qos1 publish only as far as kafka has acknowledged it #3295), so PUBACK latency here is the time to get
the message into Kafka through Zilla. - On a laptop (Docker Desktop, 50 publishers, 1 KB, QoS 1) we earlier saw about 8,500 msg/s, a similar ceiling, so it
may not depend on the number of connections. - At 11:05:56, near the end of the ramp and before publishing started, Zilla closed 3,134 client connections within
one second (all from one load generator; the clients sawtcp_closed). That's close to one worker's share of
100,000 clients over 31 workers. Possibly related to mqtt-kafka: some of the first clients after start-up are disconnected right after CONNACK, with nothing logged #3308.
Environment
ghcr.io/aklivity/zilla:2.7.2-rc1(sha256:0dce0a7d...),start -e -w 31- Kafka
apache/kafka:4.1.1, single broker, KRaft - AWS c6i.8xlarge × 2 (Zilla, Kafka), c6i.2xlarge × 2 (emqtt-bench 0.6.3), Ubuntu 22.04
Activity
ankitk-me commentedon Nov 19, 2026
Still reproduces on
2.7.2-rc2(sha256:e197b1bb…). The setup is the same as above: AWS c6i.8xlarge broker,start -e -w 31, separate Kafka 4.1.1 host, two c6i.2xlarge load generators, 100,000 QoS 1 publishers connecting at 100/s in total, 1 KB at 1 msg/s each, and 100 probe connections. The measurement window was 5 minutes instead of 30.mqtt-devicesThe lower p99 on rc2 isn't an improvement. More publishes went past the probe's 10 s timeout, so they aren't in the percentiles.
In this run, 3,090 of the 100,000 clients were closed at the end of the ramp, together with a Kafka produce error 87 on
mqtt-devices(see #3308). So about 96,900 clients were publishing during the window. Ingest is capped well below the offered rate either way, so this doesn't change the result.jfallows commentedon Nov 19, 2026
Analysis of the ingest ceiling here, and of part 2 of #3420 (QoS 2), which turns out to be the same limit.
What limits ingest.
KafkaBinding.workers()returns 1 for thecache_serverkind. Everything a published record goes through on the Kafka side therefore runs on one engine worker, whatever-wis set to: the cache server produce fan, the append to the cache log/index files, the produce requests to the partition leader, and the fetch that brings the record back from Kafka to populate the cache. The other workers only carry MQTT connections. That is why neither Zilla's other workers nor Kafka are busy while ingest is capped.Measured on a local Docker host (
start -w 4, 16-partitionmqtt-devices,emqtt-benchQoS 1, 1 KB,-F 1, 1,000 clients each offering 100 msg/s):client.produce.max.request.millis=5worker#3).writecall for each small field of the cache entry, around 8 to 10 per file per entry) and flyweight field reads.QoS 2 (#3420 part 2). The same worker serves about 8,000 records per second in both cases. A QoS 2 exchange writes about 3.6 records (the message to
mqtt-devices, plus session records tomqtt-sessions), in produce requests of 2 records. 8,000 / 3.6 ≈ 2,200 exchanges per second here, against about 8,400 QoS 1 publishes per second: the 4x difference is the records per exchange. The 1,215 exchanges/s in #3420 is 4.4k records/s, in the range of this issue. I did not see offset commit requests on the QoS 2 publish path with the example configuration, soKafkaClientOffsetCommitFactoryis not the limiter there.Raising the ceiling means either letting the cache server's partitions be served by more than one worker (each partition's files owned by one worker), or reducing the work per record on the worker. The first changes how the cache is partitioned across workers, so I'm not changing it under this issue; the numbers above are from a 4-core host and only the relative figures should be compared with the reports.
Generated by Claude Code
feat(binding-kafka): add filter term extraction and fanout index
test(binding-kafka): add filtered fetch scenarios for concurrent and …
perf(binding-kafka): wake cache client fetch members by filter term
test(binding-kafka): add dispatch modes to KafkaCacheCursorBM
feat(binding-kafka): add produce flush progress decision
perf(binding-kafka): flush produce acks only to members that progressed
perf(binding-kafka): grant no reply credit to bootstrap fetch streams
perf(binding-kafka): extend cache files in steps and append through t…
feat(engine): supply named native write buffers from the engine context
perf(binding-kafka): use named native write buffers for factory scrat…
perf(binding-mqtt): use named native write buffers for factory scratc…
test(binding-kafka): add broadcast topology and a no-filter variant t…
test(binding-kafka): add an overlapping wildcard topology to KafkaCac…
perf(binding-kafka,binding-mqtt-kafka): remove byte[] dependence ahea…
perf(runtime): use named native write buffers across remaining bindings
perf(binding-kafka): faster fetch fanout, fewer flushes and syscalls,…