Disk and Network Considerations in Kafka: The Roads and Warehouses Your Events Depend On
Kafka is a data-moving machine, and its speed is set by how fast it can write to disks and push bytes across networks. This guide explains how Kafka uses both, how to size them, and how to avoid the mistakes that cause slow clusters and painful outages.
Imagine a huge distribution centre that receives parcels from thousands of suppliers, stores them for a few days, and ships them out to thousands of shops. The building has two things that decide how well it works. The first is its warehouse: how much shelf space there is, how quickly workers can put parcels on shelves and pick them off again, and how well the shelves are organised. The second is its roads: how many lorries can arrive and leave at the same time without causing a traffic jam. You can hire the cleverest manager in the world, but if the warehouse is too small or the roads are too narrow, the whole operation will crawl.
Apache Kafka is that distribution centre for data. The warehouse is the disk, and the roads are the network. Almost every Kafka performance problem, and a great many outages, come down to one of these two being too small, too slow, or badly arranged. In this tutorial we will start from the very basics and build up, in plain language and with everyday analogies, until you can size, tune, and troubleshoot the disks and networks of a real production Kafka cluster with confidence.
1Kafka Basics You Need First
A short refresher on the parts of Kafka that use disks and networks.
Apache Kafka is a platform for storing and moving streams of events. An event is a small record of something that happened, such as an order placed or a temperature measured. Kafka stores these events in order, on disk, so that many applications can read them now or much later.
Broker
A Kafka server with its own disks and network connections. A cluster is made of several brokers.
Topic
A named category of events, such as “orders”. Think of it as a labelled folder of related messages.
Partition
A topic is split into partitions. Each partition is an ordered log stored as files on a broker’s disk.
Replica
A copy of a partition kept on another broker for safety. One replica is the leader, and the others are followers.
Producer and Consumer
Producers write events into Kafka, and consumers read events out of Kafka.
Retention
The rule that decides how long, or how much, data Kafka keeps before deleting the oldest events.
The three resources every broker spends
Every broker spends four kinds of resources: CPU for processing requests and compressing data, memory for caching, disk for storing data, and network for moving it. Kafka is generally light on CPU compared with the amount of data it handles. Memory is used mostly as a cache. So in most clusters, the two resources that run out first are disk and network, and that is why this tutorial focuses on them.
A restaurant kitchen has cooks (CPU), a countertop (memory), a pantry (disk), and a delivery door (network). On a busy night, it is rarely the cooks who are the problem. It is usually a pantry that is too full or a delivery door that is too small for all the trolleys trying to get through.
2Why Disk and Network Decide Kafka’s Fate
Kafka’s design makes it very fast, but only if the disk and network underneath it behave well.
Kafka does two simple things over and over. It receives bytes from the network and appends them to a file, and it reads bytes from a file and sends them over the network. Everything else, such as replication, retention, and compaction, is a variation on those two actions. That simplicity is the source of Kafka’s speed, and also the reason its speed is bounded by disk and network capacity.
flowchart LR
P[Producer] -->|network in| B[Broker]
B -->|write to disk| D[Log files on disk]
B -->|network out| F[Follower brokers]
D -->|read from disk or cache| B
B -->|network out| C[Consumers]
What goes wrong when either is short
The disk fills up
A full disk stops a broker from accepting writes, and can take partitions offline. It is one of the most common and most painful Kafka outages.
The disk is too slow
Writes queue up, followers fall behind and leave the in-sync set, producers time out, and consumers that fall behind cause slow reads from disk.
The network is saturated
Producers cannot send fast enough, replication lags, and consumers receive data late. Latency grows for everyone, not just the busiest client.
Recovery takes too long
When a broker fails, its data must be copied again across the network onto disks. If disks are enormous and networks are slow, the cluster stays fragile for many hours.
A cluster that runs comfortably when everything is healthy may fall over when one broker fails, because the survivors must carry the extra load and also help rebuild the failed broker. Good capacity planning always includes the failure case.
A motorway that handles rush hour perfectly can seize up completely when one lane is closed for repairs. The real test of a road system is how it copes with a closure, not how it looks on a quiet Sunday.
3How Kafka Stores Data on Disk
To size disks wisely, you first need to picture how Kafka arranges its files.
Partitions become directories, logs become segments
Each partition is stored as a directory on the broker’s disk. Inside that directory, the partition’s events are written into a series of files called log segments. Kafka writes only to the newest segment, called the active segment. When the active segment reaches a size limit or an age limit, Kafka closes it and starts a new one. Older, closed segments are never modified, only eventually deleted.
Log Segment
The file that holds the actual events, appended one after another in order.
Offset Index
A small companion file that helps Kafka find a given offset quickly without scanning the whole segment.
Time Index
A companion file that maps timestamps to offsets, so consumers can seek to a point in time.
Checkpoint and State Files
Small files that record replication progress and other bookkeeping needed after restarts.
flowchart LR
A[Partition directory] --> B[Closed segment 1]
A --> C[Closed segment 2]
A --> D[Closed segment 3]
A --> E[Active segment receiving new writes]
E -->|reaches size or age limit| F[Closed and a new active segment starts]
Why sequential writing is a big deal
Because Kafka only ever appends to the end of a file, its disk writes are sequential. Sequential writing is dramatically faster than jumping around a disk, especially on spinning hard drives, where the mechanical head must physically move for random access. This is one of the main reasons Kafka can achieve huge throughput even on modest hardware.
But sequential can turn random
There is a subtlety. Each partition has its own active segment. If a broker hosts a great many partitions, it is appending to a great many files at once. From the point of view of the disk, this can start to look like random access, as the disk hops between all those files. That is one reason why very high partition counts per broker can hurt disk performance, especially on hard drives.
Writing a diary at the end of a single notebook is quick and smooth. Writing one line each into a thousand different notebooks scattered across a room is much slower, even though the number of words is the same, because you keep walking between notebooks.
Since old data is stored in whole segment files, deleting old data is simply removing files. This is very fast compared with removing individual records from a database, and it is why Kafka can keep enormous amounts of data without slowing down.
4The Page Cache: Kafka’s Secret Weapon
Kafka is fast partly because it leans on the operating system’s memory cache instead of building its own.
When a program writes to a file, the operating system does not usually push the bytes to the physical disk immediately. It first keeps them in a region of memory called the page cache, and writes them to disk a little later, in the background. When a program reads a file, the operating system first checks whether the data is already in the page cache, and if it is, it serves it straight from memory without touching the disk.
Kafka deliberately relies on this. It does not maintain a large cache of its own inside the Java process. Instead, it lets the operating system use all spare memory as a cache for the log files. This has two large benefits: the cache survives a Kafka process restart, since it belongs to the operating system, and Kafka avoids the heavy garbage collection pauses that come with keeping huge amounts of data on the Java heap.
Durability comes from replication, not from flushing every write
By default, Kafka does not force each message to be flushed to physical disk before acknowledging it. It leaves flushing to the operating system. Safety comes from keeping several replicas on different brokers, and from producers requiring acknowledgement from enough of them. A single broker crash may lose a few unflushed messages from its own copy, but the other replicas still have them.
sequenceDiagram
participant P as Producer
participant B as Broker
participant C as Page cache in memory
participant D as Physical disk
P->>B: Send batch of records
B->>C: Append to the log file in cache
B-->>P: Acknowledge after replicas confirm
C->>D: Operating system flushes later in the background
Tail reads and lagging reads
Most consumers read data soon after it is written, close to the tail of the log. Those reads are served from the page cache and never touch the disk, making them extremely cheap. But a consumer that has fallen far behind, or one that starts from the beginning of a topic, asks for old data that is no longer in memory. Those reads must fetch from disk, and worse, they bring old data into the cache and push out the fresh data that other consumers want. A single lagging consumer can therefore slow down an otherwise healthy cluster.
| Read Type | Where Data Comes From | Cost | Side Effect |
|---|---|---|---|
| Tail read by a caught-up consumer | Page cache in memory | Very low | None |
| Catch-up read by a lagging consumer | Disk, then memory | Higher, disk reads | Can evict fresh data from the cache |
| Full replay from the start of a topic | Disk, mostly | High, sustained disk reads | Can hurt latency for all other clients |
| Follower fetching from the leader | Page cache when caught up | Low | A far-behind follower reads from disk |
Giving the Kafka process a huge Java heap steals memory from the page cache. A moderate heap, with the rest of the memory left for the operating system, usually gives much better performance than a giant heap.
A librarian keeps the newest, most requested books on the desk in front of them, and the older ones in the basement stacks. Most requests are for desk books, which take seconds. But if one reader asks for a hundred old books from the basement, the librarian spends the day fetching them and has to clear the desk to make room.
5Zero-Copy and the Cost of Encryption
Another reason Kafka is fast is a trick that skips most of the copying, and a common security feature that switches it off.
What zero-copy means
Normally, sending a file over the network involves several copies of the data: from disk to the cache, from the cache into the application’s memory, from the application into a network buffer, and from there to the network card. Each copy costs CPU time and memory bandwidth. Kafka uses an operating system feature that lets the kernel send data straight from the page cache to the network card, without passing through the Kafka process at all. This is called zero-copy, and it makes serving consumers remarkably cheap.
flowchart LR
subgraph PLAIN[Plaintext connection]
A1[Page cache] -->|kernel sends directly| B1[Network card]
end
subgraph TLS[Encrypted TLS connection]
A2[Page cache] --> C2[Kafka process encrypts data]
C2 --> B2[Network card]
end
Why encryption changes the picture
When a connection is encrypted with TLS, the broker must encrypt the data before sending it, and that work happens inside the Kafka process. The data can no longer flow directly from the cache to the network card, so the zero-copy shortcut is lost, and the broker spends much more CPU per byte served. On a busy cluster, enabling TLS can noticeably reduce the maximum throughput per broker and increase CPU usage.
This is not an argument against encryption. It is an argument for planning capacity with encryption included. Test your cluster with TLS turned on, size CPU generously, and choose modern hardware with cryptographic acceleration, instead of discovering the cost after going live.
Advantages of Plaintext Serving
- Uses zero-copy, so CPU use is very low
- Highest throughput per broker
- Simple to configure
Costs of Encrypted Serving
- Loses zero-copy, so CPU use per byte rises
- Lower maximum throughput per broker on the same hardware
- Needs more brokers or stronger CPUs for the same load
- Still essential for protecting data on untrusted networks
Handing over a sealed parcel from the warehouse door to the lorry is quick. Handing over a parcel that first has to be opened, locked in a security case, and then loaded takes more staff and more time. The security is worth it, but you need enough staff for the extra step.
6Choosing Disks: Types, RAID, and Cloud Volumes
There is no single best disk. The right choice depends on your workload, budget, and failure plan.
Hard drives versus solid state drives
| Question | Spinning Hard Drives | Solid State Drives and NVMe |
|---|---|---|
| Sequential throughput | Good for a few streams | Excellent |
| Many partitions at once | Suffers, because access becomes random | Handles it well |
| Lagging or replaying consumers | Slow, high delay | Fast, small delay |
| Cost per terabyte | Low | Higher |
| Recovery and rebuild speed | Limited by disk speed | Limited more by the network |
| Best for | Large, cheap retention with modest partition counts | Latency-sensitive, high partition count, or replay-heavy workloads |
Because Kafka writes sequentially, spinning drives can perform surprisingly well for simple, high-volume workloads with a manageable number of partitions. But as partition counts and replays grow, solid state drives give far more comfortable headroom, and many teams choose them for that reason. The best answer is the one you confirm with a realistic load test on your own hardware.
JBOD versus RAID
A broker can be given several directories for its data, each on a different physical disk. This arrangement, often called JBOD, meaning just a bunch of disks, lets Kafka spread partitions across the disks. Alternatively, disks can be combined into a RAID set, so the operating system presents one big volume.
| Approach | How It Works | Strengths | Weaknesses |
|---|---|---|---|
| JBOD, several data directories | Each partition lives entirely on one disk, and Kafka spreads partitions across disks | Uses all disk capacity, no RAID overhead, simple hardware | Uneven fill is possible, a failed disk takes its partitions offline, and tooling for moving partitions between disks matters |
| RAID 10 | Mirrored and striped disks | Survives single disk failure without broker-level recovery, good performance | Uses half the raw capacity |
| RAID 5 or 6 | Parity-based redundancy | Better capacity efficiency | Write penalty and slow rebuilds, poor fit for Kafka’s write-heavy pattern |
| RAID 0 | Striping with no redundancy | Maximum performance and capacity | Any disk failure loses the whole volume |
Modern Kafka can keep running when one of several data directories fails, moving leadership away for the affected partitions, as long as those partitions have other replicas. Support for multiple data directories has matured over versions and differs between clusters using ZooKeeper and those using the newer metadata quorum, so confirm how your version behaves before choosing a layout.
Local disks versus network storage
Kafka expects fast, low-latency, local-style storage. Network file systems such as those shared over a file-sharing protocol are a well-known trap: they add latency, can behave unpredictably under load, and are generally not recommended. In the cloud, block volumes attached over the network are widely used and work well, but they share bandwidth with other traffic on some instance types, and their performance depends on the volume type and configured throughput. Local instance storage is very fast but disappears if the machine is stopped, which is acceptable only because replication can rebuild the data.
On-premises dedicated servers
Often use many local disks in JBOD or RAID 10, with careful capacity planning and spare disks on hand.
Cloud with network-attached volumes
Choose a volume type and size that deliver the throughput you need, and check whether volume traffic competes with network traffic on the chosen instance type.
Cloud with local NVMe instance storage
Delivers excellent speed and low latency, and relies on replication to rebuild data if an instance is lost or stopped.
Storing goods in a warehouse next door is fast and predictable. Storing them in a warehouse across town, reached by a shared road, can work if the road is wide and quiet, but it becomes unpredictable when the road is busy.
7Filesystem and Operating System Settings
A well-chosen disk can still be crippled by careless operating system settings.
Filesystem Choice
A modern journaling filesystem such as XFS is commonly recommended for Kafka’s data directories, and ext4 is also widely used. Avoid unusual or network filesystems.
No Access-Time Updates
Mounting the data volume without recording file access times avoids pointless extra writes every time a file is read.
Low Swappiness
Setting the swap tendency very low tells the operating system to avoid pushing the Kafka process’s memory out to disk, which would cause dramatic pauses.
Dirty Page Limits
Settings that control how much unwritten data may pile up in memory before the system writes it out influence write smoothness and how large a burst of disk activity can become.
Open File Limit
Each segment and index is a file, and each network connection is a file descriptor. The default limit is far too low for a busy broker and must be raised considerably.
Memory Map Limit
Kafka maps index files into memory, and clusters with many partitions and segments can exceed the default limit on memory mappings, causing mysterious failures.
Memory: heap versus page cache
Give the Kafka process a moderate Java heap, generally a few gigabytes, since it does not need to hold the data itself. Leave the rest of the machine’s memory to the operating system for the page cache. As a rule of thumb, the more of your active data, meaning the last several minutes to hours of writes, that fits in the page cache, the fewer disk reads your consumers cause.
Estimate the hot data window
Decide how far behind typical consumers might be, for example thirty minutes, and estimate the data written in that period.
Compare it with free memory
Check how much memory remains for the page cache after the Java heap and other processes, and how that compares with the hot data volume per broker.
Watch disk reads under normal load
If caught-up consumers cause steady disk reads, the cache is too small for the workload, or lagging clients are pushing data out.
Running other memory-hungry or disk-heavy programs on the same machine competes with Kafka for the page cache and disk bandwidth. Dedicated machines, or strong resource isolation, keep Kafka’s behaviour predictable.
Separate disks for cluster metadata
The component that stores cluster metadata, whether ZooKeeper in older setups or the controller’s metadata log in newer ones, is sensitive to disk latency. Placing it on its own low-latency disk, separate from busy data directories, prevents heavy data traffic from delaying critical cluster decisions.
8Sizing Disk Capacity
A simple formula gives a solid first estimate. The art lies in the headroom.
The basic formula
The total disk space needed across the cluster is the data written per second, multiplied by how long you keep it, multiplied by the number of copies, and then divided by the fraction of each disk you are willing to fill. Every part of this formula matters.
Write Rate
The data that producers send per second, measured after compression, since brokers store compressed batches.
Retention Time
How long data is kept, converted to seconds, for example three days is 259,200 seconds.
Replication Factor
The number of copies, since every copy consumes disk space on some broker.
Headroom
The share of each disk you keep free, for growth, spikes, compaction, and recovery. Many teams aim to stay below about sixty to seventy percent full.
A worked example
Start with the write rate
Suppose producers send twenty megabytes per second on average, after compression.
Multiply by retention
Three days is 259,200 seconds. Twenty megabytes per second times 259,200 seconds is about 5.2 terabytes of data for one copy.
Multiply by the replication factor
With three copies, the cluster stores about 15.5 terabytes in total.
Add headroom
If you want disks no more than seventy percent full, divide by 0.7. The cluster needs roughly 22 terabytes of raw disk.
Divide across brokers, with room for failure
With six brokers, that is about 3.7 terabytes each. Check that if one broker is lost, the other five can hold the extra data they would take on during recovery.
flowchart TD
A[Write rate per second] --> M[Multiply]
B[Retention in seconds] --> M
C[Replication factor] --> M
M --> D[Total data stored]
D --> E[Divide by the usable fraction of each disk]
E --> F[Raw disk needed across the cluster]
F --> G[Split across brokers with failure headroom]
Things the formula does not show
Growth
Traffic usually grows. Plan for the volume you expect in a year, not just today, and decide how you will add capacity before you run out.
Peaks versus averages
A daily or seasonal spike can multiply the write rate for hours. Size for peaks, or at least confirm the disks can absorb a burst.
Uneven distribution
If some partitions are much bigger than others, some brokers fill faster than the average suggests. The fullest disk, not the average, is what fails.
Compaction overhead
Compacted topics need extra working space while cleaning, and hold data for as long as keys are live, not for a fixed retention time.
Index and metadata files
Indexes add a small percentage on top of the data itself, and partition counts can make this noticeable.
Kafka does not handle a completely full disk gracefully. The affected data directory may go offline, partitions may become unavailable, and recovery can be messy. Alert well before the danger zone, for example at sixty and seventy-five percent, and treat higher readings as incidents.
A warehouse manager never plans to fill every shelf to the ceiling. They keep aisles clear so forklifts can move, and space for unexpected deliveries. A warehouse packed to one hundred percent cannot function at all.
9Retention, Segments, and Tiered Storage
The rules that decide how long data stays on disk shape both cost and behaviour.
Time-based and size-based retention
Kafka can delete old data based on age, based on the size of a partition, or on both. Whichever limit is reached first triggers deletion. Setting a size limit is a useful safety net, because it guarantees that even an unexpected traffic explosion cannot fill a disk forever, though it may cause data to be deleted earlier than the time limit suggests.
Segments and when deletion actually happens
Kafka deletes only closed segments, never the active one. So data older than the retention limit may remain on disk until the segment containing it is closed and then checked. If segments are very large, or a low-traffic partition takes a long time to fill one, old data can linger far past the nominal retention time. Segment size and roll time settings therefore affect how promptly disk space is reclaimed.
| Segment Size Choice | Advantages | Disadvantages |
|---|---|---|
| Small segments | Retention is enforced more precisely, and deletion frees space sooner | Many more files, higher file handle use, and more overhead on restart and recovery |
| Large segments | Fewer files and less overhead | Old data lingers longer, and each deletion and recovery step handles bigger chunks |
Compacted topics
For topics that keep only the latest value per key, a background cleaner rewrites segments, discarding older values. This uses extra disk input and output, and needs temporary space. The cleaner works on the older, closed portion of the log, and it competes with normal traffic for disk capacity, so heavily compacted workloads need extra disk headroom and enough cleaner threads to keep up.
Tiered storage
Newer Kafka versions support tiered storage, where recent data stays on the broker’s local fast disks, and older segments are moved to cheaper remote storage such as an object store. Consumers can still read the older data, transparently. This decouples how long you can keep data from how much local disk each broker has, and it shortens recovery, because a rebuilt broker only needs to copy the recent local portion.
Advantages of Tiered Storage
- Long retention without huge local disks
- Lower storage cost per terabyte
- Much faster broker recovery and reassignment
- Easier scaling of compute and storage separately
Trade-offs to Consider
- Reads of old data are slower than local reads
- Adds a dependency on the remote storage service
- Feature maturity and restrictions depend on your Kafka version
- Extra monitoring and cost for remote requests and transfer
Tiered storage has moved from early access to wider availability across recent releases, and some features and topic types have had restrictions. Confirm the current status and limits in the documentation for your version before relying on it in production.
A shop keeps this week’s stock on the shelves and sends older stock to a cheap storage unit across town. Customers can still order old items, but they wait a bit longer, and the shop never runs out of shelf space.
10How Data Flows Across the Network
Every event crosses the network more than once. Understanding each crossing is the key to sizing bandwidth.
Producer to leader
The producer sends each batch over the network to the broker that leads the target partition. This is inbound traffic for that broker.
Leader to followers
Each follower fetches the data from the leader. With a replication factor of three, every byte is sent out twice by the leader, and received by two other brokers.
Leader to consumers
Every consumer group that reads the topic fetches its own full copy of the data from the leaders. Ten independent groups reading the same topic means ten times the outbound data.
Extra traffic from maintenance
Partition reassignments, broker recoveries, and mirroring to other clusters add further traffic on top of the steady flow.
flowchart LR
P[Producers] -->|1 unit in| L[Leader broker]
L -->|1 unit out| F1[Follower 1]
L -->|1 unit out| F2[Follower 2]
L -->|1 unit out| G1[Consumer group A]
L -->|1 unit out| G2[Consumer group B]
Teams often size the network by the producer rate alone, and are startled when the outbound traffic is many times larger. Replication and the number of independent consumer groups multiply the traffic, and this multiplier is usually the largest factor in bandwidth needs.
A single newspaper edition printed at the press is one unit of work. But delivering it to two backup warehouses and to ten different distributors multiplies the lorry trips, even though the press printed only one copy.
11Sizing Network Bandwidth
Simple arithmetic tells you how much network you need, and how much headroom to add.
The traffic formulas
Total Inbound to Brokers
The producer rate multiplied by the replication factor, since producers write once and followers replicate the remaining copies.
Total Outbound from Brokers
The producer rate multiplied by the sum of two things: the replication factor minus one, and the number of consumer groups reading in real time.
Per Broker Traffic
Divide the totals by the number of brokers, assuming even distribution, and then check the busiest broker rather than the average.
A worked example
Inputs
Producers send fifty megabytes per second in total. The replication factor is three, and three consumer groups read the data as it arrives. The cluster has six brokers.
Inbound total
Fifty times three gives 150 megabytes per second arriving at brokers, counting both producer traffic and replication traffic.
Outbound total
Replication sends out two copies, and three consumer groups each receive one copy, so five times fifty gives 250 megabytes per second leaving brokers.
Per broker, on average
Divided by six brokers, that is 25 megabytes per second inbound and about 42 megabytes per second outbound for each broker.
Compare with the network card
A one gigabit link carries at most about 125 megabytes per second in theory, and realistically a little less. The load looks comfortable, but it must also cope with peaks, failures, and recovery.
| Link Speed | Approximate Theoretical Ceiling | Typical Use |
|---|---|---|
| 1 gigabit per second | About 125 megabytes per second each way | Small clusters, development, low volume |
| 10 gigabits per second | About 1.25 gigabytes per second each way | Common for production clusters with moderate to high volume |
| 25 gigabits per second and above | About 3 gigabytes per second each way and above | Very high throughput clusters and many consumer groups |
Headroom for failures
The steady state numbers are only the starting point. When one broker fails, its partitions’ leaders move to other brokers, so the survivors take on extra client traffic. When it returns, or when a replacement joins, a large volume of catch-up replication begins. A common guideline is to keep steady-state network utilisation at around half of capacity or below, so that failures and recoveries do not push the network into saturation.
Network cards are usually full duplex, with separate capacity in each direction, but Kafka brokers often send more than they receive because of fan-out to consumers. Check the busier direction, which is usually outbound, when judging whether a broker is near its limit.
A road that is half full at rush hour has room for an ambulance to get through and for extra traffic when a lane closes. A road that is ninety percent full at rush hour is one accident away from standstill.
12Compression and Batching
The cheapest way to add capacity is often to send fewer bytes.
Kafka producers can compress batches of records before sending them. The compressed batch travels over the network, and the broker stores it on disk as it is, without decompressing. Consumers decompress it when they read. So compression reduces network use on the producer link, on the replication links, on the consumer links, and disk space, all at the same time, at the cost of some CPU on producers and consumers.
| Compression Type | Compression Ratio | CPU Cost | Best For |
|---|---|---|---|
| None | None | None | Already compressed data, or very small volumes |
| Snappy | Moderate | Low | Balanced speed and size for general use |
| LZ4 | Moderate | Very low | Speed-sensitive workloads |
| Zstandard | High | Moderate | Network or disk constrained clusters that can spare CPU |
| Gzip | High | High | Rarely the best modern choice, but widely supported |
Batching makes compression work
Compression works on batches, and larger batches compress better because there are more repeated patterns to exploit. Producers gather records for a short time, controlled by a linger setting, and up to a size limit, before sending. A small wait and a larger batch size usually improve throughput and compression at the price of a tiny additional delay per record.
Compress on the producer
Let the producer do the compression, so the CPU cost is spread across many clients instead of concentrated on the brokers.
Keep the broker’s compression setting compatible
If the topic is set to recompress with a different algorithm than the producer used, the broker must decompress and recompress every batch, wasting CPU. Letting the topic keep whatever the producer chose avoids this.
Increase batch sizes and add a small linger time
Give the producer a moment to build fuller batches, which improves compression and reduces the number of requests.
Measure real compression ratios
Test with real data. Text and JSON often compress very well, while already compressed formats such as images and encrypted payloads barely compress at all.
Because the compressed form is what is stored, replicated, and delivered, a two to one compression ratio effectively doubles disk capacity and cuts network traffic in half across the whole data path. It is one of the most valuable tuning steps available.
Vacuum-packing clothes before loading a lorry means more clothes fit in the lorry, on the road, and in the warehouse. The only cost is the effort of packing and unpacking at the two ends.
13Threads, Buffers, and Network Tuning
Inside the broker, a few settings control how efficiently network requests are handled.
The request pipeline
A broker handles requests through a small pipeline. Network threads accept connections and read and write bytes on the sockets. Requests are placed in a queue, and a separate pool of input and output threads processes them, doing the actual log work. Responses are queued back to the network threads to be sent. If either pool of threads is too small for the load, requests wait in queues and latency climbs, even though CPU and disk may look fine.
flowchart LR
A[Client connections] --> B[Network threads]
B --> C[Request queue]
C --> D[IO threads process requests and touch the log]
D --> E[Response queue]
E --> B
B --> A
Network Threads
Handle socket reading and writing. Increase when the idle percentage of the network threads is persistently low, for example with many connections or heavy encryption.
IO Threads
Process requests and perform disk work. Often scaled with the number of disks and cores when the request handler idle percentage is low.
Replica Fetchers
The number of threads each broker uses to fetch data from other brokers. More fetchers help followers keep up on busy brokers with many partitions.
Socket Buffer Sizes
Control how much data can be in flight on a connection. Larger buffers help on high-latency, high-bandwidth links, such as between distant data centres.
Message and Fetch Size Limits
Limits for the largest message, the largest fetch, and the largest request. They must be consistent across producers, brokers, and consumers, or large messages will be rejected or stuck.
Operating System TCP Settings
Kernel limits on network buffers and window scaling determine whether Kafka’s socket settings can actually be used at full size.
The bandwidth-delay idea
On a long-distance link, the amount of data that needs to be in flight to keep the pipe full equals the bandwidth multiplied by the round-trip time. If the buffers are smaller than that amount, the sender pauses and waits for acknowledgements, and throughput falls far below the link’s capacity. This is why replication or mirroring across regions often needs larger buffers than traffic inside one data centre.
Network tuning is easy to overdo. Change a setting, measure the effect on real workloads, and keep a record. Random simultaneous changes make it impossible to know what helped and what hurt.
A long, wide motorway with a slow toll booth at the entrance never reaches its capacity. Sending more cars per minute needs more toll lanes and bigger car parks at the ends, not a wider motorway.
14Listeners, Network Separation, and Advertised Addresses
How a broker presents itself on the network causes many mysterious connection problems.
Listeners
A broker can accept connections on several listeners, each with its own address, port, and security protocol. A common design has one listener for client applications and a separate one for traffic between brokers. This allows the inter-broker traffic to travel on a dedicated network interface or a private network, so that a burst of client traffic cannot starve replication, and so that the two can have different security settings.
flowchart LR
A[Client applications] -->|client listener| B[Broker]
B -->|inter broker listener on a private network| C[Other brokers]
Advertised addresses: the classic trap
When a client connects to any broker, it receives metadata that lists the addresses of all the brokers, and then connects directly to the specific broker leading each partition. The addresses in that metadata are the advertised addresses configured on each broker, not necessarily the address the client used first. If a broker advertises an address the client cannot reach, for example an internal name that only works inside the data centre, the client can connect initially and then fail with confusing timeouts when it tries to reach the actual partition leaders.
A client can list topics but cannot produce or consume. This almost always means the initial connection worked, but the advertised addresses in the metadata are unreachable from the client’s network. Check what each broker advertises on each listener.
| Deployment | Common Networking Challenge | Typical Approach |
|---|---|---|
| Containers and orchestrators | Internal and external names differ | Define separate listeners for internal and external clients with appropriate advertised names |
| Behind load balancers | Clients must reach a specific broker, not just any broker | Give each broker its own reachable address, and use the load balancer only for the first bootstrap contact |
| Across cloud networks or peered networks | Address ranges and name resolution differ | Ensure names resolve and routes exist from every client network to every broker |
| Hybrid on-premises and cloud | Long links and firewalls | Open the required ports between all brokers and clients, and plan for latency |
A receptionist gives you the room numbers of every department, and you walk to each one yourself. If the room numbers are from the building’s internal plan, but you are standing outside in the street with no access to the internal corridors, you can talk to the receptionist but cannot reach the rooms.
15Cloud Networking: Zones, Costs, and Nearby Reads
In the cloud, the network is not just about speed. It is also about money.
Spreading brokers across zones
To survive the loss of a data centre, brokers are usually spread across several availability zones, with replicas of each partition in different zones. This is excellent for resilience, but it means that replication traffic, and often client traffic, crosses zone boundaries. Cloud providers commonly charge for data transferred between zones, and with Kafka’s multiplication of traffic, these charges can become one of the largest lines on the bill.
flowchart TD
P[Producer in zone A] -->|writes to leader| L[Leader in zone B]
L -->|replicates across zones| F1[Follower in zone A]
L -->|replicates across zones| F2[Follower in zone C]
C[Consumer in zone A] -->|reads from nearby follower| F1
Fetching from the closest replica
Recent Kafka versions allow consumers to read from a follower replica in their own zone instead of always reading from the leader. The broker and the consumer both have to be told their location, and a replica selector picks the nearest suitable replica. This can remove most of the cross-zone traffic caused by consumers, and lowers read latency, at the cost of slightly more delay in seeing the very newest data, since followers are a fraction behind the leader.
Benefits of Nearby Reads
- Sharply lower cross-zone transfer costs
- Lower latency for consumers
- Less load on leaders
Things to Accept
- Consumers see data a fraction later than from the leader
- Needs location settings configured correctly on brokers and clients
- Producers still must write to the leader, so their cross-zone cost remains
Other cloud network points
Instance network limits
Each instance type has a network bandwidth limit, sometimes with burst credits that run out. A cluster that runs fine in a short test may slow down when burst credits are exhausted in production.
Shared bandwidth with storage
On some instance types, network-attached disk traffic shares bandwidth with ordinary network traffic, so heavy disk use reduces what is left for Kafka’s network use.
Private connectivity and internet egress
Traffic to clients over the public internet is billed and slower than private links. Keep heavy producers and consumers close to the cluster where possible.
Cross-region replication
Copying data between regions adds latency, needs larger buffers, and incurs transfer charges. Replicate only what you truly need.
When choosing a topology, estimate the monthly cross-zone and cross-region traffic using the fan-out formulas from earlier. A design that seems elegant can be surprisingly expensive.
16Recovery, Rebalancing, and Throttling
Moving and rebuilding data are the moments when disks and networks are pushed hardest.
When data must be copied in bulk
Replacing a failed broker
A new broker must copy all the partitions it is responsible for from the other replicas.
Adding brokers
New brokers start empty, and partitions must be moved to them to spread the load.
Rebalancing
Moving partitions to fix uneven disk usage or traffic hot spots.
Restart after long downtime
A broker that was down must catch up on everything it missed.
How long does a rebuild take?
The time to rebuild a broker is the amount of data it holds divided by the speed at which data can be copied. Suppose a broker holds five terabytes, and replication can safely proceed at 100 megabytes per second. Five terabytes is about five million megabytes, and dividing by 100 gives fifty thousand seconds, or nearly fourteen hours. During those hours, the cluster runs with reduced redundancy, so a second failure is more dangerous.
| Data on the Broker | Copy Speed | Approximate Rebuild Time |
|---|---|---|
| 1 terabyte | 100 megabytes per second | About 2.8 hours |
| 5 terabytes | 100 megabytes per second | About 13.9 hours |
| 5 terabytes | 500 megabytes per second | About 2.8 hours |
| 20 terabytes | 100 megabytes per second | About 55 hours |
Putting enormous amounts of data on each broker reduces the number of machines but makes every failure a long emergency. The size of a broker’s data set should be chosen with a target recovery time in mind, not just to minimise hardware.
Throttling: protecting live traffic
If a bulk copy runs at full speed, it will compete with normal client traffic for network and disk, and clients will suffer. Kafka provides replication throttles that limit the rate at which data is moved during reassignments and recovery. The right throttle is a compromise: too low, and recovery takes forever, leaving the cluster vulnerable. Too high, and users notice slowness.
Estimate spare capacity
Look at how much network and disk bandwidth remains during normal peak load.
Set a throttle below that spare capacity
Leave a safety margin so client traffic keeps priority, and start conservatively.
Watch client latency and follower lag during the move
If clients slow down or in-sync sets shrink, lower the throttle. If everything is calm, consider raising it.
Remove the throttle when done
A leftover throttle silently slows normal replication later, which can cause followers to lag and leave the in-sync set.
Rather than moving hundreds of partitions at once, move them in batches, and confirm cluster health between batches. Smaller steps make problems easier to detect and easier to undo.
Moving a shop’s whole stock to a new building during opening hours needs a plan. If all the staff carry boxes at once, customers get no service. If only one person carries boxes, the move takes a month. A sensible plan assigns a fixed number of movers so customers are still served.
17Failure Modes: Full Disks, Slow Disks, and Network Trouble
Knowing how things typically fail makes them much easier to diagnose.
| Failure | Typical Symptoms | Common Causes | First Response |
|---|---|---|---|
| Disk nearly full | Rising usage alerts, then write errors and offline data directories | Traffic growth, retention too long, deletion not keeping up, uneven partitions | Free space fast by lowering retention on big topics, then add capacity and rebalance |
| Slow disk | High write latency, followers dropping out of in-sync sets, producer timeouts | Failing hardware, noisy neighbours, exhausted cloud volume limits, RAID rebuild | Check disk latency and throughput graphs, move leadership away, replace or upgrade the disk |
| Failed disk | Errors in logs, a data directory offline | Hardware failure | Confirm partitions have other healthy replicas, replace the disk, and let replication rebuild |
| Saturated network | Growing latency, replication lag, client timeouts | Traffic growth, too many consumer groups, recovery traffic, encryption overhead | Identify the biggest flows, apply throttles or quotas, add capacity |
| Network partition | Brokers cannot reach each other or clients, sudden in-sync set shrinkage | Switch or routing failure, firewall change, cloud network issue | Restore connectivity, then check for under-replicated partitions and data divergence |
| Packet loss or flaky links | Intermittent timeouts, retries, unstable throughput | Faulty cables or interfaces, overloaded switches | Check interface error counters and test the path between brokers |
| Cache thrashing | High disk read rate even for caught-up consumers | Lagging consumers replaying old data, too little memory for the page cache | Identify replaying consumers, throttle them, or add memory |
The cascade to avoid
One slow disk can start a chain reaction. Its broker’s followers fall behind and leave the in-sync sets. Producers requiring several in-sync replicas may then be rejected. The remaining brokers take over leadership, receiving extra traffic and possibly saturating. If recovery is then started without throttling, the network and disks are pushed even harder. Understanding this chain helps you interrupt it early, for example by shifting leaders away from a sick broker before it drags others down.
flowchart TD
A[One disk becomes slow] --> B[Followers on that broker lag]
B --> C[Replicas leave the in sync sets]
C --> D[Fewer replicas confirm writes]
D --> E[Producers slow down or see errors]
C --> F[Leaders shift to other brokers]
F --> G[Other brokers take extra load]
G --> H[Wider slowdown if not addressed]
One slow checkout counter makes its queue grow, and shoppers move to the other counters, which then slow down too. The trouble spreads unless the shop opens a spare counter, or the faulty one is closed quickly.
18Monitoring and Alerting
You cannot manage what you cannot see. These signals show the health of disks and networks.
| Signal | Where It Comes From | What It Tells You |
|---|---|---|
| Disk usage percentage per data directory | Host metrics | How close each disk is to being full. Alert early, and track the fullest disk. |
| Disk read and write throughput and operations | Host metrics | How busy the disks are, and whether reads suggest cache misses |
| Disk wait time and utilisation | Host metrics | Whether disks are a bottleneck, and how slow they are |
| Network throughput in and out per broker | Host and broker metrics | How close each broker is to link capacity |
| Network errors, drops, and retransmissions | Host metrics | Faulty links or congestion |
| Bytes in and bytes out rates per broker and per topic | Broker metrics | Which topics drive traffic, and how it is distributed |
| Replication bytes in and out | Broker metrics | The cost of replication, and whether recovery is running |
| Request handler and network processor idle percentages | Broker metrics | Whether thread pools are too small or the broker is overloaded |
| Request latency breakdown | Broker metrics | Where time is spent: queueing, local work, waiting for followers, or sending the response |
| Under-replicated and offline partitions | Broker metrics | Early warning of slow followers or failed disks |
| Consumer lag per partition | Consumer group tools | Who is falling behind, and who might soon cause disk reads |
| Open file descriptors | Host metrics | Approaching the limit, which causes sudden failures |
Alerts that give you time to act
Disk fullness in stages
Warn at a comfortable level, escalate at a higher level, and page at a critical level. Also alert on how fast the disk is filling, because a steep rise gives less time than a slow one.
Network utilisation trending toward the ceiling
Alert when sustained utilisation passes your headroom target, not when it hits one hundred percent.
Imbalance between brokers
Alert when one broker’s disk usage or traffic is far above the cluster average, since averages hide the broker that will fail first.
Disk latency rising
Rising latency often precedes visible Kafka problems by hours or days, giving you time to move traffic and replace hardware.
Thread pool idle percentages dropping
Low idle values show the broker is running out of request processing capacity.
Store several months of history for disk usage, traffic, and lag. Trend lines let you forecast when you will run out of capacity and order hardware before it becomes an emergency.
19Quotas and Protecting Shared Clusters
When many teams share one cluster, one noisy client can hurt everyone. Quotas keep the peace.
Kafka lets administrators set quotas on clients, identified by user, client identifier, or both. A producer byte-rate quota limits how much data a client may send per second. A consumer byte-rate quota limits how much it may fetch. A request quota limits how much processing time a client may consume. When a client exceeds its quota, the broker slows down its responses rather than rejecting requests, so the client is gently throttled.
Producer Rate
Limits inbound bytes per second, protecting disk and network from a runaway producer.
Consumer Rate
Limits outbound bytes per second, protecting against a replaying consumer that would flood the network and churn the page cache.
Request Time
Limits the share of broker processing capacity that a single client can consume.
Replication Throttles
Separate limits for broker-to-broker traffic during recovery and reassignments, as discussed earlier.
A backfill job that replays a month of data
Without a consumer quota, it reads at full speed from disk, evicting cached data and slowing every other reader. With a quota, it takes longer but does not disturb anyone.
A misconfigured producer in a loop
Without a producer quota, it can flood a partition and fill disks. With a quota, its damage is limited until someone fixes it.
Quotas added during an emergency are stressful and easy to get wrong. Define sensible default quotas per client class in advance, and adjust them per application as real needs become clear.
A shared swimming pool has lane rules so that one enthusiastic swimmer cannot take over every lane. The rules are not about distrust. They are what allow many people to enjoy the pool at once.
20Design Patterns and Anti-Patterns
A few habits keep clusters healthy, and a few habits quietly build up trouble.
Helpful patterns
Size for the failure case
Choose capacity so that the cluster stays healthy with one broker, or one zone, down and recovering.
Compress at the producer
Use an efficient algorithm and healthy batching to cut network and disk needs at the same time.
Leave memory for the page cache
Keep the Java heap moderate and give the rest to the operating system.
Throttle and batch bulk moves
Protect live traffic during recoveries and rebalances, and always remove throttles afterwards.
Anti-patterns to avoid
Problem
The team runs disks at ninety percent full to save money, with no alerting until the disk is nearly full.
Why It’s Harmful
A traffic spike, a stuck retention cleanup, or a recovery can push a disk to one hundred percent within hours. The broker’s data directory may then go offline and partitions become unavailable.
Correct Approach
Keep usage comfortably below sixty to seventy percent, alert in stages, and use size limits on topics as a safety net.
Problem
Storing Kafka data on a network file system or a shared file server.
Why It’s Harmful
Latency is high and unpredictable, locking and caching behaviour can corrupt assumptions Kafka makes, and one file server becomes a single point of failure for the entire cluster.
Correct Approach
Use local disks or well-provisioned block volumes, and rely on Kafka’s replication for redundancy.
Problem
Giving the Kafka process a huge Java heap on the belief that more memory means more speed.
Why It’s Harmful
The heap steals memory from the page cache that Kafka depends on, and very large heaps invite long garbage collection pauses that make brokers look dead to the cluster.
Correct Approach
Use a moderate heap and leave most memory for the page cache.
Problem
Sizing the network by producer throughput alone.
Why It’s Harmful
Replication and multiple consumer groups multiply outbound traffic several times over. The network saturates while producer numbers look modest.
Correct Approach
Calculate inbound and outbound totals with the replication factor and the number of consumer groups, and add headroom for failures.
Problem
Running an unthrottled partition reassignment during peak hours.
Why It’s Harmful
The bulk copy floods the network and disks, followers and clients slow down, and in-sync sets shrink, turning a maintenance task into an incident.
Correct Approach
Apply a replication throttle, move partitions in small batches, watch client latency, and remove the throttle afterwards.
Problem
Putting tens of terabytes on every broker to minimise the number of servers.
Why It’s Harmful
Each failure triggers a rebuild lasting days, during which redundancy is reduced. Rebalancing and expansion also become painfully slow.
Correct Approach
Pick a per-broker data size that supports your target recovery time, consider tiered storage for long retention, and add brokers instead of stretching disks.
Problem
Leaving default operating system limits for open files and memory mappings on busy brokers.
Why It’s Harmful
As partitions and segments grow, the broker suddenly hits a limit and fails with confusing errors, often at the worst time.
Correct Approach
Raise these limits as part of the standard broker build and monitor usage against them.
21Real-World Sizing Scenarios
Different workloads stress disks and networks in different ways.
Log collection for an application fleet
High volume, short retention, and a few consumers. Write throughput dominates. Compression pays off enormously, since logs are text. Disks can be modest in size but must sustain steady writes, and the network is mostly inbound.
Financial event streaming
Moderate volume but strict durability and low latency. Solid state drives, ample headroom, careful zone spreading, and generous network capacity for replication across zones are the priorities.
Analytics fan-out with many consumer groups
Modest ingest, but a dozen teams each read everything. The outbound network is the bottleneck, so consider reading from nearby replicas, quotas for heavy readers, and perhaps a separate cluster for analytics.
Change data capture with long retention
Compacted topics hold state for a long time. Disk capacity and cleaner capacity matter more than raw network speed, and tiered storage may reduce cost for the older data.
IoT with bursty ingestion
Millions of devices send short messages, often in synchronised bursts. Batching and compression, connection handling capacity on network threads, and disk headroom for spikes all need attention.
Replay-heavy machine learning pipelines
Training jobs read months of history repeatedly, causing heavy disk reads and cache churn. Separate clusters, tiered storage, and consumer quotas protect real-time workloads.
Cross-region replication hub
Data from several regions flows into a central cluster over long-distance links. Larger socket buffers, compression, and careful throttling matter, and transfer costs must be budgeted.
22A Troubleshooting Journey
Let us follow a realistic incident from the first alert to a lasting fix.
A company runs a six-broker cluster serving many applications. On a Monday morning, producers start timing out and several consumer groups report growing lag. Nothing was deployed over the weekend.
Look for the pattern across brokers
Dashboards show that five brokers are calm, but one broker has very high disk wait times and network traffic well above the rest. The problem is concentrated, not cluster-wide.
Check which partitions live there
That broker leads a large share of the busiest partitions. Several other brokers show under-replicated partitions, because their followers of those partitions are struggling to fetch from it.
Find the source of the extra reads
Disk reads on the sick broker are unusually high even though most consumers are caught up. A batch analytics job started at the weekend, replaying two weeks of data from those partitions, is pulling old segments from disk and evicting fresh data from the page cache.
Relieve the pressure quickly
The team applies a consumer byte-rate quota to the replaying job, immediately lowering the read load. They also move leadership of some busy partitions to quieter brokers.
Confirm recovery
Disk wait times fall, followers catch up and rejoin the in-sync sets, and producer timeouts disappear. Consumer lag drains over the next hour.
Fix the underlying causes
They set default consumer quotas for all batch clients, rebalance partitions so that busy leaders are spread evenly, add alerts on per-broker disk latency and imbalance, and agree that large replays must run against a separate analytics cluster or tiered storage.
The lesson is that the trigger was not a hardware fault, but an interaction between one heavy reader, the page cache, and an uneven spread of busy leaders. Looking at the pattern across brokers, and understanding how reads reach the disk, led directly to the cause.
23Frequently Asked Questions
Because it writes sequentially by appending to files, and serves most reads from the operating system’s page cache. Sequential access is fast even on spinning drives, and cached reads avoid the disk altogether.
Not by default. Writes go into the page cache and the operating system flushes them later. Durability comes from replication across brokers and from producers requiring acknowledgement from enough replicas.
A moderate Java heap, typically a few gigabytes, and leave the rest of the machine’s memory for the operating system’s page cache, which does most of the caching work.
Hard drives can work for simple, high-volume workloads with modest partition counts. Solid state drives give far better headroom for many partitions, lagging or replaying consumers, and fast recovery. Test with your own workload.
Not necessarily, because Kafka replicates data across brokers. Many clusters use several separate disks, while some use RAID 10 to tolerate a disk failure without rebuilding a whole broker. Avoid parity RAID because of its write penalty.
Multiply the write rate by the retention time in seconds and by the replication factor, then divide by the fraction of each disk you are willing to fill, usually around sixty to seventy percent. Add growth, peaks, and room for a broker failure.
Inbound to brokers is the producer rate times the replication factor. Outbound is the producer rate times the sum of replication factor minus one and the number of real-time consumer groups. Keep steady utilisation around half of capacity to allow for failures and recovery.
Encryption forces data through the broker process, so Kafka can no longer use zero-copy to send data directly from the cache to the network card. CPU use rises, so plan capacity with encryption enabled.
The affected data directory can go offline, partitions on it become unavailable on that broker, and the broker may fail. Recovery is difficult, so alert early and keep generous free space.
Kafka deletes only closed segments. Data in the active segment, or in a large segment that has not yet been closed and checked, can remain beyond the nominal retention time.
Enable consumers to fetch from a replica in their own zone, use compression, limit unnecessary consumer groups and replication, and keep heavy clients near the cluster. Producers still write to leaders, so some cross-zone traffic remains.
The initial connection works, but the advertised addresses in the broker metadata are not reachable from the client’s network. Check the advertised addresses for each listener.
The data on the broker divided by the replication speed. Five terabytes at 100 megabytes per second takes nearly fourteen hours. Smaller per-broker data sets, faster networks, and tiered storage shorten recovery.
It limits the bandwidth used to move data during reassignments and recovery, so bulk copying does not starve normal client traffic. Remember to remove it afterwards so normal replication is not held back.
Plan capacity for the failure case, with generous headroom on both disks and network, and monitor trends per broker instead of cluster averages, so problems are found and fixed before they become outages.
24Summary and Key Takeaways
Kafka’s speed comes from a simple design: sequential appends to log segment files, reliance on the operating system’s page cache, and zero-copy transfers to consumers. That design makes disk and network the two resources that most often limit a cluster. Disks must be large enough to hold the write rate, retention, and replication with generous headroom, and fast enough to handle many partitions and lagging readers. Networks must carry the multiplied traffic of replication and many consumer groups, with room left for failures and recovery.
Good results come from choosing sensible hardware and operating system settings, keeping the Java heap moderate, compressing at the producer, separating client and replication traffic where useful, and paying attention to cloud costs and advertised addresses. Bulk data moves should be throttled and done in batches, quotas should protect shared clusters, and monitoring should watch per-broker disk, network, and latency trends. Above all, plan for the bad day: a cluster that still works with one broker down and recovering is a cluster you can trust.
Key Takeaways
- Disk and network are the usual limits — Kafka does little except move bytes between the network and log files, so these two resources decide throughput, latency, and recovery time.
- Let the page cache do the work — keep the Java heap moderate, leave memory for the operating system, and remember that lagging or replaying consumers force disk reads and can evict fresh data.
- Size disks with the full formula — write rate times retention times replication factor, divided by the usable fraction of each disk, with room for growth, peaks, compaction, and one broker’s failure.
- Size the network for fan-out — inbound is the producer rate times the replication factor, outbound adds every real-time consumer group, and steady utilisation should leave about half the capacity free for failures.
- Compression helps everywhere at once — compressing at the producer with healthy batching reduces network traffic, replication traffic, and disk use together, while TLS removes zero-copy and needs extra CPU planning.
- Recovery time is a design input — big brokers mean long rebuilds, so choose per-broker data sizes with a recovery target, use throttles and small batches for bulk moves, and consider tiered storage for long retention.
- Monitor per broker and alert early — track disk fullness, disk latency, network use, thread idle percentages, and lag trends per broker, and use quotas to stop one noisy client from harming everyone else.