Kafka Resilience And Schema Evolution
Overview
Generic streaming guidance is not enough for production Kafka. Agents routinely introduce breaking schema changes, under-provisioned durability settings, and missing poison-message isolation. This skill mandates enforceable broker, producer, consumer, and registry guardrails before any production change ships.
When to Use
- creating or modifying
Kafka topics, producers, or consumers
- setting or changing schema registry compatibility policies
- designing dead-letter queue (DLQ) routing for poison pill messages
- hardening producer durability (
acks, retries, idempotence)
- reviewing consumer lag, replay, or failover behavior on Kafka-backed pipelines
Pair with streaming-and-messaging-systems for broader event design. Pair with avro-protobuf-json-schema-registry when registry subjects and compatibility CI are in scope.
Workflow
Define the production contract before broker changes.
Document:
- topic key strategy and partition count rationale
- retention, compaction, and replay policy
- schema format and registry subject naming
- consumer groups and downstream sinks
- delivery semantics target (at-least-once with idempotent sinks, or stricter)
Enforce producer durability defaults.
Require unless explicitly waived with owner approval:
acks=all (or acks=-1)
enable.idempotence=true when ordering and deduplication matter
- bounded
retries with delivery.timeout.ms aligned to SLA
max.in.flight.requests.per.connection=1 when strict ordering is required
- TLS/SASL configuration documented for non-development clusters
Block breaking schema evolution.
Before any schema change:
- set compatibility policy per subject (
BACKWARD, FORWARD, or FULL — not NONE in production)
- run compatibility checks in CI against registered schemas
- document producer-then-consumer or consumer-then-producer rollout order
- reject field removals, renames, or type changes without migration plan
- load
references/kafka-production-guardrails.md for DLQ and evolution patterns
Mandate dead-letter and poison pill isolation.
Every production consumer that parses external payloads must define:
- DLQ topic or sink with retention and access controls
- classification rules (deserialization failure, schema mismatch, business rule violation)
- alert routing when DLQ rate exceeds threshold
- replay procedure with deduplication keys
- no silent drop of unparseable records
Make lag and recovery observable.
Plan for:
- consumer group lag alerts with owner routing
- offset reset policy documented and restricted
- replay runbook that does not bypass DLQ classification
- broker disk and retention monitoring for high-throughput topics
Load MCP observability when diagnosing live lag.
Use mcp-data-observability-integration with mcp/kafka.mcp.json to inspect consumer group lag and topic metadata before changing consumer code or partition counts.
Common Rationalizations
| Rationalization |
Reality |
| "acks=1 is fine because Kafka is durable." |
Leader acknowledgment without full ISR acknowledgment loses events under failure scenarios. |
| "We can fix schema breaks by redeploying consumers quickly." |
Breaking changes propagate to many consumers and batch sinks before redeploy completes. |
| "DLQs add too much operational overhead." |
Poison pills without DLQs stall partitions, inflate lag, and hide data loss as consumer retries. |
| "Schema compatibility NONE is okay for internal topics." |
Internal topics still feed warehouses, stream processors, and audit systems. |
Red Flags
- production subjects use
NONE compatibility
- producers use
acks=0 or acks=1 without documented waiver
- consumers have no DLQ path for deserialization failures
- schema changes ship without CI compatibility validation
- consumer group lag has no alert owner
- replay procedures reset offsets without reconciliation or publish pause
Verification
1---2name: kafka-resilience-and-schema-evolution3description: Enforces production Kafka guardrails including non-breaking schema evolution, dead-letter queues for poison messages, and acks=all producer durability. Use when designing or changing Kafka topics, producers, consumers, schema registry policies, or streaming recovery paths.4---56# Kafka Resilience And Schema Evolution78## Overview910Generic streaming guidance is not enough for production Kafka. Agents routinely introduce breaking schema changes, under-provisioned durability settings, and missing poison-message isolation. This skill mandates enforceable broker, producer, consumer, and registry guardrails before any production change ships.1112## When to Use1314- creating or modifying `Kafka` topics, producers, or consumers15- setting or changing schema registry compatibility policies16- designing dead-letter queue (DLQ) routing for poison pill messages17- hardening producer durability (`acks`, retries, idempotence)18- reviewing consumer lag, replay, or failover behavior on Kafka-backed pipelines1920Pair with `streaming-and-messaging-systems` for broader event design. Pair with `avro-protobuf-json-schema-registry` when registry subjects and compatibility CI are in scope.2122## Workflow23241. Define the production contract before broker changes.25 Document:26 - topic key strategy and partition count rationale27 - retention, compaction, and replay policy28 - schema format and registry subject naming29 - consumer groups and downstream sinks30 - delivery semantics target (at-least-once with idempotent sinks, or stricter)31322. Enforce producer durability defaults.33 Require unless explicitly waived with owner approval:34 - `acks=all` (or `acks=-1`)35 - `enable.idempotence=true` when ordering and deduplication matter36 - bounded `retries` with `delivery.timeout.ms` aligned to SLA37 - `max.in.flight.requests.per.connection=1` when strict ordering is required38 - TLS/SASL configuration documented for non-development clusters39403. Block breaking schema evolution.41 Before any schema change:42 - set compatibility policy per subject (`BACKWARD`, `FORWARD`, or `FULL` — not `NONE` in production)43 - run compatibility checks in CI against registered schemas44 - document producer-then-consumer or consumer-then-producer rollout order45 - reject field removals, renames, or type changes without migration plan46 - load `references/kafka-production-guardrails.md` for DLQ and evolution patterns47484. Mandate dead-letter and poison pill isolation.49 Every production consumer that parses external payloads must define:50 - DLQ topic or sink with retention and access controls51 - classification rules (deserialization failure, schema mismatch, business rule violation)52 - alert routing when DLQ rate exceeds threshold53 - replay procedure with deduplication keys54 - no silent drop of unparseable records55565. Make lag and recovery observable.57 Plan for:58 - consumer group lag alerts with owner routing59 - offset reset policy documented and restricted60 - replay runbook that does not bypass DLQ classification61 - broker disk and retention monitoring for high-throughput topics62636. Load MCP observability when diagnosing live lag.64 Use `mcp-data-observability-integration` with `mcp/kafka.mcp.json` to inspect consumer group lag and topic metadata before changing consumer code or partition counts.6566## Common Rationalizations6768| Rationalization | Reality |69| --- | --- |70| "acks=1 is fine because Kafka is durable." | Leader acknowledgment without full ISR acknowledgment loses events under failure scenarios. |71| "We can fix schema breaks by redeploying consumers quickly." | Breaking changes propagate to many consumers and batch sinks before redeploy completes. |72| "DLQs add too much operational overhead." | Poison pills without DLQs stall partitions, inflate lag, and hide data loss as consumer retries. |73| "Schema compatibility NONE is okay for internal topics." | Internal topics still feed warehouses, stream processors, and audit systems. |7475## Red Flags7677- production subjects use `NONE` compatibility78- producers use `acks=0` or `acks=1` without documented waiver79- consumers have no DLQ path for deserialization failures80- schema changes ship without CI compatibility validation81- consumer group lag has no alert owner82- replay procedures reset offsets without reconciliation or publish pause8384## Verification8586- [ ] Producer durability settings meet `acks=all` and idempotence requirements87- [ ] Schema compatibility policy is set and CI-validated for production subjects88- [ ] DLQ routing, alerts, and replay procedure are documented89- [ ] Consumer lag and retention monitoring exist with named owners90- [ ] Rollout order for schema changes is explicit and tested in non-production