Kafka Streams Stateful Topology Tuning Prompt
Analyze a Kafka Streams application with state stores — RocksDB memory pressure, slow restore/rebalance, changelog bloat, and repartition-driven lag — and prescribe topology, standby, and RocksDB tuning that preserves correctness.
- Target user
- Backend and streaming engineers
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior Kafka engineer reviewing a stateful Kafka Streams application, producing a performance and stability analysis with a remediation plan to review before changes ship. I will provide: - Topology shape: the processing steps (map, filter, groupBy, join, windowed aggregation), how many state stores exist, and which operations force a repartition - Scale: number of application instances, `num.stream.threads` per instance, input topic partition count, and the resulting task count - State signals: state store sizes on disk, changelog topic sizes, RocksDB block-cache and write-buffer settings, and off-heap/RSS memory per instance - Stability signals: rebalance frequency, state restore time after a rebalance, whether `num.standby.replicas` is set, and any `LockException` or restore-consuming behavior in the logs - Lag picture: end-to-end lag, lag on internal repartition and changelog topics, and whether processing is falling behind during or after rebalances Your job: 1. **Map tasks to partitions** — establish the fixed relationship between input partitions, repartition topics, and stream tasks, and explain why total parallelism is capped by partition count regardless of thread or instance count. 2. **Find needless repartitions** — identify operations (rekeying before an aggregate, unnecessary `selectKey`/`map` that sets a new key) that create hidden repartition topics doubling network and state, and recommend restructuring to avoid them. 3. **Diagnose RocksDB memory** — determine whether off-heap RSS growth comes from unbounded RocksDB block cache and write buffers across many stores, and recommend a bounded shared cache via a `RocksDBConfigSetter` with concrete limits. 4. **Attack restore time** — quantify how long state restore from changelogs takes on rebalance, and recommend `num.standby.replicas`, changelog compaction/retention, and static membership (`group.instance.id`) to cut restore-driven downtime. 5. **Reduce rebalance impact** — check whether frequent rebalances (scaling, crashes, `max.poll.interval.ms` breaches during heavy processing) are the dominant cost, and recommend static membership, warmup replicas, and `max.poll` tuning. 6. **Right-size changelogs** — verify changelog topics are compacted, replicated, and retained correctly so restore is bounded and recovery is safe. 7. **Prescribe the fix** — give an ordered plan that preserves exactly-once/correctness: remove needless repartitions, bound RocksDB memory, add standby replicas and static membership, then scale threads/instances up to the partition ceiling. Output: (a) task-to-partition map, (b) repartition audit, (c) RocksDB memory analysis, (d) restore-time and rebalance plan, (e) changelog sizing, (f) prioritized remediation plan with concrete Streams and RocksDB settings. Advisory only; changing partition count on input topics breaks state-store key locality and typically requires a reset and reprocess — validate on a staging topology first.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Kafka Consumer Lag Investigation Prompt
Investigate and reduce growing consumer lag by isolating the root cause — slow processing, partition skew, GC pauses, or broker-side bottlenecks — then prescribe targeted fixes.
-
Kafka Client Quota and Throttling Design Prompt
Design produce, fetch, and request-percentage quotas per user/client-id so one noisy tenant cannot saturate broker network or CPU and starve others on a shared cluster.
-
Kafka Cost and Storage Footprint Optimization Prompt
Review a Kafka cluster's storage, replication, and retention footprint to cut disk and inter-broker/cross-AZ network cost without weakening durability guarantees.
-
Kafka Cruise Control Self-Balancing Setup Prompt
Configure LinkedIn Cruise Control goals, capacity model, and anomaly detection to keep partition load, disk, and leadership balanced automatically without manual reassignment JSON.
More Kafka prompts & error guides
Browse every Kafka prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.