Nâng CaoKafka iconKafka

min.insync.replicas và acks=all kết hợp bảo vệ data như thế nào? Khi nào producer throw NotEnoughReplicasException?

acks=all yêu cầu leader đợi tất cả ISR (In-Sync Replicas) ghi xong mới acknowledge producer. min.insync.replicas (broker/topic config, default=1) quy định số replica tối thiểu trong ISR để accept write. Kết hợp tối ưu: replication.factor=3, min.insync.replicas=2, acks=all → message chỉ acknowledged khi ít nhất 2 replica ghi xong → chịu được 1 broker failure mà không mất data. NotEnoughReplicasException xảy ra khi ISR size < min.insync.replicas — ví dụ 2 trong 3 broker down, ISR chỉ còn 1 nhưng min.insync.replicas=2 → producer bị reject.

  • Đây là trade-off giữa availability và durability.
  • Nếu muốn availability hơn durability: giảm min.insync.replicas=1 (có thể mất data nếu leader fail trước follower sync).
  • Trong production tài chính: replication.factor=3, min.insync.replicas=2, acks=all là cấu hình bắt buộc.

Xem toàn bộ Kafka cùng filter theo level & chủ đề con.

Mở danh sách Kafka