Building Self-driving Kafka clusters using open source components
Slack standardized roughly 10 Kafka clusters (0.7 PB, 6.5 Gbps peak) onto Kafka 2.0.1 and automated their operation with Chef, Terraform ASGs, Consul-assigned Zookeeper IDs, Cruise Control, Kafka Manager and a Prometheus offset exporter. Hot spots were removed by making partition counts a multiple of broker count, balancing consumers, throttling replication bandwidth and moving partitions in small batches. Chaos testing with dark traffic showed recovery was limited by packets per second, which jumbo frames helped address. It also motivated a dedicated Zookeeper per Kafka cluster and a cut-over upgrade policy instead of in-place upgrades. Splitting the largest topics off a saturated 90-broker cluster onto d3en instances gave about 2.5x efficiency, cut worst-case log latency from about 1.5 hours to 3-4 minutes, and reduced monthly alerts from 71 to 9.
Related posts
- Achieving relentless Kafka reliability at scale with the Streaming Platform
Datadog Engineering mediumAdeptDatadog runs hundreds of Kafka clusters with millions of partitions and built the Streaming Platform, a control layer that decouples producers and consumers from specific clusters through "Streams" spanning clusters, AZs and Kubernetes environments. A custom coordinator, the Assigner, replaces Kafka's timeout-based group coordination with metric-driven, seconds-scale rebalancing and live failovers that create a new topic and drain the old one. Head-of-line blocking is removed with priority lanes, a dead-letter lane for poison pills, and multi-range offset tracking stored in commit metadata, which also carries ingestion timestamps to compute real-time time lag from __consumer_offsets. After zstd decompression bombs crashed consumers, the team built libstreaming, a Rust Kafka client with bindings for other languages, and rejected a gRPC proxy because of throughput and latency costs.
- How we built reliable log delivery to thousands of unpredictable endpoints
Datadog Engineering mediumAdeptDatadog's Log Forwarding avoids head-of-line blocking from Kafka's per-partition FIFO ordering by moving logs out of Kafka early into cloud object storage, grouped by destination. A stager service reads logs from Kafka and writes slice files of individually compressed per-destination slices, which it uploads and registers in a metadata store before committing Kafka offsets. A leader-elected planner builds lightweight forwarding tasks from eligible slices based on each destination's batching settings. Shipper workers range-read only the slices they need, send them to the endpoint and retry failures with exponential backoff, which gives per-endpoint isolation without a Kafka topic per destination and scales horizontally to gigabytes per second.
- How We Built Automated Capacity Testing for Kafka Consumers
Booking.com Engineering mediumAdeptBooking.com extended its HTTP capacity-testing platform to Kafka consumers by using partition assignment as the load knob: a custom priority-aware partition assignor shifts extra partitions onto one target instance step by step, reproducing failure-induced load concentration without killing healthy consumers. A Kafka capacity API translates the scheduler's abstract load ratio into concrete assignments, and a composite health check (liveness, CPU/memory headroom, consumer lag percentile, throughput and errors) decides when to stop and record the last healthy step. Scale commands carry a TTL lease so assignments revert automatically if the controller dies. Load steps are discrete at roughly 1/P of the topic, so effective ratios should be reported. Tests must also be serialized per consumer group because rebalances are group-wide, and the results make N-1 resilience policies testable and support right-sizing.
- Break Stuff on Purpose
Slack Engineering mediumAdeptSlack's internal Kibana cluster failed in January 2024 after running out of disk, a consequence of co-locating its Elasticsearch storage on the same hosts as the application. The rebuild exposed a nearly two-year-old unmonitored backup that failed to restore and an outdated runbook, so users' dashboards and visualizations were lost. The team added scheduled backups, checked S3 retention, rewrote runbooks, and then deliberately filled the disks on a development cluster to rehearse recovery. The drill succeeded but missed the one-hour recovery goal and surfaced missing firewall rules in infrastructure as code. A later Kubernetes migration finished with about 30 minutes of downtime, and the backup script became a CLI that restores from cloud storage with a single command.
- Slack’s Migration to a Cellular Architecture
Slack Engineering mediumAdeptSlack moved its critical user-facing services in us-east-1 to a cellular architecture where each availability zone is a cell that can be drained, after a 2021 gray-failure network outage in one AZ caused user-visible errors across all AZs. Services are "siloed": they receive traffic only from their own AZ and send traffic only to backends in that AZ. Draining therefore only requires redirecting user requests at the edge, not changing RPC clients written in Hack, Go, Java and C++. Edge Envoy load balancers use weighted clusters and RTDS weights pushed from Slack's xDS control plane, Rotor, so operators can shift traffic away from an AZ gracefully in seconds at 1% granularity, without depending on resources inside the failed AZ.