Skip to main content

1  Introduction

You find out how a Kafka cluster handles a broker failure on the day a broker fails, unless you’ve already tried it. Kates lets you try it first: it puts load on the cluster, injects the failure, and checks the numbers against targets you set. It’s built for the people who run, test or are about to inherit an Apache Kafka cluster: platform engineers, SREs and developers.

After this chapter, you can:

1.1 What Is Kates?

Kates (Kafka Advanced Testing & Engineering Suite) is a tool for performance testing and chaos engineering on Apache Kafka clusters. It has two halves: the kates CLI on your machine, and the Kates API, a service in the cluster that generates load, drives faults and keeps every run in PostgreSQL. Architecture & Design shows the parts. Together they answer questions like these:

  • How many records per second can my cluster sustain before latency degrades?
  • What happens to in-flight messages when a broker dies?
  • Does my cluster recover from a network partition within the SLA I set?
  • Is there any data loss under cascading failures?

A generic load testing tool treats Kafka as an endpoint that accepts requests. Kates sets producer acknowledgments, batching and consumer group settings for each test, and a fault can aim at a partition’s leader while Kates tracks the ISR. kafka-producer-perf-test prints its numbers and exits; Kates stores every run, checks it against your targets and keeps the history for trends. A safety guard checks each disruption before it starts.

1.2 The Problem Space

Before you trust a cluster with production traffic, you need answers in three areas, and each one is tested differently. The table names what you test in each area and the chapters that test it; its last two rows cover what you need around the tests:

Area What you test Where the book tests it
Performance Throughput under load, latency percentiles, capacity limits Performance Theory, Test Types Deep Dive
Resilience Broker failure recovery, network partition tolerance, cascading failures Chaos Engineering in Practice
Data integrity No acknowledged record lost, ordering, duplicates Data Integrity Verification
Observability Heatmaps, trends and exports of every run Observability & Monitoring
Operations Deploying, upgrading and sharing the stack Deployment Guide

Most teams check these by hand: a perf-test script, a Grafana dashboard watched while someone deletes a pod, and a judgment call. Kates turns the same checks into tests you can repeat, run in a pipeline and check against targets you set.

1.3 Design Philosophy

Five principles shape Kates, and each later chapter leans on one of them.

Kafka-Native

The native benchmark backend, which generates a test’s load by default, runs real Kafka producers and consumers with the acks, batching, compression and consumer group settings of the test’s spec. A disruption plan can aim a fault at a partition’s leader and track a topic’s ISR while the fault runs.

Kubernetes-First

Kates runs inside Kubernetes and targets Strimzi-managed clusters. It injects faults through LitmusChaos, which make all installs with the rest of the stack, or straight through the Kubernetes API if you choose; Chaos Engineering in Practice says which faults each can run. Load tests work against any Kafka cluster the Kates API can reach.

SLA-Driven

Every test can carry the targets it must meet. Kates calls them SLA thresholds, though they work like SLOs: targets you set, not agreements with anyone [10]. In a scenario file they are gates, which kates test apply --wait checks after each run, exiting 1 when one is missed. A disruption plan’s thresholds earn it an SLA grade from A to F instead. So a CI job can fail the build when throughput drops or P99 rises past a gate.

Observable

Every run is stored as a report, which kates report show <id> -o json prints as JSON. kates report export writes it as CSV, as JUnit XML for CI, as Markdown or HTML, or as heatmap data in JSON or CSV that shows how latency spread over time. While a test runs, kates top and the live dashboard show it as it happens.

Safe by Default

Before a plan runs, Kates refuses it when its steps would hit more broker pods than its maxAffectedBrokers allows or leave no broker untouched, and before each fault it checks that every Kafka pod is Ready. By default, when a step fails, rollback gives back a broker a scale-down removed and deletes the NetworkPolicies Kates created for a network partition. Safety Guardrails in Chaos Engineering in Practice says exactly what it checks, and Limits of the Guard what it doesn’t.

1.4 How Kates Fits into Your Workflow

The diagram places Kates in a delivery pipeline as two gates, each named by the command that implements it. Read it from the top: a build passes a performance gate before staging and a chaos gate before production, and after release, scheduled tests feed a trend that sends any regression to the same block-and-alert step.

graph TB
    B[Build] --> C["Performance gate<br/>kates test apply --wait"]
    C -->|gates met| D[Staging deploy]
    D --> E["Chaos gate<br/>kates disruption run<br/>--fail-on-sla-breach"]
    E -->|SLA met| F[Production deploy]
    C -->|gate missed| G[Block and alert]
    E -->|SLA breached| G
    F --> H["Scheduled tests<br/>kates schedule"]
    H --> I["Trend<br/>kates trend"]
    I -->|regression| G
Figure 1.1: Kates as two gates in a delivery pipeline: performance before staging, resilience before production, and scheduled tests watching the trend afterwards.

Kates is both a check before a merge (a short LOAD run) and the gate before production (the disruption plans with their SLA blocks).

1.5 Quick Start

You run the payments platform, and before it moves onto krafter, the Kafka cluster under test, you have to say whether the cluster can carry it. The book turns that into targets a Kates run can check. krafter must take 2,000 records per second of 1 KiB with acks=all, and answer writes with a P99 of 100 ms or less from send to acknowledgment. It must also lose no acknowledged record when one broker or one zone fails.

The Quick Start takes the first step: a LOAD run against krafter and its report. It installs the released CLI and deploys the stack in the isolated topology, which puts the Kates API in the kates namespace and krafter in kafka. In the book’s lab that stack runs on panda, the three-node Kind cluster. It needs no checkout of the repository. Each step says what success looks like and where to go when it fails; the CLI Issues in the Troubleshooting Index cover most of the failures.

  1. Install Kind, kubectl, Helm and the CLI, on macOS or Linux, with Docker running and about 16 GB of RAM available to it.

    brew install kind kubectl helm bmscomp/tap/kates

    kates version then prints the release. The kates formula also installs cosign, which checks the charts the deploy pulls. Without Homebrew, Installation in CLI Reference gives the release installer and the archives.

  2. Deploy the stack.

    kates deploy --topology isolated

    With no cluster reachable, it offers to create panda and switches kubectl to it; accept. With a cluster reachable, it deploys into kubectl’s current context, so check kubectl config current-context first. Success is a summary of the installed components and their access points. After a failure, fix the cause and run it again: it skips or upgrades the components already installed.

  3. Forward the services in the background, and connect the CLI.

    kates ports

    It forwards the Kates API to localhost:8080, reads the API key the kates chart generated into the kates-api-key Secret, and writes both into a CLI context named ports, which it makes current. It says when the API rejects the key.

  4. Check that the CLI reaches the Kates API and the Kates API reaches krafter.

    kates health

    The banner reads System Status: UP, and the Kafka Cluster section shows the bootstrap address. DEGRADED means the Kates API can’t reach Kafka: see Kates Can’t Connect to Kafka. A refused connection means the forward from step 3 died: run kates ports again.

  5. Run your first test, and wait for it to finish.

    kates test create --type LOAD --records 100000 --wait

    It prints Test created successfully and the run’s ID, then exits 0 when the run is done. An error that starts [401] Missing API key means the context has no key: repeat step 3. A run that ends FAILED prints the kates test get <id> command that shows why.

  6. Read the run’s report, with the ID that step 5 printed.

    kates report show <id>

    The report shows a throughput summary, a latency distribution from average through P99 and an error rate: that’s your first success. Report has no performance data means the run collected no metrics, and the report prints the kubectl logs command that reads the Kates API’s logs. kates test list shows the ID again if you lost it.

Every /api endpoint except /api/health needs the API key, which is why kates ctx set takes --api-key and why kates health works before the key is set.

To connect without kates ports, forward the API yourself and create a context with the key: kubectl get secret kates-api-key -n kates -o jsonpath='{.data.api-key}' | base64 -d reads it, and kates ctx set <name> --url <url> --api-key <key> stores it. With the single-namespace topology (--topology single), the Secret lives in kates-stack. The Deployment Guide covers how kates deploy fills a context’s key.

The report also has an SLA section, which reads All SLA thresholds met unless the run missed a threshold it carried. The payments targets are judged on the produce row of kates test get <id>: its throughput, and its P99, which times each write from send to acknowledgment. This first run carries no targets yet: Part II writes them into a scenario file whose gates check them.

The REST and gRPC examples in this book read the same key from the KATES_API_KEY variable; Authentication in REST API Reference shows how to export it.

For a complete setup guide, see Deployment Guide. Tutorial 1: Getting Started with Kates goes over the same ground one step at a time, and the Kates Tutorials continue from there.

TipTry it: What does acks=1 buy you in latency?

Run the Quick Start’s test again with --acks 1, then put the two reports side by side:

kates test types
kates test create --type LOAD --records 100000 --acks 1 --wait
kates test list --type LOAD
# the Quick Start run used the acks=all default
kates report diff <quick-start-id> <id>

The diff shows what relaxing producer acknowledgments buys you in latency.

1.6 What Kates Is Not

Kates leaves four nearby jobs to other tools:

  • It isn’t a Confluent Platform replacement or a managed Kafka distribution. It tests clusters that Confluent, Strimzi or any other Kafka deployment runs.
  • It isn’t a general-purpose load tester. Its tests are built around Kafka behavior, such as ISR tracking, consumer rebalancing and partition leadership. For HTTP or gRPC load, use k6, Gatling or Locust.
  • It isn’t a Kafka management UI. To browse topics, consumer groups and cluster state in a browser, use Kafka UI, which Kates deploys alongside the cluster.
  • It isn’t a production monitoring system. Kates runs in test and validation environments; monitor production with Prometheus and Grafana directly. Kates deploys both too, for its own observability.

1.7 Summary

  • Kates pairs performance testing with chaos engineering and speaks Kafka: it sets producer acknowledgments and tracks ISR state and partition leadership.
  • Production readiness spans performance, resilience and data integrity, and Kates checks all three with repeatable tests against targets you set.
  • You can connect the CLI to a running Kates API, start a LOAD run and find its report.
  • Every run is stored and exportable as JSON, CSV, JUnit XML or heatmap data, so results feed CI gates and trends.
  • Kates is a testing and validation platform, not a Kafka distribution, a management UI or a production monitoring system.

Next, Architecture & Design follows a LOAD run through those two halves: which part generates the load, where the faults come from, and where the Quick Start’s report is kept.

Back to top