Your Kafka client is an infrastructure dependency you probably chose years ago and rarely revisited. It shapes how your service publishes messages, handles failures, and recovers from interruptions. But when was the last time you evaluated whether it is still the right choice? Here is the fact that starts this post. The last KafkaJS release, version 2.2.4, shipped on February 27, 2023. Nothing has followed it.

That fact deserves a careful reading, because three different concerns hide inside it and they are not interchangeable. No recent releases is a verifiable statement about the npm registry. Lack of active maintenance is a judgment about the project behind the package. Exposure to specific vulnerabilities or missing protocol support is a third claim, and it needs its own evidence. This post will not blur them together. What we can say plainly is this: the pure JavaScript client that became the ecosystem's default has not shipped in over three and a half years, and its repository shows no merged commits since May 2024 either, even as issues and pull requests keep arriving. Maintained alternatives exist, and most teams running it have never measured what staying or leaving actually costs them.

So this is not really a post about which client wins a benchmark. It is a post about how to make this decision well: how to read benchmark evidence without being sold to, which settings matter more than the client, how to measure your own workload, and when migrating is worth its cost. The benchmark story turns out to be the best illustration, because the most-cited numbers in this space had to be measured twice.

The landscape, as of October 2026

Four clients cover most serious Node.js Kafka deployments. Versions below were checked against the npm registry on October 19, 2026.

Client Engine Latest Last published
kafkajs Pure JavaScript, implements the Kafka protocol in JS 2.2.4 Feb 27, 2023
node-rdkafka C++ binding to librdkafka 3.6.1 Dec 3, 2025
@confluentinc/kafka-javascript librdkafka, official Confluent client 1.11.0 Oct 7, 2026
@platformatic/kafka Pure JavaScript, modern rewrite 2.20.0 Nov 25, 2026

The two librdkafka clients share an engine and differ in ownership and API. Confluent's is the official client, with a KafkaJS-shaped compatibility API we will look at closely later. Platformatic's is the newest design: a from-scratch pure JavaScript client with a stream-first API. One constraint worth knowing before you fall for it: its current release requires Node >= 22.22.0 or >= 24.6.0, a much newer floor than the other three.

If you use NestJS, one more fact shapes the decision. The framework's built-in Kafka transport is KafkaJS-based, and NestJS documents no supported way to substitute another client inside that transport. Replacing the client under NestJS means writing a custom transport strategy or bypassing the transport and using the client directly from your services. Budget for that, because it is part of the migration cost, not a footnote to it.

The benchmark that had to be benchmarked again

The most-cited head-to-head numbers for these clients come from Platformatic, the company that sells one of them. That alone should set your reading posture: vendor benchmarks are evidence, but they are evidence published by an interested party. What happened next is why this story is worth telling properly.

Platformatic's original 2025 benchmark made its client look strong and the librdkafka clients look broken. There was a problem. Their method sampled timing only every 100 messages, ran with small sample sizes, and, critically, did not properly wait for delivery reports from the librdkafka-based clients. It was timing sends without confirming acknowledgments. The tell was in their own table: node-rdkafka's producer result carried a tolerance of plus or minus 96 percent (in some runs of that suite, ±67 percent). A measurement with error bars that wide is not a result. It is a note that says "we could not measure this cleanly."

To their credit, they said so themselves, rebuilt the suite, and published the correction. The revised methodology measures every operation individually, waits for each message's delivery report before timing the next librdkafka operation, and uses 100,000 samples for most tests. The numbers moved dramatically for every library, before any client code changed. Then, with measurements they finally trusted, they found and fixed real bottlenecks in their own client, including replacing their pure JavaScript CRC32C checksum with a native Rust implementation.

Here are the corrected results, exactly as published, for @platformatic/kafka v1.21.0. The environment was an M2 Max MacBook Pro running Node.js 22.19.0 against a three-broker Kafka cluster. "Producer (single)" sends one message per operation; "Producer (batch)" sends 100 messages per operation; "Consumer" processes 100,000 messages. These are operations per second, and in the batch row an operation is 100 messages, so compare rows across clients, not down the column.

Library Producer (single) Producer (batch) Consumer
@platformatic/kafka v1.21.0 92,441 4,465 159,828
KafkaJS 62,450 2,923 120,279
@confluentinc/kafka-javascript (KafkaJS API) 19,721 2,311 139,881
@confluentinc/kafka-javascript (rdkafka API) 21,587 2,648 127,146
node-rdkafka 16,488 701 133,526

Now read them the way an engineer should, because the honest conclusions are narrower than the headline.

The single-message producer ranking is dominated by the pattern, not the clients. In this test every operation flushes one message and waits for its delivery confirmation. That pattern never lets librdkafka's batching engage, and it charges the native clients a boundary-crossing and delivery-report round trip for every single message. Platformatic's 92,441 op/sec is about 48 percent ahead of KafkaJS's 62,450 on this pattern. Whether that gap survives contact with your workload depends on whether your producers actually send one message at a time and wait.

Batching narrows some gaps, not all of them. At 100 messages per operation, Platformatic leads at 4,465 op/sec, and its lead over KafkaJS (2,923) is about the same as in single-message mode: batching did not close that gap. What batching changed is the native clients' position. The two Confluent API styles reach 2,311 and 2,648 op/sec, close behind KafkaJS after trailing it roughly threefold in single-message mode, because batched operations finally let the delivery cost amortize across many messages. node-rdkafka's 701 remains an outlier with very wide variance in this suite and should be treated as unreliable, the same skepticism the corrected methodology was built to enforce. So the lesson is narrower than "batching fixes it": batching narrows some performance gaps between clients, although the extent varies by implementation and workload.

The consumer spread is real but modest, and variance is part of the story. Platformatic's 159,828 op/sec leads KafkaJS's 120,279 by about a third. Every client sits in the same order of magnitude. Platformatic also reported far tighter variance on the consumer test (about ±1.75 percent) than node-rdkafka (about ±19 percent) or the Confluent clients (about ±18 to 24 percent). Average throughput tells you how fast a system ran. Variance tells you how consistently it repeated that result. Tail latency needs its own measurement: a run-to-run percentage spread is not a per-message p99.

What these numbers are not. They are one vendor's measurements, on one laptop, of one workload shape, taken in late 2025 against a Platformatic version (v1.21.0) that is no longer current. The original post does not pin down every configuration that matters, including acknowledgment levels for each client, so do not treat the table as a durability-matched comparison. Treat it as a well-documented claim with a known provenance, and as a prompt to run the measurement that actually counts: yours.

Why the implementations behave differently

It helps to separate the two execution paths the old draft of this article blurred together, because producer behavior and consumer behavior have different causes.

On the producer path, the plausible contributors to the gaps are protocol serialization cost, buffer allocation and copying, how much batching the API shape encourages, how acknowledgments are awaited, and, for native clients, the cost of crossing the JavaScript to C++ boundary on every operation. KafkaJS and Platformatic both implement the protocol in JavaScript, so their hot paths run on the event loop; Platformatic's design works hard at minimizing buffer copies and keeping hot operations (checksums, hashing, encoding) cheap, and its fastest checksum path prefers a native Rust CRC32, shipped as an optional dependency with a WASM fallback, which is worth knowing when you hear "pure JavaScript": the project describes itself as 99 percent pure JavaScript with no native addon required, and the optional percent sits exactly on the hot path. The librdkafka clients hand messages to a native queue and let background threads handle batching, compression, and socket I/O, which frees the event loop but charges that boundary cost per operation. These are mechanisms consistent with the measurements, not proven causes. Only profiling your build separates them.

On the consumer path, the work is fetch handling, callback or stream overhead per message, deserialization, and what your handler does. That is why consumer numbers cluster: once records arrive, the client is a smaller share of the total work than your own processing. It is also why consumption style matters more than client brand, which brings us to the settings.

Message path comparison: a pure JavaScript client serializes and sends on the Node.js event loop, while a librdkafka-based client crosses a native boundary into a queue where background threads batch, compress, and perform network I/O before delivery reports return

The knobs, told truthfully

Here is where this article has to correct a common piece of advice, including advice in its own first draft: the famous Kafka tuning knobs are not universal. They belong to specific clients.

KafkaJS does not expose linger.ms or batch.size. Those names come from the Java producer's configuration model, and librdkafka adopted them. In KafkaJS, the equivalents are shaped differently:

  • Acknowledgments are a per-send option: producer.send({ acks }), where -1 (the default) waits for all in-sync replicas, 1 waits for the leader only, and 0 waits for nothing.
  • Compression is also per send: producer.send({ compression }), defaulting to none. Only GZIP ships in core KafkaJS; Snappy, LZ4, and ZSTD arrive through companion packages (kafkajs-snappy, kafkajs-lz4, @kafkajs/zstd).
  • Batching is whatever you hand it: the messages array in one send() call is the batch. There is no background linger collecting messages for you.
  • An experimental idempotent producer mode exists as a producer option, and it requires acks: -1.

The librdkafka clients expose the classic knobs as client configuration, including linger.ms, batch.size, and compression.type, and they batch in the background whether or not your send calls arrive in batches. Two facts keep this honest. First, Kafka's own default for producer compression is none, not LZ4; LZ4 is a common production choice because it trades a little CPU for a good ratio at low latency cost, but it is a choice, not a default. Second, batching is what makes compression pay: compressing full batches is where the ratio comes from, so the two knobs move together.

Confluent's compatibility API moves the knobs. If you migrate through the KafkaJS export, acks and compression stop being per-send options and become producer-level configuration. Same words, different home. Assume nothing about a setting until you have found where it lives in the new client.

On the consumer side, the KafkaJS truth is more interesting than the folklore. Messages are always fetched in batches, whichever handler you choose. eachMessage is implemented on top of eachBatch, and offsets work by resolution: a message you processed is resolved, and resolved offsets are what get committed, after the fetched batch and on the auto-commit interval or threshold you configure. eachMessage does not commit once per message, and eachBatch does not magically commit once per batch. What eachBatch actually buys you is control: the whole batch at once, resolveOffset for partial progress, heartbeat() for long processing, and commitOffsetsIfNecessary() when you want a commit decision inside the batch. It also hands you the responsibility that comes with control, including setting eachBatchAutoResolve deliberately instead of accepting the default blindly. Benchmark the two styles on your handler; do not assume the batch style wins by definition.

How to benchmark your own workload

Everything above is someone else's workload. The complete harness for this article now lives in a companion repository: codedbyMo/kafka-client-benchmark. It is real, runnable code, not a longer version of a blog snippet. The article keeps the methodology and a representative excerpt; the repository has the adapters, broker setup, topic bootstrap and cleanup, validation checks, and exercises.

Its design matters more than any single line:

  • The full configuration is printed before anything is measured. That includes the client and its version, the Node.js version, the broker version supplied to the run, message count and payload size, the seed, topic partitions and replication factor, acks, batching shape, producer scenario, and consumer mode. A result is only comparable to another result whose configuration block matches.
  • The dataset is deterministic. It is a pure function of the seed, message count, and payload size. Every message gets its own deterministic payload content, with its sequence number in the first four bytes and a fill derived only from the seed and that sequence number. The same inputs produce the same bytes on another machine, and the repository includes a checksum check for the dataset.
  • Every run is isolated. The harness creates a fresh topic for each client, run, and phase, including a separate warm-up topic, and deletes the topics afterwards unless they are explicitly kept for inspection. A consumer run never replays a shared bench topic, warm-up records, or another client's data. Each consumer also gets a fresh group.
  • Seeding is verified before consumption starts. The harness checks the topic's partition offsets and requires the broker to hold exactly the dataset it intended to seed. During consumption, it validates the set of messages, not just a total: every sequence number in range exactly once, no foreign data, and an order-independent checksum equal to the seeded dataset's checksum. A failed validation produces no result.
  • Durability is aligned by default. The default is ACKS=-1, meaning all in-sync replicas, for every client. Compression is set to none. Where a client cannot express acks in the same place, the adapter prints that difference before the run.
  • CPU and memory sit beside throughput. The consumer takes its timing, CPU, and RSS baselines when the first message arrives, so group join and assignment are excluded from all three. RSS is reported as a before-and-after delta, not as peak memory.

The configuration defaults state the measurement contract plainly:

JavaScript
acks: int(env, 'ACKS', -1),
producerScenario: env.PRODUCER_SCENARIO ?? 'serial', // serial | bounded | both
consumerMode: env.CONSUMER_MODE ?? 'eachBatch', // kafkajs: eachBatch | eachMessage

In the serial producer scenario, each timed unit is one awaited send call:

JavaScript
for (const chunk of chunks) {
  const t0 = process.hrtime.bigint();
  await producer.sendBatch(topic, chunk);
  sendLatenciesMs.push(Number(process.hrtime.bigint() - t0) / 1e6);
}

That distinction drives the metric names. Producer percentiles are per send call, reported as sendCallP50Ms, sendCallP95Ms, and sendCallP99Ms. One call can carry up to BATCH_SIZE messages, so those values are never divided by the batch size and presented as per-message latency. The headline result is the run with median throughput; its latency percentiles and CPU/RSS figures are that run's own, not pooled or averaged across runs, and the output labels them that way. All individual runs are printed as well.

The serial scenario also has a deliberate limit. It keeps one send call in flight and awaits every delivery confirmation, so it is a latency-focused workload, not a maximum-throughput test. The harness therefore includes a bounded-concurrency scenario as well: up to CONCURRENCY send calls in flight, with backpressure from simply not starting more sends at the limit, and every send still awaited before the run ends. Use the serial result to study acknowledged-send latency. Use the bounded result when the question is closer to throughput capacity. Neither number, on its own, is "the client's speed."

The consumer benchmark is fetch/count-only. Its handler validates and counts messages; it does no application processing. That makes it a raw consumption rate, useful for comparing consumption machinery, and not a prediction of your application's throughput once deserialization, business logic, and downstream writes enter the handler.

Offset handling is part of the measurement rather than an afterthought. Auto-commit is off. Only messages that were actually counted have their offsets resolved or committed, and the final commit happens before the run is declared finished. In KafkaJS eachBatch mode, offsets are resolved per counted message inside the batch, so a target reached mid-batch leaves the uncounted remainder unresolved. In eachMessage mode, the harness explicitly commits the offset after the last counted message in each partition. Platformatic tracks the last counted message per partition and commits the counted set once at the target with message.commit(). Confluent uses an explicit commit of the counted set. The clients differ in mechanism; the policy, commit only what was counted, does not.

The repository's broker-free logic tests pass (13 of 13), and the dataset determinism is verified by checksum. The harness has also run live, end to end, against a real broker (GitHub Codespaces, October 25, 2026; the complete log is in the repository's sample-output folder). This article still does not present a home-run table from the harness: a two-core cloud shell is an indicative environment, not benchmark hardware, and the Platformatic figures above remain the cited external evidence. Run the companion project in Codespaces, with Docker Compose, or against your own broker to produce numbers for your environment; the README documents all three routes and the pinned versions.

A methodology correction belongs on the record before the result itself. Reviewing the harness after that run found two measurement defects: the producer and consumer wall-clock windows included client teardown (close, stop, and disconnect time), and Platformatic committed every counted record during its consumer run while the other two adapters committed the counted set once at the end. Both are fixed in the repository now: the windows end when the measured work ends, and every adapter commits the counted set once, at the target. The October 25 run predates the correction, so nothing from it is presented here as a like-for-like ranking of the three clients. The outcomes it is asked to support are completion, validation, and one failure, stated next.

In our Codespaces test on Kafka 4.1.2, Platformatic 2.14.0 failed during producer metadata handling (PLT_KFK_MULTIPLE), while KafkaJS and Confluent completed the tested scenarios. This needs isolation and an upstream reproduction before attributing the cause or generalizing compatibility.

Porting the harness is real work

The companion project has adapters for KafkaJS, Platformatic, and Confluent. Writing them is the clearest evidence that "the same shape" is not the same integration.

KafkaJS takes brokers at client construction and acks and compression on each producer.send() call. Platformatic is a different API shape: Producer and Consumer classes, explicit serializers and deserializers so raw buffers stay raw, a consumption stream rather than batch callbacks, and message.commit() for offsets. Confluent keeps a KafkaJS-like surface through its compatibility export, but moves acks and compression into producer creation, and auto.offset.reset and enable.auto.commit into consumer creation. Its subscribe() takes { topics: [...] }, there is no heartbeat() for your handler to call, and its eachBatch semantics differ enough that the companion adapter consumes with eachMessage and commits explicitly.

Here is the Confluent producer path in copy-and-run form:

JavaScript
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { KafkaJS } = require('@confluentinc/kafka-javascript');
const { Kafka } = KafkaJS;

const kafka = new Kafka();
const producer = kafka.producer({
  'bootstrap.servers': '127.0.0.1:9092',
  'client.id': 'bench',
  acks: '-1',
  'compression.type': 'none',
  'enable.idempotence': false,
});

await producer.connect();
await producer.send({
  topic: 'bench-topic',
  messages: [{ key: 'key-0', value: Buffer.from('hello') }],
});
await producer.disconnect();

That is still the gentle version of a migration. The compatibility guide lists the rest: fromBeginning and auto-commit settings move into consumer creation, autoCommitThreshold is not supported, error types and retry semantics differ, and parts of the Admin API are subsets. None of this makes the compatibility API a bad idea. It makes it what Confluent actually built: an incremental migration path, not a guaranteed drop-in replacement. Validate it the way you would validate any engine swap:

  • Producer acknowledgment and compression settings, and where each one lives now.
  • Consumer group behavior, offset commits, and what happens on rebalance.
  • Error classification and retry behavior, including which errors are fatal.
  • Serialization and compression round trips against real payloads.
  • Transactions, if you use them; their API shape changes too.
  • Framework integration, especially NestJS, where the built-in transport will not follow you.
  • Batch consumer behavior, if you rely on eachBatch: Confluent's implementation is not semantically identical to KafkaJS's, and its own migration guide describes the batch sizing inconsistently, so verify actual batch sizes, offset resolution, auto-commit behavior, and error handling inside your handler instead of assuming KafkaJS semantics.

The companion repository does not include node-rdkafka. Its install requires a node-gyp source build, which could not be completed in the environment used to build the project. That absence is stated in the repository rather than papered over; the client still belongs in the landscape discussion above, but no companion adapter is claimed for it.

Turn it into a lab

The repository's exercises are where the settings stop being folklore:

  1. Run with ACKS=1 and ACKS=-1 and compare. Explain the durability tradeoff in terms of what the broker must do before it may acknowledge.
  2. Compare BATCH_SIZE=1 with BATCH_SIZE=100 in the serial scenario. Watch both sendCallP99 and throughput, and explain why both move.
  3. Run KafkaJS with CONSUMER_MODE=eachMessage, then with the default eachBatch. The dataset, handler work, and committed-offset policy stay the same; only the delivery shape changes.
  4. Run PRODUCER_SCENARIO=bounded and compare it with the serial run. Explain what the serial scenario was hiding, and why neither number alone is the client's speed.

Treat every result from those exercises as a local lab measurement, not a production guarantee.

When should you actually move?

Not because a benchmark table told you to. The decision weighs at least six factors, and throughput is only one of them: maintenance and support, framework integration, native dependency constraints, supported Node.js versions, migration complexity, and your own measured throughput and latency on your own topics.

Decision flowchart: weigh maintenance and support, framework integration, native dependencies, Node.js version support, and migration cost against your own measured numbers before choosing to stay on KafkaJS, move to Confluent, keep node-rdkafka, or adopt Platformatic

Staying on KafkaJS is defensible when the service is low-throughput and stable, the dependency is pinned, and your team has written the maintenance risk down as accepted tech debt with a review date. An unmaintained client is a risk, not a fire. What is not defensible is staying by default, without the measurement or the note.

Confluent's client is the maintained default for most teams leaving KafkaJS: official, librdkafka underneath, actively shipping, with TypeScript definitions. The price is a native dependency and a migration you must validate rather than assume, per the checklist above.

node-rdkafka is a reasonable keep if you already run it and have tuned around its API. There is no strong reason to adopt it fresh when the official client wraps the same engine, and no urgent reason to rip it out either.

Platformatic is the interesting bet if you want a modern pure-JavaScript-first design and your runtime clears its Node version floor (currently >= 22.22.0 or >= 24.6.0). Its corrected benchmarks are genuinely strong, especially on variance. It is also the newest option, with the smallest production track record, and its own vendor wrote the numbers. Weight all three of those facts.

What I would do

First, run the harness at your production settings and write down the numbers. You cannot evaluate a migration without a baseline. Second, set the knobs your current client actually exposes, and re-measure; durability and batching choices routinely outweigh the client, and they cost an afternoon instead of a quarter. Third, spike the Confluent client behind its compatibility API in staging, run the same harness, and work the validation checklist. If the numbers move and the behavior checks out, you have evidence. If they do not move, you have evidence too, and staying put becomes a decision instead of a habit.

That is the real lesson of the benchmark that had to be benchmarked again. The team that published the flattering numbers also published the correction, and the correction was worth more than the numbers. KafkaJS has not shipped since 2023. Whether that should move you depends on things a headline cannot tell you: your workload, your framework, your risk tolerance, and your measurements. Get those four things in a row, and the decision becomes one you can defend.

Sources