Configure Apache Kafka Clusters
Domain 1, Configure Apache Kafka clusters, tests whether you can translate workload requirements into broker, topic and client settings, and whether you know which settings are static, which are dynamic, and where each one applies.
Static, dynamic and scoped configuration
server.propertiesis read at broker startup. Settings such asbroker.id/node.id,log.dirsandlistenersare static and need a restart.- Many properties can be changed at runtime with
kafka-configs.sh:--entity-type brokers --entity-name 0,--entity-type topics, or--entity-type clientsfor quotas. Dynamic entries live in cluster metadata and survive restarts. - Precedence: a topic override beats the broker default, and a client quota beats the broker default quota.
Replication and durability
The durability triangle is replication factor, min.insync.replicas and producer acks.
- With RF=3 and
min.insync.replicas=2, one broker may be lost andacks=allwrites still succeed. - Setting
min.insync.replicasequal to RF means any single broker outage blocks writes withNotEnoughReplicas. unclean.leader.election.enable=falseprotects durability; enabling it restores availability at the cost of silent data loss.replica.lag.time.max.mscontrols ISR eviction; a lagging follower that is evicted shrinks the effective ISR and can makeacks=allfail.
Log, retention and partitioning
log.dirsaccepts multiple directories; Kafka spreads partitions across them, so capacity planning must allow for imbalance rather than assuming perfect striping.- Retention (
log.retention.ms,log.retention.bytes) is enforced as segments are rolled and checked, solog.segment.bytesandlog.roll.msaffect how promptly disk space is reclaimed. num.partitionsanddefault.replication.factorapply mainly to auto-created topics. Partitions can be increased but never decreased.compression.typecan be set at producer, broker or topic level; broker-side recompression costs CPU, while producer-side compression saves network.
Worked example
A team runs topic orders with RF=3, min.insync.replicas=2, acks=all and 7-day retention, and wants to survive one broker failure without data loss. The setting combination already achieves this: two of three replicas must acknowledge. If they instead chose RF=2 with min.insync.replicas=2, a single broker failure would stop producers; the correct fix is RF=3, not lowering acks.
Traps
- Forgetting that
auto.create.topics.enable=truecreates topics with one partition and the broker default replication factor. - Lowering
acksto cure producer timeouts, converting a durability requirement into an outage risk. - Raising
min.insync.replicasabove the currently in-sync replica count during a rolling restart, which blocks writes. - Assuming a topic-level retention override follows the broker default after the override is deleted.