Skip to content

mqtt-kafka: with 100K connected QoS 1 publishers, ingest tops out at ~6,000 msg/s and PUBACKs take 8–19 s #3307

Open

Description

@ankitk-me

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-rc1 on c6i.8xlarge (32 vCPU), start -e -w 31, examples/mqtt.kafka.proxy
    config (routes device/# to mqtt-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-devices with 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

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

  1. added
    bug
    on Nov 17, 2026
  2. ankitk-me commented on Nov 19, 2026

    @ankitk-me
    ContributorAuthor

    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.

    rc1 (above) rc2
    Written to mqtt-devices 6,090 msg/s 5,603 msg/s
    Sent by clients 6,083 msg/s 5,600 msg/s
    PUBACK latency, probe (PUBACKs within 10 s) p50 8.4 s, p99 18.6 s p50 8.4 s, p99 9.9 s
    Probe publishes with no PUBACK within 10 s 87% 92% (2,799 of 3,037)
    Zilla host CPU 9% 9%
    Zilla memory 16.2–17.6 GiB 16.6 GiB
    Kafka host CPU 0.5% 0.4%

    The 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.

  3. jfallows commented on Nov 19, 2026

    @jfallows
    Contributor

    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 the cache_server kind. Everything a published record goes through on the Kafka side therefore runs on one engine worker, whatever -w is 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-partition mqtt-devices, emqtt-bench QoS 1, 1 KB, -F 1, 1,000 clients each offering 100 msg/s):

    msg/s reaching Kafka produce requests/s records per request request round trip
    16 partitions about 8,400 to 12,000 500 to 1,000 12 to 20 (about 20 KB) 9 to 12 ms
    4 partitions about 8,700 about 450 21 about 5 ms
    1 partition about 6,700 about 330 21 (23.6 KB) about 2.2 ms
    16 partitions, client.produce.max.request.millis=5 about 8,900 similar 12 to 15 9 to 13 ms
    • Every produce request in the 16-partition run was encoded on the same worker (worker#3).
    • The produce request pipeline is not the limit once there is more than one partition: requests are far below what one request in flight per partition and a 10 ms round trip would allow, and the request linger makes no difference. With one partition the formula holds: one request in flight and a window of about one slot gives 21 records / (2.2 ms + refill) ≈ 6.8k per second.
    • The Kafka produce round trip is milliseconds. The time a client waits for its PUBACK is the time the record spends queued for that one worker; with every client waiting for its PUBACK, throughput is clients divided by that latency, which matches 100,000 / 8.4 s ≈ 12k and the observed 5.6k to 6.1k once the queue is only partly offered.
    • On that worker the largest shares of time per record are the cache populate path (decoding the fetched record, then a separate write call 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 to mqtt-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, so KafkaClientOffsetCommitFactory is 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions