Skip to content

Commit e227fa2

Browse files
authored
chore: Improved benchmark results. (#135)
Signed-off-by: Paolo Insogna <[email protected]>
1 parent 87aac69 commit e227fa2

File tree

1 file changed

+91
-34
lines changed

1 file changed

+91
-34
lines changed

BENCHMARKS.md

Lines changed: 91 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,109 @@
1-
# Producer (Single)
1+
# Kafka Client Performance Benchmarks
2+
3+
This document contains performance benchmarks comparing `@platformatic/kafka` against other popular Kafka client libraries in the Node.js ecosystem.
4+
5+
## Test Environment
6+
7+
The benchmarks were conducted to evaluate the performance characteristics of different Kafka client libraries under various messaging patterns. All tests were performed under controlled conditions to ensure fair comparison.
8+
9+
### Libraries Tested
10+
11+
The following Kafka client libraries were included in the benchmark comparison:
12+
13+
- **@platformatic/kafka** - The highest performing library across all test scenarios
14+
- **KafkaJS** - Popular Node.js Kafka client
15+
- **node-rdkafka** - Node.js bindings for librdkafka
16+
- **@confluentinc/kafka-javascript** - Confluent's official JavaScript client (with both KafkaJS and node-rdkafka backends)
17+
18+
These results demonstrate `@platformatic/kafka`'s superior performance characteristics, making it an excellent choice for high-throughput Kafka applications in Node.js environments.
19+
20+
## Producer Performance Benchmarks
21+
22+
### Single Message Per Iteration
23+
24+
This test measures producer throughput when sending one message per operation, with a total of 100,000 messages produced. This pattern simulates applications that send individual messages as events occur, representing a common real-world usage pattern.
25+
26+
**Test Configuration:**
27+
28+
- Messages per iteration: 1
29+
- Total messages: 100,000
30+
- Metric: Operations per second (op/sec)
231

332
```
4-
╔═══════════════════════════════════════════════╤═════════╤═══════════════╤═══════════╤══════════════════════════╗
5-
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
6-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
7-
║ node-rdkafka │ 100 │ 68.30 op/sec │ ± 67.58 % │ ║
8-
║ @confluentinc/kafka-javascript (node-rdkafka) │ 100 │ 220.26 op/sec │ ± 1.24 % │ + 222.47 %
9-
║ @confluentinc/kafka-javascript (KafkaJS) 100 │ 250.59 op/sec │ ± 1.25 % │ + 13.77 %
10-
║ KafkaJS │ 100 │ 383.82 op/sec │ ± 3.91 % │ + 53.17 %
11-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
12-
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
13-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
14-
║ @platformatic/kafka │ 100 │ 582.59 op/sec │ ± 3.97 % │ + 51.79 % ║
15-
╚═══════════════════════════════════════════════╧═════════╧═══════════════╧═══════════╧══════════════════════════╝
33+
╔═══════════════════════════════════════════════╤═════════╤═════════════════╤═══════════╤══════════════════════════╗
34+
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
35+
╟───────────────────────────────────────────────┼─────────┼─────────────────┼───────────┼──────────────────────────╢
36+
║ node-rdkafka │ 100000 │ 17452.32 op/sec │ ± 18.42 % │ ║
37+
║ @confluentinc/kafka-javascript (KafkaJS) │ 100000 │ 20215.32 op/sec │ ± 13.10 % │ + 15.83 %
38+
║ @confluentinc/kafka-javascript (node-rdkafka) 100000 │ 20771.13 op/sec │ ± 12.69 % │ + 2.75 %
39+
║ KafkaJS │ 100000 │ 61877.92 op/sec │ ± 0.67 % │ + 197.90 %
40+
╟───────────────────────────────────────────────┼─────────┼─────────────────┼───────────┼──────────────────────────╢
41+
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
42+
╟───────────────────────────────────────────────┼─────────┼─────────────────┼───────────┼──────────────────────────╢
43+
║ @platformatic/kafka │ 100000 │ 95039.18 op/sec │ ± 0.71 % │ + 53.59 % ║
44+
╚═══════════════════════════════════════════════╧═════════╧═════════════════╧═══════════╧══════════════════════════╝
1645
```
1746

18-
# Producer (Batch)
47+
### Batch Message Production
48+
49+
This test measures producer throughput when sending 100 messages per operation, with a total of 100,000 messages produced. This pattern simulates high-throughput applications that batch messages for improved efficiency, which is common in data pipeline and ETL scenarios.
50+
51+
**Test Configuration:**
52+
53+
- Messages per iteration: 100
54+
- Total messages: 100,000
55+
- Metric: Operations per second (op/sec)
1956

2057
```
21-
╔═══════════════════════════════════════════════╤═════════╤═══════════════╤═══════════╤══════════════════════════╗
22-
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
23-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
24-
║ node-rdkafka │ 100 86.92 op/sec │ ± 86.84 % │ ║
25-
║ @confluentinc/kafka-javascript (KafkaJS) │ 100 │ 218.23 op/sec │ ± 3.89 % │ + 151.06 % ║
26-
KafkaJS 100 │ 285.14 op/sec │ ± 4.67 % │ + 30.66 %
27-
@platformatic/kafka 100 │ 336.80 op/sec │ ± 5.46 % │ + 18.12 % ║
28-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
29-
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
30-
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
31-
║ @confluentinc/kafka-javascript (node-rdkafka) │ 100 │ 594.68 op/sec │ ± 2.26 % │ + 76.57 % ║
32-
╚═══════════════════════════════════════════════╧═════════╧═══════════════╧═══════════╧══════════════════════════╝
58+
╔═══════════════════════════════════════════════╤═════════╤═══════════════╤═══════════╤══════════════════════════╗
59+
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
60+
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
61+
║ node-rdkafka │ 1000 706.69 op/sec │ ± 69.72 % │ ║
62+
║ @confluentinc/kafka-javascript (KafkaJS) │ 1000 │ 2511.97 op/sec │ ± 1.00 % │ + 255.45 % ║
63+
@confluentinc/kafka-javascript (node-rdkafka) 1000 │ 2568.78 op/sec │ ± 0.85 % │ + 2.26 %
64+
KafkaJS │ 1000 │ 3144.13 op/sec │ ± 2.62 % │ + 22.40 % ║
65+
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
66+
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
67+
╟───────────────────────────────────────────────┼─────────┼───────────────┼───────────┼──────────────────────────╢
68+
║ @platformatic/kafka │ 1000 │ 4488.69 op/sec │ ± 3.76 % │ + 42.76 % ║
69+
╚═══════════════════════════════════════════════╧═════════╧═══════════════╧═══════════╧══════════════════════════╝
3370
```
3471

35-
# Consumer
72+
## Consumer Performance Benchmarks
73+
74+
### Message Consumption Throughput
75+
76+
This test measures consumer throughput when processing 100,000 messages. The benchmark compares different consumption patterns including stream-based and event-driven approaches across various client libraries.
77+
78+
**Test Configuration:**
79+
80+
- Total messages consumed: 100,000
81+
- Consumption patterns: Stream-based and event-driven
82+
- Metric: Operations per second (op/sec)
3683

3784
```
3885
╔════════════════════════════════════════════════════════╤═════════╤══════════════════╤═══════════╤══════════════════════════╗
3986
║ Slower tests │ Samples │ Result │ Tolerance │ Difference with previous ║
4087
╟────────────────────────────────────────────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
41-
@confluentinc/kafka-javascript (node-rdkafka, stream) 10000 23245.80 op/sec │ ± 43.73 % │ ║
42-
║ node-rdkafka (stream) 10000 25933.93 op/sec │ ± 32.86 % │ + 11.56 % ║
43-
║ @confluentinc/kafka-javascript (node-rdkafka, evented) │ 10000 41766.69 op/sec │ ± 77.85 % │ + 61.05 %
44-
║ @confluentinc/kafka-javascript (KafkaJS) 10000 │ 49387.87 op/sec │ ± 63.30 % │ + 18.25 %
45-
node-rdkafka (evented) 10000 55369.02 op/sec │ ± 77.81 % │ + 12.11 %
46-
KafkaJS 10000 │ 172692.11 op/sec │ ± 52.70 % │ + 211.89 %
88+
║ node-rdkafka (stream) 100000 │ 49423.52 op/sec │ ± 6.63 % │ ║
89+
@confluentinc/kafka-javascript (node-rdkafka, stream) │ 100000 55990.54 op/sec │ ± 10.58 % │ + 13.29 % ║
90+
║ @confluentinc/kafka-javascript (KafkaJS) 100000 │ 123289.64 op/sec │ ± 16.86 % │ + 120.20 %
91+
║ @confluentinc/kafka-javascript (node-rdkafka, evented) 100000 │ 125986.77 op/sec │ ± 23.14 % │ + 2.19 %
92+
KafkaJS 100000 │ 126963.99 op/sec │ ± 4.15 % │ + 0.78 %
93+
node-rdkafka (evented)100000 │ 135950.87 op/sec │ ± 19.03 % │ + 7.08 %
4794
╟────────────────────────────────────────────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
4895
║ Fastest test │ Samples │ Result │ Tolerance │ Difference with previous ║
4996
╟────────────────────────────────────────────────────────┼─────────┼──────────────────┼───────────┼──────────────────────────╢
50-
║ @platformatic/kafka │ 10008 │ 338994.74 op/sec │ ± 38.21 % │ + 96.30 % ║
97+
║ @platformatic/kafka │ 100015 │ 152567.14 op/sec │ ± 1.48 % │ + 12.22 % ║
5198
╚════════════════════════════════════════════════════════╧═════════╧══════════════════╧═══════════╧══════════════════════════╝
5299
```
100+
101+
## Performance Summary
102+
103+
The benchmarks demonstrate that `@platformatic/kafka` consistently outperforms other Kafka client libraries across different usage patterns:
104+
105+
### Key Results
106+
107+
- **Producer (Single Message)**: `@platformatic/kafka` achieves 95,039 op/sec, which is 53.59% faster than KafkaJS, the second-best performer
108+
- **Producer (Batch Messages)**: `@platformatic/kafka` reaches 4,488 op/sec, outperforming competitors by 42.76%
109+
- **Consumer Performance**: `@platformatic/kafka` delivers 152,567 op/sec, providing a 12.22% improvement over the next fastest option

0 commit comments

Comments
 (0)