System Design · Concept Library · Free article
Kafka: The Distributed Commit Log
Kafka is a durable, replayable log that sits between the services that write events and the services that read them, so neither has to wait for the other. Topics split into ordered partitions, consumer groups read them in parallel, and replication keeps them safe when a broker dies.
Kafka is one idea taken very seriously: an append-only log you can’t edit, split into ordered pieces, copied across machines, and kept around long enough to read again. Producers append records to the end; consumers read forward at their own bookmark (an offset) and the record stays put — so ten different readers, or the same reader tomorrow, all see the same history. A topic is sharded into partitions (the unit of both ordering and parallelism), each partition is replicated across brokers for durability, and a message’s key decides which partition it lands on — which is the single most important design choice you make, because it sets both your ordering guarantee and where your load piles up. Everything else on this page — acks, consumer groups, exactly-once, retention, hot partitions — hangs off those few facts. Get them, and Kafka stops being a black box.
The redirect can’t wait for the write — so where do the clicks go?
Back in the clicks-dashboard chapter, Hatch’s viral link — MegaDrop — melted the redirect. The cause was a single line bolted onto the fast path: every click did an UPDATE clicks = clicks + 1 before answering the user, and when fifty thousand people a second hammered the same row, the database locked up and the redirect that used to take 20 ms started taking five seconds. The async-event-emission concept gave us the move that saved it: stop doing the write inline — fire a lightweight "a click happened" event and return the redirect immediately. The counting happens later, somewhere else, out of the user’s way.
That leaves one very large question hanging: fire the event where? You need something that can swallow fifty thousand events a second without flinching, hold onto them safely even if the thing that counts them is down for a minute, let you add more counters later without losing data, and — because Marketing will inevitably want a second and third thing built on the same clicks — let several different readers consume the same stream independently. A plain database can’t do that cheaply. A simple in-memory queue drops everything if it restarts. What you want is a durable, replayable log sitting between the producers and the consumers — and the de-facto answer, the box you’ll reach for in nearly every event-driven design you’re ever asked about, is Apache Kafka.
It’s a logbook you append to and never erase
Forget "message queue" for a second, because it gives you the wrong picture. The truest one-line description of Kafka is a commit log: an ever-growing logbook where writers only ever add a new line to the bottom, and nobody is allowed to go back and change or delete a line that’s already there. Picture the arrivals board at a station, except it never scrolls anything off — every train that was ever announced is still written down, in the exact order it was announced, forever (or at least for as long as you choose to keep it).
Two properties fall straight out of that picture, and they’re the whole reason Kafka behaves the way it does. First, it’s append-only and immutable — you add to the end, you never edit the middle. That’s what makes writes so cheap (the disk head never has to hunt around; it just keeps writing forward) and what makes the data safe to copy to other machines (a copy can never disagree about a line, because lines never change). Second — and this is the part that trips people coming from ordinary queues — reading does not remove anything. When a consumer reads a record, the record stays exactly where it is. The consumer just moves its own bookmark forward. So the same record can be read by a totally separate reader, or re-read by the same reader tomorrow, as many times as you like.
Now, one logbook on one machine would be a bottleneck and a single point of failure — the exact problems we’re trying to escape. So Kafka runs as a cluster of servers, each one called a broker. A broker is nothing exotic: it’s just a machine (physical or virtual) whose job is to store some of the log and serve the clients reading and writing it. Add brokers and you can hold more data and serve more traffic. One broker in the cluster also wears a second hat as the controller — the coordinator that keeps track of which machine is responsible for which slice of data and steps in when a machine dies. You rarely talk to the controller directly; it works quietly in the background so the cluster always agrees on who owns what. In a moment you’ll see exactly how the log gets carved up and spread across these brokers.
One log is really many ordered logs, and everyone keeps their own bookmark
A topic is just a named stream — a labelled logbook. Hatch would have a clicks topic for redirect events, maybe a signups topic, a notifications topic. Producers write to a topic by name; consumers subscribe to a topic by name; the topic is the unit you think in when you design. So far, so simple. But if a topic were a single physical log, we’d be right back to one machine holding everything. So under the hood every topic is split into partitions.
A partition is where the real action is: it’s one of those append-only logs, living on one broker (with copies elsewhere, more on that later), holding a slice of the topic’s records. A clicks topic with three partitions is three independent logs that, together, are "the clicks." Splitting a topic this way buys you the two things a single log can’t give you at once:
- Parallelism — three partitions can be written and read in parallel, on three different brokers, so throughput scales with partition count instead of being capped by one machine. The partition is the unit of parallelism in Kafka — remember that line; nearly every scaling answer comes back to it.
- Ordering — but only within a partition. Kafka promises that records inside a single partition come out in exactly the order they went in. It promises nothing about order across partitions. Two clicks that land on partition 0 and partition 2 have no defined order relative to each other. This is the single most important caveat on the page, and controlling it — through the record key — is what the very next section is about.
Before we go further, get this hierarchy into your bones, because every scaling and durability answer later leans on it. Build a cluster below: add brokers, set how many partitions each topic has, and watch the partitions physically spread across the machines. Notice the two things that stick: a topic spans brokers (it’s just a name over many partitions), but each partition lives on exactly one broker — and if a topic has fewer partitions than you have brokers, some brokers sit idle for it (your first glimpse of the parallelism ceiling):
The interactive version of this example is available when JavaScript loads.
Every record in a partition gets an offset — a plain, ever-increasing integer marking its position: the first record is offset 0, then 1, then 2, and so on, per partition. The offset is how a consumer keeps its place. Instead of Kafka tracking "who has seen what" (which would mean remembering something about every reader), Kafka flips it around: each consumer remembers its own offset — "I’ve read clicks partition 0 up to offset 8,412" — and periodically writes that bookmark down (a commit) so it can pick up where it left off after a restart. Because the bookmark belongs to the reader, two readers of the same partition are completely independent: one can be racing along at the live edge while another, slower one is still catching up from an hour ago, and neither knows or cares about the other.
That’s a lot of moving parts described in words. Produce some records and watch it: the log only grows, each record gets the next offset, and each consumer group drags its own bookmark forward at its own pace. Add a second consumer group and watch it read the same records independently — the history-book property, live:
The interactive version of this example is available when JavaScript loads.
The key decides the partition — and the partition decides everything
When a producer sends a record, that record is a small envelope with a few parts. The one that carries the payload is the value — for Hatch, a little blob like { "linkId": "mega-drop", "visitorId": "v-91c…", "ts": 1712 }. Alongside it are three optional extras: a key (which we’re about to see is anything but optional in practice), a timestamp (when the event happened), and headers (key–value metadata, like HTTP headers — a trace id, a schema version). Keep the value small: Kafka is a log of events, not a filing cabinet for blobs. If you need to move a 200 MB video, put the video in object storage and send Kafka a short record that points to it — a rule we’ll come back to when we talk about what Kafka is not.
Now the decision that quietly determines your whole design: which partition does a record go to? Kafka answers it with the record’s key. It runs the key through a hash function and takes the remainder against the partition count — in shorthand, partition = hash(key) % number_of_partitions. That formula has one beautiful consequence: the same key always hashes to the same partition. Key mega-drop might always land on partition 1; key spring-sale always on partition 2. And since a partition preserves order, all events for a given key are therefore ordered. If you key Hatch’s clicks by linkId, then every click for MegaDrop is on one partition, in the exact order it happened — which is precisely the guarantee you want if a downstream consumer is folding those clicks into a running total.
Type a key and watch where it lands — same key, same partition, every time, with order preserved down each column. Then flip to no key and watch the records scatter round-robin and the per-key ordering dissolve:
The interactive version of this example is available when JavaScript loads.
The producer’s dial between "fast" and "safe": acks
When a producer sends a record, it goes to the leader of that partition — the one broker currently in charge of it (the followers, which hold copies, come in the next cluster). But here’s the thing: "I sent it" is not the same as "it’s safe." The network might drop it; the leader might crash a millisecond after receiving it but before its copies caught up. So the producer gets to choose how sure it wants to be before it considers a write done — a single setting called acks (acknowledgements), and it’s a straight trade of speed for safety.
acks=0— fire and forget. The producer sends and immediately moves on, never waiting to hear back. Fastest possible, and fine for firehose telemetry you can afford to lose a little of — but if the record never lands, you’ll never know. For Hatch’s money-adjacent events, no.acks=1— the leader has it. The producer waits until the leader has written the record, then continues. Safer, still quick. The hole: if the leader dies after acknowledging but before a follower copies the record, that record is gone — acknowledged but lost.acks=all— every in-sync copy has it. The producer waits until the leader and all its in-sync replicas have the record. Now a single broker dying can’t lose it, because another broker already has it. This is the durable setting, and the small price is a bit more latency per write. (Paired withmin.insync.replicas, it’s the backbone of Kafka’s "no data loss" story — the next cluster shows exactly why.)
You’ll get to feel the acks=all guarantee — a broker dying without losing a record — in the replication interactive next cluster, where the followers are on screen. For now, hold the dial: acks is how paranoid the producer is before calling a write done.
Consumer groups: how a topic gets read in parallel
One consumer reading a busy topic hits the same wall the redirect did — it can’t keep up. The answer is a consumer group: a set of consumers that agree to split a topic’s partitions between them. The rule is simple and strict: each partition is handed to exactly one consumer in the group. So a clicks topic with four partitions can be worked by up to four consumers at once, each owning one partition, each processing its slice in parallel — and because a partition has a single owner, every record is processed once by the group.
This is where the line from the anatomy builder pays off: the partition count is the ceiling on how many consumers can share the load. Four partitions, four consumers → a tidy one-to-one. Add a fifth consumer and it just sits idle — there’s no unowned partition to give it. Two consumers for four partitions → each carries two. Want more read parallelism than you have partitions? You can’t get it without adding partitions. (And separately: two different consumer groups each get the whole topic independently — group is the unit of "a copy of the stream," consumer is the unit of "a share of the work." The dashboard team and the fraud team read the same clicks without stepping on each other.)
When the group changes — a consumer is added, or one crashes or is deployed — Kafka runs a rebalance: it reshuffles partition ownership so every partition is covered again and no two consumers own the same one. Rebalancing is what makes the group self-healing, but it isn’t free: classically the group briefly stops consuming while it re-agrees who owns what (a "stop-the-world" pause), which is why flapping consumers or huge groups can hurt. One more design-relevant detail: Kafka is pull-based — consumers poll the broker for the next batch at their own pace, rather than the broker pushing data at them. That’s deliberate: a slow consumer can never be flooded, it simply falls behind (its lag grows), and you scale it out when you notice. Add and remove consumers below and watch partitions reassign — then push past the partition count and watch a consumer go idle:
The interactive version of this example is available when JavaScript loads.
At-least-once, at-most-once, exactly-once — it all rides on one decision
Here’s the guarantee people obsess over, and the good news is it comes down to one choice: when do you commit the offset, relative to actually doing the work? Remember, committing an offset is a consumer saying "I’m done through here, don’t send it to me again." So the whole thing hinges on whether you say that before or after you’ve finished the work — and what happens if you crash in the gap.
- At-least-once — process first, then commit. You do the work (write the click to the dashboard), then move your bookmark. Crash in between and, on restart, you re-read that record because you never committed it — so you might process it twice, but you can never lose it. This is Kafka’s default and the right default for most systems.
- At-most-once — commit first, then process. You move your bookmark the moment you read, then do the work. Crash in between and, on restart, the record is already marked done — so it’s never reprocessed, but it can be lost. Only acceptable when a dropped record is cheaper than a duplicate one (some metrics, some logs).
- Exactly-once (EOS) — make the work and the commit one atomic step. Using Kafka transactions plus the idempotent producer, the processing and the offset commit either both happen or neither does. No duplicates, no loss. The catch: this magic only holds inside Kafka (reading a topic, writing another topic + offsets together). The moment your consumer touches the outside world — charges a card, sends a text — Kafka’s transaction can’t cover it.
Pick a strategy, then crash the consumer mid-flight and see what the log does on restart — a duplicate, a lost record, or neither:
The interactive version of this example is available when JavaScript loads.
Replication, the in-sync set, and the setting that loses data
A partition that lives on one broker dies with that broker. So Kafka keeps copies — every partition is replicated to several brokers, a count called the replication factor (three is the common choice: one original plus two copies). Of those copies, exactly one is the leader — it takes all the writes and hands them to the others — and the rest are followers that do nothing but continuously copy the leader’s log, ready to step up. If the leader’s broker catches fire, a follower is promoted and the partition keeps serving without missing a beat. This is the same leader/follower shape you saw in read replicas, applied per partition.
Now we can finally cash the cheque the acks dial wrote earlier. The followers that are fully caught up to the leader form the in-sync replica set — the ISR. When you set acks=all, "all" means all the in-sync replicas: the producer’s write isn’t considered committed until every ISR member has it. That’s the whole durability guarantee in one line — a committed record lives on more than one broker, so any single broker dying cannot lose it. A companion setting, min.insync.replicas, is the floor: set it to 2 and if the ISR ever shrinks below two brokers, Kafka refuses new acks=all writes rather than accept one that isn’t safely copied. Refusing a write sounds harsh, but it’s the point — better a loud rejection than a silent loss.
Take a broker down and watch the ISR shrink, acks=all block when it’s too small, a clean promotion happen when a follower is caught up — and, if you allow it, a stale follower get promoted and drop committed records:
The interactive version of this example is available when JavaScript loads.
Retention & replay: reading doesn’t delete, but time does
We said early on that reading a record doesn’t remove it. So what does? A retention policy. Kafka keeps every record for a configured window — a duration (retention.ms, seven days by default) or a size (retention.bytes) — and only then drops the oldest ones off the tail. Everything inside that window is fully replayable, and this is the superpower a plain queue can never match:
- A brand-new consumer can read the whole history. Spin up a fresh downstream system — say Hatch adds an hourly-trends service — and it can backfill from the start of the retained log, no one has to re-send anything.
- A broken consumer can rewind and reprocess. Shipped a bug that mis-counted clicks for an hour? Fix it, reset the offset back an hour, and reprocess from the log. The events are still there.
- Multiple teams replay independently. Because each consumer group owns its offset, the dashboard team can be at the live edge while the fraud team reprocesses yesterday — same log, no coordination.
Drag the retention window and watch old records expire off the tail; then drag the consumer’s offset back to replay — and try to rewind past the retention horizon to see the data that’s already gone:
The interactive version of this example is available when JavaScript loads.
Log compaction: keep the latest value, not the whole history
Time-based retention is perfect for a stream of events (clicks happen and then they’re old news). But sometimes you don’t care about the history — you care about the latest state. Imagine a topic where each record is "user 42’s current plan is now Pro," keyed by user id. You don’t want to drop it after seven days; you want to keep the most recent value for every user forever, and throw away only the superseded older ones. That’s log compaction: instead of deleting by age, Kafka keeps at least the newest record for each key and garbage-collects the earlier duplicates. A record with a null value is a tombstone — it marks that key as deleted and is eventually cleaned away too.
The effect is that the log stops being "everything that ever happened" and becomes "the current value of everything" — a changelog you can replay to rebuild state from scratch. That’s exactly how you’d warm a cache or a search index after a restart (replay the compacted topic → you have every entity’s latest value), and it’s the machinery under change-data-capture and stream-processing state stores. Watch several updates to the same keys collapse to just the latest per key when compaction runs (note the offsets don’t renumber — compaction removes records, it doesn’t rewrite positions):
The interactive version of this example is available when JavaScript loads.
How a log on plain disks moves millions of messages a second
It surprises people that Kafka is disk-based and yet handles throughput you’d expect from a memory system. The trick is that it never fights the disk — it works the way disks are actually fast. Four choices do almost all of the work:
- Sequential writes, not random ones. Appending to the end of a file lets the disk write in one long continuous streak — no jumping around to find a spot. Sequential disk throughput is enormous (often faster than random memory access), and it’s the whole reason the append-only design isn’t just tidy but fast.
- The OS page cache does the reading. Records the producer just wrote are still sitting in the operating system’s memory cache, so a consumer reading the live edge is really reading from RAM, not spinning up the disk. Kafka leans on the OS cache instead of building its own — simpler and faster.
- Zero-copy to the network. When sending log data to a consumer, Kafka asks the kernel to move bytes straight from the page cache to the network socket, skipping the usual detour up into the application and back down. Fewer copies, less CPU, more throughput.
- Batching and compression. Producers group many records into one batch before sending, and can compress the batch (gzip, snappy, lz4, zstd). Fewer, bigger network and disk operations — and compression shrinks what crosses the wire. Throughput climbs; per-message overhead falls.
Consumer lag: is anyone falling behind?
Consumer lag is the single most important operational metric on Kafka, and it’s beautifully simple: it’s the gap between the newest offset in a partition and the offset a consumer group has committed — how many records behind the live edge you are. Lag near zero and flat means the consumer is keeping up. Lag climbing steadily means it can’t — records are arriving faster than it can process them — and if you do nothing, it will eventually fall so far behind that its next record has aged out of retention and events vanish silently. You watch lag the way you watch a fuel gauge: not because a full tank is interesting, but because the slope tells you when you’re in trouble.
When lag is climbing, you have a ladder of fixes, cheapest first: add consumers to the group — up to the partition count (the consumer-group ceiling we met earlier); if you’re already at the ceiling, add partitions so more consumers can share the work; make each consumer’s job smaller — offload heavy work, batch database writes, do less on the hot path; and, as a stopgap, slow the producer (backpressure) so you stop digging. And before any of it: do the arithmetic. A single well-provisioned broker handles on the order of a million messages a second and a terabyte of data; if your load is comfortably under that, the honest interview answer is "one broker with enough partitions is plenty — I won’t over-engineer it." Drag the produce and consume rates below and watch lag build or drain:
The interactive version of this example is available when JavaScript loads.
Failure modes & gotchas
- Hot partition. A key that’s too popular funnels all its traffic to one partition while the rest idle — a redirect for a viral link keyed by
linkIdis the classic. The fix is a better key (salt it, use a compound key) or accepting no-key spread; the whole playbook is the Hot Keys & Partition Skew pattern. - Rebalance storms. If consumers keep joining and leaving — flapping on a slow health check, or taking too long to process a batch and getting kicked — the group rebalances over and over, and each rebalance pauses consumption. Tune the poll/session timeouts, keep per-record work short, and prefer cooperative (incremental) rebalancing or static membership so a brief blip doesn’t reshuffle everyone.
- Poison messages. One record your consumer cannot process (malformed, a bug) will be retried forever and block its whole partition, because the offset never advances. Kafka has no built-in consumer retry — you build it: catch the failure, route the bad record to a dead-letter topic, and move the offset on so the partition keeps flowing.
- Unclean leader election. Covered under replication above — allowing a stale replica to lead silently drops committed records. Know the durability-vs-availability choice you’re making.
- Too many (or too few) partitions. Each partition has real cost — memory, open files, and longer leader elections when a broker dies — so tens of thousands across a cluster hurts; but too few caps your consumer parallelism. Size partitions to the throughput you actually need, with a little headroom.
When Kafka — and when something simpler
The clean mental split is log vs queue. A traditional queue is a to-do list you drain: one worker takes a message, does it, it’s gone. Kafka is a retained, replayable log many readers can share. So reach for Kafka when you need what a log gives: high throughput, replay/history, several independent consumers of the same stream, per-key ordering, or a durable buffer that absorbs bursts. If you need none of those — just a simple background job queue with retries — a plain queue is less to run and reason about.
| Tool | What it is | Reach for it when | Watch out |
|---|---|---|---|
| Kafka | Distributed, replayable commit log | High throughput, replay, many consumers, per-key ordering, event streaming | More to operate; no built-in consumer retry/DLQ; not for blobs |
| AWS SQS | Fully-managed simple queue | Straightforward async jobs; you want built-in retries + dead-letter with near-zero ops | No replay; no ordering (standard) / limited throughput (FIFO); one logical consumer |
| RabbitMQ | Traditional message broker | Flexible routing, priorities, low-latency work queues, request/reply | Not built for huge retained streams or replay; throughput below Kafka |
| AWS Kinesis | Managed log (Kafka-like) | You want Kafka’s streaming model, fully managed, deep in AWS | AWS-only; shard limits and quotas; less ecosystem than Kafka |
| Pulsar / Redpanda | Kafka-model alternatives | Pulsar: multi-tenant + tiered storage; Redpanda: Kafka API, no JVM/ZooKeeper, lower latency | Smaller communities; fewer managed options than Kafka |
A few operational notes that come up. Most teams run Kafka managed — Confluent Cloud or AWS MSK — so the scaling and patching is someone else’s job; you still need to understand partitions, keys, and acks. Modern Kafka has replaced its old ZooKeeper dependency with KRaft, where the brokers run their own metadata quorum (that controller we met at the start, now built in) — one fewer system to operate. And the ecosystem is half the reason Kafka wins: Kafka Connect (ready-made source/sink connectors to databases, S3, etc.), Kafka Streams / ksqlDB (process and aggregate the stream — the tools behind the stream-aggregation concept), and a Schema Registry to keep producers and consumers agreeing on the record shape.
Answer the questions below and see which box actually fits:
The interactive version of this example is available when JavaScript loads.
Producing, consuming, and the settings that matter
The client API is small; the configuration is where the guarantees live. Here’s a durable producer, a consumer group that commits after processing, and the handful of settings worth memorising:
The interactive version of this example is available when JavaScript loads.
The configs that carry the guarantees
acks=all+min.insync.replicas=2+ replication factor 3 — the durability trio: a committed write is on ≥2 brokers, no single failure loses it.enable.idempotence=true— retries don’t duplicate or reorder. On by default in modern clients; leave it on.- Process, then commit the offset — at-least-once; pair with idempotent processing so a duplicate is harmless.
retention.ms/retention.bytes— how long replay stays possible; set it longer than the worst consumer outage you expect.cleanup.policy=compact— for "latest value per key" changelog topics.max.poll.records/ poll loop timing — keep per-batch work short so you don’t trip a rebalance.
Pitfalls
- Keying everything the same (or badly). A skewed key builds a hot partition while the rest idle. Choose the key for even spread and the ordering you actually need.
- Treating Kafka as a database. Infinite retention, giant messages, using it as your source of truth — all fight its design. Small records, bounded retention, truth stored elsewhere.
- Committing the offset before processing. That’s at-most-once — a crash silently loses the record. Commit after the work unless you genuinely mean at-most-once.
- Ignoring consumer lag. A slow consumer that drifts past retention loses events with no error. Alert on lag slope, not just its value.
- Assuming ordering across partitions. Order holds only within a partition. If two events must be ordered, they must share a key (and thus a partition).
- Forgetting idempotence. Without the idempotent producer, retries duplicate; without idempotent consumers, at-least-once delivery double-counts.
- Wrong partition count. Too few caps parallelism; tens of thousands add real overhead. Size to your throughput with headroom, and remember you can add but not easily remove.
Best practices
- Choose the partition key deliberately — even spread plus the ordering guarantee you need; watch for skew.
- Make durable data durable — replication factor 3,
acks=all,min.insync.replicas=2, and leave unclean leader election off unless you’ve chosen availability over durability on purpose. - Idempotent everywhere — idempotent producer on; process-then-commit with idempotent consumers so at-least-once is safe.
- Watch consumer lag and size retention — alert on the slope; keep retention longer than the worst outage a consumer might survive.
- Keep messages small — events and pointers, never blobs; store big payloads in object storage.
- Use a dead-letter topic for poison messages so one bad record can’t block a partition.
- Right-size partitions and prefer managed Kafka (MSK / Confluent) unless you have a real reason to run it yourself.
Rapid-fire cheat-sheet (intern → principal)
- "What is Kafka, in one line?"
- A distributed, append-only commit log: producers append records, consumers read forward at their own offset, and records are kept (not consumed) so multiple readers and replay are free. It’s durable, ordered per partition, and scales by partitioning.
- "Topic vs partition?"
- A topic is a logical named stream; a partition is a physical append-only log on a broker. A topic is split into partitions for parallelism, and a record’s key picks the partition via hash(key) % partitions.
- "How does Kafka guarantee ordering?"
- Only within a partition, never across them. To keep related events ordered, give them the same key so they land on the same partition. There’s no global order.
- "Consumer vs consumer group?"
- Within a group, each partition goes to exactly one consumer, so the group processes each record once and parallelism is capped at the partition count. Different groups each read the whole topic independently.
- "How do you make it durable / not lose data?"
- Replication factor 3, acks=all, min.insync.replicas=2 — a committed write is on at least two brokers, so a single broker failure can’t lose it. Keep unclean leader election off so a stale replica can’t be promoted and drop committed records.
- "At-least-once, at-most-once, exactly-once?"
- It’s decided by when you commit the offset. Process-then-commit = at-least-once (may duplicate). Commit-then-process = at-most-once (may lose). Atomic via transactions = exactly-once, but only inside Kafka. The practical answer: at-least-once + idempotent processing.
- "How would you handle a hot partition?" (senior)
- Diagnose the skewed key, then spread it: salt the key, use a compound key, or drop the key for even round-robin if ordering isn’t needed — and add partitions. It’s the partition-skew pattern; the trade is ordering vs balance.
- "How do you scale consumption / make it fast?" (staff)
- Scale reads by adding consumers up to the partition count, then adding partitions. Throughput comes from sequential disk writes, the page cache, zero-copy, and batching/compression — and from small messages. Watch consumer lag as the health signal.
- "When would you NOT use Kafka?" (the one they love)
- When you just need a simple job queue with built-in retries/DLQ (SQS), low volume where a DB table or Redis suffices, request/reply RPC, or storing large blobs. Kafka is for durable, high-throughput, replayable streams — not a general database or a lightweight queue.
The takeaway
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.