CCAAK cheat sheet
CCAAK · Keep the key ideas within reach.
Configure Apache Kafka Clusters
num.partitions sets the default partition count for auto-created topics; it does not change existing topics, and per-topic partitions are fixed once created (only increase, never decrease).
replication.factor for auto-created topics comes from default.replication.factor; internal topics use offsets.topic.replication.factor, transaction.state.log.replication.factor, and transaction.state.log.min.isr.
min.insync.replicas works with acks=all: a produce fails with NotEnoughReplicas when fewer than min.insync.replicas in-sync replicas remain, so durability = min.insync.replicas vs replication.factor trade-off.
unclean.leader.election.enable=false preserves consistency by refusing to elect an out-of-sync replica; setting it true trades data loss for availability during outages.
log.retention.hours/bytes and log.segment.bytes interact: a segment is only deleted when it is closed and both time and size retention permit; log.retention.check.interval.ms controls scan frequency.
log.dirs may list multiple directories on distinct disks; Kafka spreads partitions across them but does not replicate within a broker, so a failed disk loses those partitions.
auto.create.topics.enable=true lets producers and consumers create topics implicitly; disabling it forces explicit topic creation and avoids accidental misconfigured topics.
listeners/advertised.listeners must be distinct per security protocol (PLAINTEXT, SSL, SASL_SSL); advertised.listeners is what clients and other brokers receive, so it must be routable from outside.
compression.type (producer, topic, broker) governs the on-disk and on-wire codec; broker-level compression.type=producer keeps producer-chosen codecs, while a fixed value recompresses batches.
Deploy Apache Kafka Clusters
KRaft mode replaces ZooKeeper: a controller quorum is configured via controller.quorum.voters (or bootstrap controllers), and node roles are set with process.roles=broker,controller or broker.
A KRaft cluster needs a formatted log directory (kafka-storage.sh format with a cluster ID from kafka-storage.sh random-uuid) before brokers or controllers start.
ZooKeeper deployments require a stable ensemble of odd size (3 or 5); zookeeper.connect lists all ensemble members and an optional chroot suffix.
broker.id must be unique and immutable per broker; in KRaft, node.id replaces broker.id and must match the controller quorum configuration.
Partition assignment across brokers uses rack awareness via broker.rack; with replica placement, replicas of one partition land on distinct racks when racks are declared.
Rolling upgrades require inter.broker.protocol.version and log.message.format.version to be pinned to the current version until all brokers run the new binary, then bumped and rolled again.
Capacity planning: total partitions per broker affect controller and metadata load; keep partition counts per broker bounded and size clusters for expected throughput plus headroom.
JVM heap for brokers is typically 6-8 GB with the rest left to the page cache; G1GC is the standard collector, and heap sizes above roughly 8 GB rarely help throughput.
Monitor Apache Kafka Clusters
UnderReplicatedPartitions (per broker) > 0 signals replicas lagging or offline; it is the primary health indicator and should normally be zero.
OfflinePartitionsCount > 0 means a partition has no leader and cannot serve clients; it is a critical alert condition.
ActiveControllerCount should equal exactly 1 across the cluster; 0 or more than 1 indicates a controller election problem or split brain.
IsrShrinksPerSec and IsrExpandsPerSec track replica churn; sustained shrinks indicate broker or network instability rather than normal operation.
RequestHandlerAvgIdlePercent below roughly 30% (or increasing request queue time) indicates broker saturation; correlate with NetworkProcessorAvgIdlePercent.
Consumer lag = log-end-offset minus committed consumer offset, exposed via kafka-consumer-groups.sh --describe and the consumer group metrics; lag growth is the key consumer health signal.
BytesInPerSec/BytesOutPerSec, MessagesInPerSec, and Fetch/Produce request latency (p99) describe throughput and latency; watch Produce request total time for slow acks.
LogFlushRateAndTimeMs and disk usage per log dir reveal I/O pressure; free disk below a threshold causes brokers to shut down partitions or fail writes.
Support Apache Kafka Clusters
kafka-consumer-groups.sh --describe shows CURRENT-OFFSET, LOG-END-OFFSET, LAG, and CONSUMER-ID per partition; --reset-offsets with --execute rewinds or advances a group.
A partition reassignment is executed with kafka-reassign-partitions.sh --execute and verified with --verify; throttle with --throttle to limit replication bandwidth.
Preferred leader election (kafka-leader-election.sh or auto.leader.rebalance.enable) restores leadership to the preferred replica after broker restarts.
kafka-topics.sh --describe reports leader, replicas, and ISR per partition; a shrinking ISR plus a stuck leader points to a broker that is down or unreachable.
kafka-log-dirs.sh and kafka-dump-log.sh inspect on-disk segment state; deletion of a topic's data is asynchronous after kafka-topics.sh --delete when delete.topic.enable=true.
Consumer rebalance storms are commonly caused by session.timeout.ms/heartbeat.interval.ms mismatch with processing time, or by max.poll.interval.ms being exceeded.
Message loss diagnosis: check acks setting, min.insync.replicas, unclean.leader.election.enable, and whether producers retried after NotEnoughReplicas or timeout exceptions.
Rolling restart procedure: restart one broker at a time, wait for UnderReplicatedPartitions to return to zero, and confirm the broker rejoins the ISR before proceeding.
Configuration
num.partitions applies only to auto-created topics; existing topic partition counts are immutable downward.
min.insync.replicas plus acks=all defines the durability contract for produce requests.
advertised.listeners must be reachable by clients and peer brokers, not just the local host.
log.dirs across multiple disks does not replicate data within a broker.
unclean.leader.election.enable=false favors consistency over availability.
auto.create.topics.enable=false prevents implicit topic creation with default settings.
Retention requires a closed segment plus elapsed time and size thresholds before deletion.
Internal topic replication factors are configured separately from default.replication.factor.
Deployment
KRaft requires kafka-storage.sh format with a cluster UUID before startup.
process.roles selects broker, controller, or both; node.id must be unique.
ZooKeeper ensembles should have an odd number of members for quorum.
broker.rack enables rack-aware replica placement across failure domains.
Rolling upgrades pin inter.broker.protocol.version until all brokers are upgraded.
Broker heap is typically 6-8 GB, leaving remaining RAM for the page cache.
Partition count per broker drives controller metadata and failover time.
controller.quorum.voters must list all controller nodes in KRaft mode.
Monitoring
UnderReplicatedPartitions should be zero in a healthy cluster.
OfflinePartitionsCount above zero blocks produce and consume for those partitions.
ActiveControllerCount must be exactly one cluster-wide.
Consumer lag equals log-end-offset minus committed offset.
RequestHandlerAvgIdlePercent below about 30% indicates saturation.
IsrShrinksPerSec spikes indicate broker or network instability.
p99 produce and fetch latency reveal slow acknowledgement paths.
Free disk per log dir is a leading indicator of broker failure.
Support
kafka-consumer-groups.sh --reset-offsets requires --execute to take effect.
kafka-reassign-partitions.sh --verify confirms reassignment completion.
Preferred leader election restores balance after broker restarts.
max.poll.interval.ms exceeded triggers a consumer rebalance and partition revocation.
A stuck ISR with a live leader points to a slow or unreachable follower.
Topic deletion is asynchronous and gated by delete.topic.enable.
Rolling restarts proceed one broker at a time, waiting for ISR recovery.
NotEnoughReplicas errors trace to min.insync.replicas versus live ISR size.