Configuring Kafka Streams
1. Setting Application ID
| Config | Description | Detail |
|---|---|---|
| application.id | Unique app identifier | = consumer group |
| Prefix | Internal topic names | app-id-... |
| Stable | Don't change in prod | Resets state |
2. Configuring Bootstrap Servers
| Config | Description | Detail |
|---|---|---|
| bootstrap.servers | Cluster entry points | Required |
| Multiple | List for resilience | Comma-separated |
| Discovery | Full cluster learned | Auto |
3. Setting Default Serdes
| Config | Description | Detail |
|---|---|---|
| DEFAULT_KEY_SERDE | Key serializer/deserializer | Class |
| DEFAULT_VALUE_SERDE | Value serde | Class |
| Override | Per-operator Consumed/Produced | Local |
Example: Default serdes
props.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG,
Serdes.String().getClass());
4. Configuring Commit Interval
| Config | Description | Default |
|---|---|---|
| commit.interval.ms | State commit frequency | 30000 / 100 (eos) |
| Lower | Less reprocessing on crash | More overhead |
| EOS | Defaults to 100ms | Tighter |
5. Setting Cache Size
| Config | Description | Default |
|---|---|---|
| statestore.cache. max.bytes |
Record cache for dedup NEW | 10MB |
| 0 | Emit every update | No dedup |
| Larger | Fewer downstream emits | More memory |
6. Configuring State Directory
| Config | Description | Default |
|---|---|---|
| state.dir | Local state location | /tmp/kafka-streams |
| Persistent | Use durable disk in prod | Not /tmp |
| Per-Instance | Unique per app instance | No sharing |
7. Setting Processing Guarantee
| Value | Description | Detail |
|---|---|---|
| at_least_once | Default, may dup | Fast |
| exactly_once_v2 | EOS via transactions | Recommended |
| Requirement | RF ≥ 3, min ISR 2 | Durability |
Example: Exactly-once
props.put(StreamsConfig.PROCESSING_GUARANTEE_CONFIG,
StreamsConfig.EXACTLY_ONCE_V2);
8. Configuring Replication Factor
| Config | Description | Prod |
|---|---|---|
| replication.factor | Internal topic RF | 3 |
| Applies To | Changelog + repartition | All internal |
| -1 | Use broker default | 3.x+ |
9. Setting Number of Threads
| Config | Description | Default |
|---|---|---|
| num.stream.threads | Processing threads | 1 |
| Parallelism | Bounded by partitions | ≤ tasks |
| Scaling | Add threads or instances | Rebalances |
10. Configuring Window Store Retention
| Aspect | Description | Detail |
|---|---|---|
| Materialized. withRetention |
Window store retain time | ≥ window + grace |
| windowstore. changelog.additional. retention.ms |
Changelog buffer | Default 1d |
| Expiry | Old windows dropped | Bounded state |