blog by OSO

Kafka performance best practices for monitoring and alerting

Sion Smith
Sion Smith 12 July 2023
kafka-performance

Quick Answer

Kafka performance improves when you size partitions for parallelism, tune producer batching and acknowledgements for your durability needs, keep consumer groups caught up with measured lag, and automate broker metrics. There is no single config that fits every cluster—measure throughput, latency and cost together, then change one variable at a time.

Why does Kafka performance tuning matter?

Apache Kafka underpins real-time pipelines where missed SLOs show up as lag, timeouts or rising cloud bills. From OSO’s work across enterprise Kafka estates, the teams that improve performance fastest treat tuning as a measured loop: baseline metrics, change one lever, re-measure. Guesswork on partitions, acks or consumer count usually trades one bottleneck for another.

This refresh focuses on practical Kafka performance best practices for topics, producers, consumers and monitoring—so you can move from “it feels slow” to a clear plan.

How should you tune topics and partitions for Kafka performance?

Partition count drives both parallelism and operational cost. More partitions generally raise throughput for producers and consumer groups, but each partition adds metadata, open files and rebalance work on brokers and clients.

Practical guidance:

  • Start from expected peak throughput and consumer parallelism, not an arbitrary large number.
  • Prefer fewer, well-sized partitions over thousands of tiny ones that never fill a batch.
  • Watch under-replicated and offline partitions after any increase—those signals often appear before end-user latency does.
  • Revisit partition strategy when you adopt KRaft, tiered storage or multi-region topologies; the old ZooKeeper-era defaults are rarely optimal.

For a deeper look at partition-aware application design, see how to build high-performance Kafka Streams applications.

How do you improve Kafka consumer performance?

Consumer lag is the headline Kafka performance metric for most reading workloads. Two levers dominate:

  1. Parallelism — Scale the consumer group so partitions are actively read. One consumer per partition in a group is the usual ceiling; idle consumers do not help.
  2. Commit strategy — Batch offset commits where your processing allows it. Committing every record increases broker chatter; committing too rarely lengthens reprocessing after a failure.

Also check max.poll.records, fetch sizes and whether processing blocks the poll loop. A fast fetch with slow business logic still looks like “Kafka is slow”. Pair this section with the Kafka consumer configuring cheatsheet when you are adjusting client settings.

How do you optimise Kafka producers without losing durability?

Producer tuning is where throughput and data integrity trade off most clearly:

  • acks — acks=all (with a suitable min.insync.replicas) favours durability; weaker acks favour speed. Confirm what your producers actually use today—many estates still run mixed defaults.
  • Batching — batch.size and linger.ms let the client fill batches before send. Small messages with linger.ms=0 create chatty, expensive traffic.
  • Buffering — buffer.memory must absorb bursts; when it fills, producers block or throw, which surfaces as application latency rather than broker CPU.

Change one setting at a time and measure end-to-end latency under a realistic produce rate. Official producer configuration reference: Kafka producer configs.

What trade-offs should you weigh when improving Kafka performance?

Every Kafka performance change sits on four axes: throughput, latency, data integrity and cost. Raising partitions or brokers can lift throughput while increasing management overhead and cloud spend. Weakening acknowledgements can cut publish latency while widening the failure window.

Before you scale out:

  • Quantify whether the bottleneck is client, broker, disk, network or downstream processing.
  • Prefer fixing hot partitions, slow consumers or mis-sized batches before adding hardware.
  • Budget for the operational cost of more brokers, more partitions and more alerting noise.

If you are also cutting platform spend, OSO’s fully managed Kafka and Kafka services engagements often combine performance tuning with right-sizing so cost and SLOs move together.

What should you monitor to keep Kafka performance stable?

Automation matters once the cluster is larger than a handful of brokers. Manual checks do not keep up with partition churn and consumer group changes.

Prioritise:

  • Active controller count (should be stable at one in classic deployments)
  • Under-replicated and offline partitions
  • Consumer lag by group and partition
  • Request latency (produce/fetch), local time and I/O wait
  • Disk usage and log flush behaviour
  • Network saturation on broker interfaces

Open-source stacks such as Prometheus and Grafana remain the common baseline; the goal is actionable alerts, not vanity dashboards. For CLI-oriented operators, see 7 must-have CLI tools every Apache Kafka engineer should know.

Frequently asked questions

What is the fastest way to diagnose poor Kafka performance?

Start with consumer lag, under-replicated partitions and produce/fetch latency. Those three usually show whether the problem is on the read path, the write path or the brokers themselves.

How many partitions should a Kafka topic have?

Enough for your target consumer parallelism and throughput, and no more. Excess partitions increase rebalance time, memory use and metadata load without improving speed.

Does raising linger.ms always improve producer throughput?

It often improves batching for small messages, but it adds intentional delay. Measure p99 latency under load before and after; latency-sensitive publishers may prefer a smaller linger with larger batch.size.

Which Kafka metrics matter most for alerting?

Alert on under-replicated partitions, offline partitions, sustained consumer lag growth and broker disk/network saturation. Throughput alone rarely explains user-visible incidents.

Should I tune brokers or clients first?

Tune the side that owns the bottleneck you measured. Client batching and consumer parallelism fix many “slow Kafka” tickets without touching broker JVM settings.

When should we bring in outside Kafka performance help?

Bring in specialists when lag or timeouts persist after basic client and partition checks, or before a major migration (KRaft, multi-region, tiered storage). OSO’s Kafka support team works on those production cases daily.

Is Kafka performance tuning different after KRaft?

Yes—controller behaviour and some operational limits change without ZooKeeper. Re-baseline partition counts, metadata-sensitive workloads and recovery drills after migration rather than copying old runbooks.

Key takeaways

  • Kafka performance is a measured trade-off across throughput, latency, integrity and cost—not a single config file.
  • Size partitions for real parallelism; avoid both under- and over-partitioning.
  • Tune producers (acks, batching, buffers) and consumers (group size, commits, poll settings) against metrics, not folklore.
  • Automate monitoring for lag, under-replicated partitions and broker I/O so regressions surface early.
  • Link platform changes to money outcomes via Kafka services when you need hands-on help.

Facts in this refresh were checked against public Apache Kafka documentation on 12 October 2026. Competitor or product names appear only where factual.

Get started with OSO professional services for Apache Kafka

Have a conversation with a Kafka expert to discover how we help your adopt of Apache Kafka in your business.

Contact Us
OSO
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.