Mỗi partition có một leader và nhiều follower replica trên các broker khác nhau.
- Leader xử lý tất cả read/write, follower chủ động pull data từ leader để sync.
- ISR (In-Sync Replicas) là tập hợp các replica đang sync kịp với leader (không bị lag quá
replica.lag.time.max.ms). - Khi leader broker bị lỗi, một replica trong ISR sẽ được bầu làm leader mới.
- Cấu hình
replication.factor=3vàmin.insync.replicas=2kết hợp vớiacks=allđảm bảo message chỉ được acknowledge khi ít nhất 2 replica đã ghi — bảo vệ khỏi mất data kể cả khi 1 broker bị lỗi. - Trong production nên dùng
replication.factor >= 3để chịu được lỗi của 2 broker đồng thời.
Each partition has one leader and multiple follower replicas spread across different brokers.
- The leader handles all reads and writes; followers actively pull data from the leader to stay in sync.
- The ISR (In-Sync Replicas) is the set of replicas that are caught up with the leader (not lagging beyond
replica.lag.time.max.ms). - If the leader broker fails, one replica in the ISR is elected as the new leader.
- Setting
replication.factor=3andmin.insync.replicas=2combined withacks=allensures a message is only acknowledged after at least 2 replicas have written it — protecting against data loss even when 1 broker fails. - In production, use
replication.factor >= 3to tolerate simultaneous failure of 2 brokers.