Search code examples
apache-kafkakafka-consumer-apiapache-kafka-streams

Kafka local state store of multiple partitions


I am using kafka processor api and I create a state store from a topic of 3 partitions(I have 3 brokers), I have 1 instance of stream. I wonder to know when I get local state store, can I get all keys? Why certain keys work but certain don't? Is it normal? Thank you


Solution

  • The number of application instances does not matter for this case. Because the input topic has 3 partitions, the state store is created with 3 shards. Processing happens with 3 parallel tasks. Each task instantiates a copy of your topology, processes one input topic partition, and uses one shard.

    Compare: https://kafka.apache.org/21/documentation/streams/architecture

    If you want to access different shards, you can use "Interactive Queries" feature for key/value lookups (and key-range queried) over all shards.

    Also, the is the notion of a global state store, that would load data from all partitions into a single store (not sharding). However, it provided different semantics compared to "regular" stores, because store updates are not time-synchronized with the other processing.