kafka-load-test

Guides authoring and reviewing Kafka load tests using k6, xk6-kafka, and kafka-perf-test.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/lurodrisilva/personal-skills --skill kafka-load-test-lurodrisilva
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: kafka-load-test
Source: https://github.com/lurodrisilva/personal-skills/tree/main/platform-engineering/kafka-load-test
Command: npx skills add https://github.com/lurodrisilva/personal-skills --skill kafka-load-test-lurodrisilva

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Kafka load tests often produce indefensible numbers because teams conflate broker bottlenecks with application bottlenecks, run tests from laptops with network skew, or leave sizing knobs unfixed. This Skill codifies a paired-tool methodology that produces reproducible results and names exactly which resource saturated first. ## Core Features & Use Cases - Paired-tool methodology: Run a one-time broker baseline with kafka-producer-perf-test.sh / kafka-consumer-perf-test.sh whenever broker shape changes, then run headline application-pipeline tests with k6 + xk6-kafka (v2 API: Producer, Consumer, AdminClient, SchemaRegistry). - Correct k6 lifecycle and CI integration: Create topics in setup() with a fresh AdminClient plus sleep(2) instead of the racy if (VU == 0) pattern, and bind k6 thresholds to kafka_writer* / kafka_reader* metrics so runs become pass/fail CI artifacts. - In-cluster execution and observability: Run k6 as a Kubernetes Job in a dedicated namespace like testing-system, watch the four-quadrant dashboard (producer, broker, consumer, app), stop on the first SLO breach, and clean up topics, offsets, and synthetic rows after every run. - Use Case: After changing a Strimzi KafkaNodePool, establish the new broker ceiling with perf-test.sh, then run a ramping-arrival-rate xk6-kafka Job against your service's inbound adapter to verify the pipeline meets its p99 latency SLO. ## Quick Start Ask the AI to write a k6 xk6-kafka load test script with ramping-arrival-rate, setup()-based topic creation, and kafka_writer thresholds, packaged as a Kubernetes Job in testing-system.

Frequently Asked Questions about kafka-load-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I load test Kafka with k6 and xk6-kafka?▼

Build a custom k6 binary with CGO using xk6 build --with github.com/mostafa/xk6-kafka/v2, or use the grafana/xk6 Docker builder or the prebuilt mostafamoradian/xk6-kafka image. Write a script using the v2 Producer, Consumer, AdminClient, and SchemaRegistry APIs with a ramping-arrival-rate scenario.

kafka-producer-perf-test vs xk6-kafka: which should I use?▼

Use kafka-producer-perf-test.sh for raw broker baselines to prove the broker is not the bottleneck, and use k6 with xk6-kafka for application-pipeline tests that drive your service's real adapters with schemas, thresholds, and CI integration. The two tools answer different questions.

Why does my k6 Kafka test fail with topic creation errors?▼

The if (__VU == 0) pattern at module scope is a race because other VUs start producing before VU 0 finishes creating the topic. Create topics inside setup() with a fresh AdminClient, verify with listTopics(), then sleep(2) for metadata propagation, or set autoCreateTopic: true.

Does xk6-kafka v2 support Schema Registry and Avro?▼

Yes, the v2 API includes a built-in SchemaRegistry class supporting Avro, JSON Schema, and Protobuf serialization, including gzip-compressed payloads. Use sr.serialize() with the appropriate schemaType when producing messages.

Why are my Kafka load test numbers inconsistent between runs?▼

Common causes are running from a laptop instead of an in-cluster Job, floating sizing knobs like message size or producer acks, insufficient duration under 10 minutes, and leftover synthetic data from prior runs. Fix all knobs in writing and clean up topics, offsets, and database rows after each run.

When should I not use this Kafka load testing approach?▼

Do not use it for cluster sizing decisions such as broker count or JVM heap, which belong to Strimzi operator configuration, or for deploying Kafka itself. It also does not cover broker comparisons like Kafka versus Pulsar or debugging client library bugs.