Load tests for @message-queue-toolkit/kafka measuring throughput, latency, and backlog under configurable load.
Two producer modes and two consumer modes can be combined:
- CDC: CockroachDB inserts → CDC changefeed → Kafka (realistic end-to-end)
- Direct:
AbstractKafkaPublisher→ Kafka (isolates Kafka consumer performance) - Single: One message at a time (
batchProcessingEnabled: false) - Batch: Batched consumption via
KafkaMessageBatchStream(batchProcessingEnabled: true)
- Docker & Docker Compose
- Node.js >= 22.14.0
# Install dependencies
npm install
# Start infrastructure (Kafka + CockroachDB + CDC changefeed)
npm run docker:start
# Stop and clean up
npm run docker:stop# Single-message consumer
npm run load:cdc:light # 100 rows/sec, 30s
npm run load:cdc:medium # 1000 rows/sec, 60s
npm run load:cdc:heavy # 5000 rows/sec, 120s
npm run load:cdc -- --rate 500 --duration 45 --batch 50
# Batch consumer
npm run load:cdc:batch:light # 100 rows/sec, 30s
npm run load:cdc:batch:medium # 1000 rows/sec, 60s
npm run load:cdc:batch:heavy # 5000 rows/sec, 120s
npm run load:cdc:batch -- --rate 500 --consumer-batch 100 --consumer-timeout 500# Single-message consumer
npm run load:direct:light # 100 msgs/sec, 30s
npm run load:direct:medium # 1000 msgs/sec, 60s
npm run load:direct:heavy # 5000 msgs/sec, 120s
npm run load:direct -- --rate 500 --duration 45 --batch 50
# Batch consumer
npm run load:direct:batch:light # 100 msgs/sec, 30s
npm run load:direct:batch:medium # 1000 msgs/sec, 60s
npm run load:direct:batch:heavy # 5000 msgs/sec, 120s
npm run load:direct:batch -- --rate 500 --consumer-batch 100 --consumer-timeout 500| Flag | Short | Default | Description |
|---|---|---|---|
--rate |
-r |
1000 | Target produce rate (rows or msgs per sec) |
--duration |
-d |
60 | Test duration (seconds) |
--batch |
-b |
100 | Producer batch size |
| Flag | Default | Description |
|---|---|---|
--consumer-batch |
50 | Messages per consumer batch |
--consumer-timeout |
200 | Batch flush timeout (ms) |
Load Generator → CockroachDB (inserts) → CDC Changefeed → Kafka → Consumer → Metrics
- CockroachDB tables (
events,orders) with CDC changefeed targeting Kafka - Load generator inserts rows into CRDB at configurable rate with fire-and-forget concurrency
- CDC changefeed publishes row changes to Kafka topics
- Consumer (single or batch) processes messages and records metrics
Load Generator → AbstractKafkaPublisher → Kafka → Consumer → Metrics
- Publisher sends messages directly to Kafka topics (
direct-events,direct-orders) - Consumer (single or batch) processes messages and records metrics
| Service | Port | Description |
|---|---|---|
| Kafka | 9092 | Message broker (KRaft, 6 partitions) |
| CockroachDB | 26257 | SQL database |
| CockroachDB UI | 8181 | DB admin console |
| Kafka UI | 8080 | Topic browser |
Each events row embeds {"loadtest_ts": <epoch_ms>} in its payload. The consumer extracts this timestamp and computes end-to-end latency (insert/publish → consume). Reported as avg, p50, p95, p99.