Sobes.tech
Middle+

What are partitions and replicas in Kafka?

sobes.tech AI

Answer from AI

In Apache Kafka, partitions are logical divisions of a topic that allow for scaling message processing and provide parallelism. Each topic is divided into several partitions, and each partition stores an ordered set of messages. Partitions enable load distribution among brokers and consumers.

Replicas are copies of partitions stored on different brokers to ensure fault tolerance. One replica is the leader, responsible for writing and reading data, while others are followers that synchronize data with the leader. If the leader fails, one of the followers becomes the new leader.

Example: if a topic has 3 partitions and a replication factor of 2, each partition will have 2 copies on different brokers, ensuring load balancing and reliability.