Optimizing publishers
Three Camel publish routes with different producer settings, a flash-sale load driver and Kafka client metrics in Prometheus.
Chapter 5
examples/05-optimizing-publishers/ publishes a burst of OrderPlaced records through three Camel routes and reads how many records each Kafka request carried. It accompanies Optimizing publishers.
It uses Quarkus, Camel Kafka, Micrometer and OpenTelemetry to the LGTM stack. There is no database.
(cd examples/domain-model && mvn -B -q install)
cd examples/05-optimizing-publishers
mvn -B verify
./verify.sh
./bench.sh
What to observe
- Unbatched is one record per batch. With
lingerMs=0andproducerBatchSize=0the route sends at most three records per request on three partitions. - Kafka’s defaults already batch. The default route sends several times the unbatched records per request with no tuning options.
- Tuning goes further. The tuned route sends fewer requests and fewer bytes per record, and the broker’s log holds
lz4batches. - One caller never fills a batch. The tuned route with one caller in flight sends about one record per request; with 100 callers it does not.
- acks=1 without idempotence drops the producer id. After a recreate the new batches carry no producer id.
- Throughput belongs to bench.sh.
results/holds the medians and ranges of the repeated rounds.
Infrastructure
Kafka and the LGTM stack from examples/_infra, a one-shot container that creates the topic, and order-service on port 8080. The compose project is edp-05.