Broker Throughput And Capacity
How many messages per second can one Klok service publish and consume? This page gives measured figures for the Java broker client, explains how they were produced, and how to judge them for your own service. The most important thing to keep in mind is that they were measured with the broker on the same machine. They show what the client and the broker can do when the network does not get in the way. They do not show what your service gets across a network.
The Short Version
One service, one subscription, one receive loop, a message of about 300 bytes, broker on the same machine:
| Messages per second | Typed client (Avro) | Bytes client |
|---|---|---|
| Publish | 190,000 – 240,000 | 440,000 – 575,000 |
| Consume | 235,000 – 305,000 | 350,000 – 450,000 |
| Client cost per message | Typed client (Avro) | Bytes client |
|---|---|---|
| Encoding the payload on send | 480 ns | 5 ns |
| Decoding the payload on receive | 630 ns | 5 ns |
| Building the Klok properties on send | 103 ns | 81 ns |
The typed client, KlokBrokerClient<T>, turns a datamodel object into Avro and back for every message. The bytes
client, KlokBytesBrokerClient, takes a byte[] that the service has already encoded, for example as Protobuf, and
sends it as is. Both put the same Klok properties on the message and follow the same acknowledgement rules. The bytes
figures leave out the service's own encoding. The bytes client only pays off if that encoding is cheaper than Avro, or
if the service passes payloads on without looking inside them.
Most services never come near these rates. What limits an integration is almost always the system at the other end, the work the handler does, or the network. The figures matter when you design something that must carry tens of thousands of messages per second or more, and when you decide between the two clients.
What Was Measured
The message. The payload was an order shaped like a typical integration datamodel: ten fields (ids, a customer name, a currency, a timestamp, an amount, a status, a flag, a free text note) and a list of five order lines with four fields each. Encoded as Avro it is 301 bytes. The bytes client sent exactly the same 301 bytes, already encoded, so both clients carried the same payload.
The properties. Every message also carries Klok properties, and those travel with each message too:
| Typed client | Bytes client | |
|---|---|---|
| Properties | klok-instance, klok-body-type, klok-sent-time, and their 0.2 names klokSolutionId, klokBodyType, klokSentTime |
klok-instance, klok-body-type, klok-sent-time |
| Size of the properties | about 227 bytes | about 105 bytes |
| Message with properties | about 530 bytes | about 410 bytes |
In a real flow the correlation id, the invocation ids and the CloudEvents attributes add some 150 to 300 bytes more. The typed client writes the old 0.2 names for one more release, so that 0.2 services can still read the messages. The bytes client leaves them out: each property is read for every message, and the duplicates cost the bytes client about a fifth of its publish rate.
The run. Each run used a new topic and published and consumed 100,000 messages with each client, in two timed phases:
- Publish. The subscription was created first, so nothing was lost. Then all messages were sent without waiting for each other. The clock stopped when the broker had confirmed the last one. This is the rate at which one service can push messages onto the broker.
- Consume. A subscriber was then attached to the full backlog. The clock stopped when the handler had seen every message and each had been acknowledged. The handler only counted, so the figure is the client and broker cost alone.
There were three runs per client, alternating typed and bytes. Each table shows the range over the three runs. Results vary by about 20 % between runs: the first run is usually the slowest while the JVM warms up.
The settings. These are the defaults a Klok service has unless it changes them:
| Setting | Value |
|---|---|
| Subscription | exclusive, one receive loop (concurrency 1) |
| Producer batching | up to 100 messages or 5 ms per batch |
| Consumer receiver queue | 1,000 messages (Pulsar default) |
| Acknowledgements | grouped and sent every 100 ms (Pulsar default) |
| Client memory limit for unconfirmed sends | 64 MiB (Pulsar default) |
| Compression | none |
| TLS and authentication | none (plain pulsar://, no OAuth2) |
| Metrics and logging | OpenTelemetry disabled, log level INFO |
The per message costs in the second table were measured without a broker. Each operation ran 300,000 times to warm up the JVM and 1,000,000 times with the clock running.
The Environment
| Date | 2026-09-26 |
| Machine | MacBook Pro, Apple M5 Max, 18 cores (6 performance, 12 efficiency), 128 GB memory, on mains power |
| Operating system | macOS 26.6.2 |
| Broker | Apache Pulsar 4.0.4 standalone (broker, BookKeeper and metadata store in one process, one node, no replication) in Docker Desktop 29.8.0 (Linux arm64 VM with 18 CPUs and about 37 GB of memory), default storage and durability settings |
| Client | JDK Temurin 21.0.12, pulsar-client 4.0.4, klok-brokerclient-java 0.3.5 |
| Client and broker together | the same laptop: the benchmark process on macOS, the broker in the Docker VM |
Network Proximity And Latency
This is the part that changes the most between the benchmark and a real service.
In the benchmark there was no network in between. The client reached the broker through Docker Desktop's port forwarding on the same machine. Opening a TCP connection took about 0.05 ms. The figures therefore show how fast the client and the broker are when nothing slows the traffic down. For a service on another host they are an upper limit.
In the Klok datacenter the distance is short. Klok services run in the Kubernetes cluster in Klok's own datacenter,
and the broker (broker.ipaas.se) runs on a separate host on the same internal network. There, a round trip should take
well under a millisecond. This has not yet been measured from inside the cluster. Until it has, expect figures
somewhat below the ones on this page, not above them.
From a laptop over the Klok VPN it is a different situation. Measured on 2026-09-26 from the benchmark machine through the IPsec VPN to the broker: ping round trips of 21–95 ms (57 ms on average), and a TCP connection in 58–79 ms. That is more than a thousand times the round trip of the benchmark. Use it for development and testing, not to judge how fast a service will be.
How latency affects each kind of traffic
The estimates below follow from how Pulsar and the Klok client work. They were not measured over a real network.
- Publishing is barely slowed by latency.
sendMessagedoes not wait for the broker, so many messages are on their way at once. Latency only becomes a limit when the unconfirmed messages reach the client's 64 MiB memory limit. The amount in flight is the send rate times the round trip time: 500,000 messages of 410 bytes per second at a 60 ms round trip is about 12 MB, well within the limit. Across a VPN the bandwidth of the link runs out first. - Consuming is limited by latency together with the receiver queue. The broker sends at most as many messages ahead as
the consumer's receiver queue holds (1,000 by default), and the consumer asks for more as it works through them. One
subscription therefore receives at most about one queue per round trip. At a 60 ms round trip that is roughly 17,000
messages per second, however fast the handler is. At a sub-millisecond round trip the limit is far above what the client
can process. For a high-volume consumer on a distant broker, raise
receiverQueueSizeinKlokSubscriptionOptions. Raisingconcurrencydoes not help here, because all receive loops of a subscription share one queue. - Acknowledgements do not cost a round trip each. The client collects them and sends them together every 100 ms.
- Request/reply is limited by latency. A synchronous call has to wait for the request to reach the service and the
reply to come back, so each call takes at least one round trip. Batching can add more on quiet topics, because a batch
is sent when it is full or when its time is up. A request can wait up to 5 ms. A reply sent by
KlokBrokerClientSyncorKlokBytesBrokerClientcan wait up to 25 ms. One thread that makes calls one after another therefore gets at most a few dozen calls per second, even on a fast network. Make many calls in parallel, or use an asynchronous flow, when volume matters.
Choosing Between The Typed And Bytes Client
Use the typed client by default. It registers the datamodel's schema on the topic. The broker then knows the message format, other services can read the messages through the generated datamodel, and a schema change is checked against earlier versions.
Use the bytes client when a service must carry very high volumes and has an encoding of its own that is cheaper than
Avro, or when it relays payloads without reading them. In exchange, the topic has no schema: the topic name and the
klok-body-type property are all the contract there is between the services. For how to use it, see Bytes
client in the
broker client documentation.
What These Figures Do Not Tell You
- Production security. Production uses
pulsar+ssl://with OAuth2, and TLS encryption costs CPU on both sides. - A production broker. The benchmark used one standalone broker without replication. Klok's broker writes its data with the durability settings of the platform.
- Integration routes. The benchmark called the broker client directly. A route in the Klok Quarkus extension adds Camel, retries, the context properties and logging on top of that.
- Real handlers and several receive loops. The handler did no work, and each subscription ran one receive loop.
- Server hardware. The figures come from one laptop, not from Klok's servers.
- Compression and large messages. Messages were about 300 bytes and uncompressed. Larger payloads move fewer messages per second but more bytes. Payloads in the megabyte range belong in object storage, with only a reference in the message (see Claim Check, Sync Over Async, And Other Tactics).
When a service has real volume requirements, measure it in its own environment, with its own messages and handler.
Reproducing The Figures
The benchmark belongs to the broker client repository (klok/framework/klok-brokerclient-java). ./gradlew benchmark
runs it and prints the results, and KLOK_BENCHMARK_SERVICE_URL points it at a broker without authentication. The exact
commands for a throwaway local broker are on the
Testing page. Record the
machine, the broker, the versions and the round trip time together with the figures, as on this page. Without them, the
figures cannot be compared with anything else.