Updated November 2026: We have restyled this July 2023 post. Tiered storage (KIP-405) is now production-ready in Apache Kafka 3.9, Kafka 4.0 removed ZooKeeper entirely, and we have corrected the storage and compression details and replaced a calculator link that no longer works.
How do you reduce the total cost of ownership (TCO) of Kafka on public cloud? Optimising costs and increasing efficiency are top priorities for organisations, especially when deploying Kafka clusters in the cloud. Public cloud services have grown tremendously, with organisations investing in data infrastructure and analytics while also looking to save money. However, there are hidden costs in running distributed systems in the cloud.
Across more than 30 enterprise engagements we have explored many ways to demystify and reduce cloud costs for Kafka clusters. Here we share lessons learned from the field: sizing, compute and storage choices, network transfer costs across single and multi-zone environments, compression, configuration tuning and monitoring.
Why is Kafka cost on public cloud hard to control?
The adoption of public cloud shows no signs of slowing down, with real-time analytics leading the charge. Organisations increasingly use cloud services for real-time data infrastructure and analytics, but distributed systems carry hidden costs: replicated storage, cross-zone traffic and idle headroom. Without the correct planning and architecture, things can get very expensive, very fast.
Kafka cost driver
Where the money goes
Main lever
Compute
Broker instances or Kubernetes nodes
Size from measured throughput; right-size instance types
Storage
Replicated disks for the retention period
Tune retention; tiered storage for long retention
Networking
Cross-zone replication, producer and consumer traffic
Rack-aware follower fetching; compression
Operations
Engineering time, monitoring, upgrades
Automation and capacity alerting
If you are comparing self-managed Kafka with managed services on price, see our guide to the best managed Kafka services.
How do you calculate your Kafka cluster size?
Before deploying Kafka on public cloud, analyse your needs and estimate your workload growth. Start by estimating throughput (messages per second, average message size, number of consumer groups reading each topic) and retention. From that baseline, work out the number of brokers, storage and network capacity you need, then map it onto cloud resources.
Track usage and monitor infrastructure spend so you can optimise for compute and throughput while saving costs. Compare each new deployment with previously established standards so every cluster is deployed in a cost-effective way.
Which compute options suit Kafka on public cloud?
You can run Kafka on virtual machines or on Kubernetes. For high-performance deployments we recommend at least 4 vCPU and 16 GB of RAM per broker, because Kafka relies heavily on the operating system page cache; memory-optimised instance families give more cache per vCPU. Choose instance types based on your performance and cost requirements, and benchmark before committing to reserved capacity.
How do you optimise Kafka storage costs?
Calculate the storage your cluster needs from throughput, replication factor and your desired retention period. On AWS, EBS volumes are replicated within their availability zone and can be detached and re-attached to a replacement instance after a failure, so a new broker does not have to re-copy all of its data from other brokers.
Networking is a major source of cost for Kafka clusters on public cloud, because cloud providers charge for traffic between availability zones. Spread brokers, producers and consumers across multiple availability zones for reliability and resiliency, then reduce the cross-zone traffic that design creates.
Since Kafka 2.4, rack-aware follower fetching (KIP-392) lets consumers read from a replica in their own zone: set broker.rack on each broker, replica.selector.class to the rack-aware selector, and client.rack on consumers. Analysing your fan-out (how many consumer groups read each topic) shows where cross-zone reads cost most. If you are unsure how to architect a cost-efficient solution, talk to the Kafka experts at OSO.
Which Kafka compression type should you use?
Kafka can compress batches of messages on the producer, which cuts network transfer and disk usage. Kafka supports four codecs, each with different trade-offs between CPU usage, compression ratio and speed.
Compression type
Trade-off
gzip
High compression ratio, but the most CPU-intensive
snappy
Fast with low CPU usage, moderate compression ratio
lz4
Very fast with low CPU usage, a good default for throughput
zstd
High compression ratio at moderate CPU usage
Compression costs some CPU on producers and consumers, but repetitive payloads such as JSON and XML compress well, saving disk space and network bandwidth.
How do you tune Kafka configuration for cost?
Configuration plays a crucial role in optimising Kafka clusters. Tuning parameters such as log.segment.bytes, log.retention.bytes and log.retention.ms to each use case keeps storage in line with what you actually need. Tiered storage, available in both Apache Kafka and Confluent Platform, reduces the cost of long retention further.
ZooKeeper is no longer part of the picture: Apache Kafka 4.0 removed ZooKeeper entirely, so new clusters run in KRaft mode without a separate ZooKeeper ensemble to pay for and operate. See our ZooKeeper to KRaft migration guide if you are still running ZooKeeper.
Why do continuous monitoring and automation lower Kafka cost?
Continuously monitor your workloads and adjust as needed. Estimate workloads, grow incrementally rather than over-provisioning, and automate administrative tasks to reduce operational burden. Offloading heavy lifting to managed platforms such as Confluent can also cut operational cost.
Always know how much runway you have in your Kafka clusters, and set up monitoring and alerting to notify you at 70% of that threshold.
How do you lower Kafka cluster costs overall?
Deploying Kafka clusters in the cloud requires careful analysis and optimisation to reduce costs. By analysing your needs, choosing the right compute and storage options, optimising networking, using compression and tuning configuration, you can save money while keeping high performance. Continuous monitoring and automation keep costs efficient over time.
Key takeaway: Kafka cost on public cloud is driven by compute, replicated storage and cross-zone traffic. Size from measured throughput, cut network spend with rack-aware fetching and compression, use tiered storage for long retention, and alert at 70% of capacity instead of over-provisioning.
Frequently asked questions
What drives the cost of running Kafka on public cloud?
The main drivers are broker compute, replicated storage for the retention period, network traffic between availability zones, and the engineering time needed to operate, monitor and upgrade the cluster.
How can you reduce cross-AZ networking costs in Kafka?
Use rack-aware follower fetching (KIP-392, available since Kafka 2.4): set broker.rack on brokers, the rack-aware replica selector on the cluster and client.rack on consumers so they read from a replica in their own zone. Compression also reduces the bytes sent between zones.
Which Kafka compression type is best for cost?
zstd usually gives the best compression ratio at moderate CPU cost, while lz4 and snappy are faster with lower CPU usage. Benchmark with your own payloads; repetitive formats such as JSON compress especially well.
Does tiered storage reduce Kafka costs?
Yes, for high-retention topics. Tiered storage (KIP-405), production-ready since Apache Kafka 3.9, moves older log segments to cheaper object storage so you do not need more brokers or larger disks just to keep data longer.
When should you scale a Kafka cluster?
Monitor how much capacity runway each cluster has and alert at around 70% of the limit, so you can scale in time without paying for large amounts of idle headroom.