Before You Add Partitions
Adding partitions to increase consumer parallelism works, but it raises broker resource use on every dimension that scales with partition count. A consumer-side path reaches the same throughput without changing the broker topology.
Why Teams Repartition
The reasoning is straightforward. A consumer group has 12 partitions and 12 consumers. Processing latency is climbing because individual messages take longer to process, perhaps because a downstream API slowed down or a new enrichment step was added. Throughput falls behind the production rate. The standard playbook says: add more partitions, deploy more consumers, spread the load.
This works, and it always has. But each time, the broker pays a cost that persists long after the throughput problem is resolved. File descriptors, memory-mapped index regions, page cache pressure, replication fetch streams, controller metadata, consumer group coordinator state and compaction thread contention all grow with partition count. These costs accumulate regardless of actual message throughput: an idle partition holds the same broker resources as one handling thousands of messages per second.
In short, repartitioning solves a consumer-side parallelism problem by creating a broker-side resource problem.
One Partition, One Consumer, One Thread
Repartitioning feels necessary because of a coupling in the Kafka® consumer group protocol: each partition is assigned to exactly one consumer, and most consumer implementations process each partition's messages sequentially on a single thread. Needing 48-way parallelism means needing 48 partitions; needing 200-way parallelism means needing 200.
The coupling is on the consumer side, not the broker side. The broker does not require one thread per partition; it delivers each partition's messages to whichever consumer owns it. Sequential processing is an implementation choice in the consumer, not a protocol requirement. A consumer that processes messages from a single partition concurrently, while preserving per-key ordering, breaks the coupling entirely.
That is what llingr-demux does. It operates inside the existing consumer, processing messages from each assigned partition concurrently across independent per-key workers. A single consumer instance with 12 partitions sustains 250-way concurrency by default (configurable up to 5,000) without any broker-side change.
What Actually Changes
Consider an orders pipeline processing payment confirmations. Each message requires a downstream API call averaging 50ms. The topic has 48 partitions, and the team is about to increase to 96 because throughput has doubled.
48 → 96 partitions
96 consumer instances across the consumer group, and twice the file descriptors, memory-mapped regions, replication streams and coordinator state on the brokers. Keyed topics cannot simply gain partitions without moving keys, so repartitioning means a new topic, migrated producers and consumers, and a drained old topic: weeks of planning, a maintenance window and a rollback strategy.
48 partitions, unchanged
The same 48 partitions. Each consumer instance processes messages for many keys concurrently, one worker per active key up to the configured limit. Doubling throughput means raising the concurrency limit, not the partition count. No broker changes, no repartitioning, no maintenance window.
The broker topology is unchanged: no new partitions, no replication reconfiguration, no controller metadata growth. The additional parallelism lives entirely within the consumer process, invisible to the broker.
Per-Key Ordering Is Preserved
Processing messages concurrently within a partition does not mean processing them out of order. Messages sharing a partition key are routed to the same worker and processed sequentially, in the order the broker delivered them. Messages with different keys are processed concurrently by independent workers. This is the ordering guarantee partitions provide at the broker level, applied at the consumer level within each partition.
The ordering property is structural, not heuristic. Each message is routed to a worker by a deterministic hash of its partition key, and each worker reads from a bounded channel that preserves arrival order. Concurrency occurs between keys, never within a key. An application that relies on per-key ordering today continues to work without modification.
Offset Commits Remain Correct
When messages from a single partition are processed concurrently, they complete in arbitrary order. The message at offset 102 may finish before the message at offset 100. Committing offset 102 at that point would skip 100 and 101 if the consumer restarted, violating at-least-once delivery.
llingr-demux links every in-flight message to its predecessor offset and commits only the highest contiguous completed position. An offset is committed only when every preceding message has also completed. The mechanism handles non-consecutive broker offsets (from compaction, transactions or control records) without special-case logic, and its memory use is bounded by the concurrency limit rather than by message volume.
The offset resolution design has been formally verified with TLA+ model checking across more than 1.1 billion distinct states, confirming monotonic commit progress, no regression of the committed position, and correct contiguous advancement under arbitrary completion order.
Rebalancing Works Normally
Consumer group rebalancing, whether triggered by scaling, rolling deployments or consumer failures, continues to use the standard Kafka® consumer group protocol. llingr-demux does not modify, extend or interfere with it. It operates entirely within the consumer process, downstream of partition assignment.
When a partition is revoked, the workers holding its messages finish their current work, the completed offsets are committed, and only then is the partition released. This happens automatically during the rebalance, with total drain time set by the slowest in-flight message rather than a fixed polling interval. No messages are lost, and under normal operating conditions none are duplicated.
Fewer partitions also means faster rebalances, because the group coordinator has less assignment state to redistribute. Every future rebalance in the cluster benefits from the partitions that were never added.
Nothing Changes on the Broker
llingr-demux is a Go engine that compiles into the consumer application, and Rust services embed the same engine through the llingr-kafka crate. It does not run as a sidecar, proxy or separate service. It opens no additional broker connections, creates no internal topics, consumer groups or coordination state, and does not change the broker's configuration or behaviour.
From the broker's perspective, the consumer looks like any other member of the group. It polls for messages, processes them and commits offsets. The per-key concurrency happens entirely within the consumer process, over the consumer's existing broker connection. The broker cannot distinguish an llingr-demux consumer from a sequential one.
No additional infrastructure. No sidecars, no proxies, no coordination topics, no ZooKeeper™ nodes, no additional consumer groups: one dependency and two callbacks.
There Is No Need to Reduce Partitions
llingr-demux works with any partition count. With 200 partitions it processes all of them with per-key concurrency; with 6 it processes those. Its parallelism comes from key cardinality, not partition cardinality, so the partition count does not limit it.
The aim is not "reduce your partitions", which would require a migration. The aim is "stop increasing them". The current partition count is fine. The next time throughput requirements grow, the answer is a higher concurrency limit in the consumer configuration rather than a change request to repartition the topic.
Over time, as topics are retired and replaced, new topics can start with lower partition counts. The broker savings accumulate without a single repartitioning event.
What the Consumer Uses
Concurrent per-key processing is not free. Each active worker uses a small, bounded amount of memory (a goroutine stack, roughly 4-8 KB) and processor time in proportion to its message processing work. Idle workers are parked by the runtime and use negligible processor time.
Total resource use is bounded by the configured concurrency limit, not by message volume or partition count. A consumer configured for 250 concurrent keys runs at most 250 workers, whether it handles 10 partitions or 100, and whether throughput is 100 messages per second or 100,000.
- Memory per active worker
- ~4-8 KB
- Memory at 250 concurrent keys
- ~1-2 MB
- Engine pipeline latency
- 0.6-2.0 µs
- CPU for idle workers
- negligible
- Additional broker connections
- 0
Measured on commodity hardware running Go 1.24. Engine pipeline latency ranges from 0.6 µs (Apple® M4™) to 2.0 µs (Arm® Cortex®-A76). Real-world throughput depends on message processing work, network latency to downstream services and available CPU.
Two Callbacks and a Concurrency Limit
Adoption does not require rearchitecting the consumer. llingr-demux replaces the message processing loop, not the broker connection, serialisation or business logic. The existing processing function becomes a callback, alongside a dead-letter callback for messages that fail. Broker client configuration passes through unchanged.
The processing callback receives the same message the current consumer processes and returns an error on failure. The difference is that 250 keys are processed concurrently instead of one at a time, and the engine handles offset tracking, worker lifecycle and drain coordination.
Two Go broker adapters are available: a pure Go adapter built on franz-go (no CGO, static binaries, recommended for new deployments) and a librdkafka-based adapter for teams already using confluent-kafka-go. Both work with Apache Kafka® and Redpanda™ without configuration changes. Rust services use the same engine through the llingr-kafka crate.
Per-Message Observability Without Sampling
Every message processed through llingr-demux produces a timing decomposition across the pipeline (queue wait, processing, commit lag and end-to-end latency) for 100% of messages, not a sampled subset. The timing data costs almost nothing to collect, because it travels in the same containers that carry messages through the pipeline and is written at synchronisation points already held for processing correctness.
A dual-purpose trait field on each message records both engine processing state (error, dead letter, offset buffered, overflow, orphaned, first after rebalance) and application-defined annotations (fraud flags, audit markers, priority tiers) in one compact structure. The complete record reaches the metrics sink for every message, so infrastructure behaviour can be correlated with business-level classification without separate instrumentation.
This visibility matters when validating that concurrent processing behaves correctly: how many messages are buffered for offset resolution, whether the concurrency limit is being reached, and how processing latency distributes across keys, all without additional monitoring infrastructure.
The Next Time Throughput Needs to Grow
Raise a configuration value in the consumer instead of filing a change request to repartition the topic. The broker topology stays exactly as it is.