CCAAK Cheatsheet
Confluent Certified Administrator for Apache Kafka
Download free PDFKafka data, storage and replication
Records, topics and partitions
- A **record (message)** is Kafka's basic data unit. It can contain a key, value, timestamp and headers. A **topic** contains one or more partitions; each partition belongs to one topic.
- A **partition** is an ordered append-only log. Its **offsets** identify record positions within that partition; offsets are not global identifiers across topics or clusters.
- Ordering is guaranteed **within a partition**. Key-based partitioning commonly keeps related records together; increasing the partition count can change the key-to-partition mapping.
- **Partition leaders** spread producer and consumer traffic across brokers. Replicas provide redundant copies; adding replicas does not increase the number of independent partitions.
Segments, retention and compaction
- Each local partition replica has a **directory** containing multiple log segments and indexes. The active segment receives appends; segment rolling creates a new active segment.
- **cleanup.policy=delete** removes eligible old segments according to time or size retention. **retention.ms** controls age; **retention.bytes** limits retained log size per partition. Removal is asynchronous.
- **cleanup.policy=compact** eventually retains the latest value for each key. A **tombstone** is a record with a non-null key and null value, marking that key for deletion. Compaction requires keys.
- **delete,compact** combines both policies. Compaction leaves offset gaps and does not renumber surviving records. Producers append new records rather than editing an existing offset.
Storage sizing and replica placement
- Estimate **cluster log storage** as partition count × retained bytes per partition × replication factor. If given daily ingestion, multiply by retention days. Allow extra space for indexes, segment granularity and operational headroom.
- For balanced placement, **average storage per broker** is total replicated storage divided by broker count. Compression and uneven traffic can make actual usage differ from the estimate.
- **Replication factor (RF)** is the total number of copies, including the leader. RF 3 normally places three replicas on three different brokers; partition count alone does not protect against broker failure.
- Set **broker.rack** to identify a broker's failure domain. Rack-aware placement spreads replicas across available racks or zones. Broker count need not be odd; consensus quorum sizing is a separate concern.
- More partitions and segments consume **file descriptors**, memory, metadata and recovery time. Check open-file limits, disk throughput and expected replica counts before large partition increases.
ISR, acknowledgments and availability
- The **in-sync replica set (ISR)** contains replicas sufficiently caught up with the leader, including the leader itself. A configured replica can exist outside the ISR.
- **acks=all** waits for the current ISR to acknowledge the write. **min.insync.replicas** sets the minimum ISR size required for such writes; RF alone does not enforce this minimum.
- With **RF 3, min.insync.replicas=2 and acks=all**, one broker loss can still permit writes if two replicas remain in sync. A minimum ISR of 3 blocks these writes when any copy leaves the ISR.
- A writable partition and a readable partition have different conditions. **Insufficient ISR** can stop writes while existing committed data remains readable from an available leader.
- **Clean leader election** selects an eligible in-sync replica. **Unclean leader election** can restore availability by promoting an out-of-sync replica, with possible loss of previously acknowledged records.
Clients, performance and operations
Controller and cluster coordination
- In a **ZooKeeper-based cluster**, one broker is the active controller. ZooKeeper coordinates controller election and broker membership using ephemeral nodes; the controller broker can also host topic partitions.
- The **controller** manages partition leadership and replica-state changes. When a leader broker fails, it selects eligible replacement leaders and propagates metadata changes to brokers; clients refresh their metadata.
- A **controller epoch** identifies successive controller tenures and fences stale control actions. It is not a broker ID. Consumer partition assignment belongs to consumer-group coordination, not the controller.
- In **KRaft**, a controller quorum maintains the metadata log and elects one active controller. ZooKeeper-specific election and metadata-storage details apply only to ZooKeeper-based deployments.
Producer throughput and delivery
- **acks=0** requests no broker acknowledgment: it reduces acknowledgment overhead but cannot confirm broker receipt. **acks=1** waits for the leader; **acks=all** waits for the ISR and offers stronger durability with suitable replication settings.
- **batch.size** controls the target maximum batch size per partition in bytes. **linger.ms** allows time to accumulate records. Larger batches and a longer linger can improve throughput at the cost of latency and buffering.
- **compression.type** compresses record batches and can reduce network and storage use at a CPU cost. Existing uncompressed data does not prevent later compressed batches in the same topic.
- **Retries** can duplicate delivery unless producer idempotence is used. **Idempotence** protects against duplicates caused by producer retries; **transactions** extend atomicity across writes and consumed offsets.
- Tune from measured **latency, batch fill, request rate and errors**. delivery.timeout.ms bounds delivery time; send.buffer.bytes controls the socket buffer rather than the batching delay.
Consumer groups, offsets and lag
- Kafka consumers **pull** records with fetch requests. In a conventional consumer group, a partition is assigned to at most one active member; one member may handle several partitions.
- **Group parallelism** is bounded by subscribed partitions. Four consumers reading a two-partition topic leave two idle. Adding consumers can help a two-member group reading four partitions if processing is the bottleneck.
- Separate **consumer groups** maintain independent positions and each receive the stream. A new group does not share the processing load or committed offsets of an existing group.
- A **committed offset** is the next position the group should resume from. **auto.offset.reset** applies when no usable offset exists, such as first use or a position outside retention; earliest and latest choose reset positions.
- An offset removed by **compaction** can still be within the valid log range; fetching proceeds to available records without an offset reset. Offset gaps do not by themselves indicate a failed consumer.
- Use **kafka-consumer-groups.sh --bootstrap-server broker:9092 --describe --group app** to inspect committed offsets, log-end offsets and lag. Lag is an offset distance, not a direct elapsed-time measure.
Monitoring, maintenance and quotas
- Monitor **offline partitions, under-replicated partitions, ISR changes, disk space, request latency and consumer lag**. A partition showing **Leader: -1** has no current leader; inspect replica availability and broker health.
- Long **JVM garbage-collection pauses** can interrupt requests and heartbeats. In ZooKeeper mode, a pause exceeding session tolerance can make the broker appear dead and trigger leadership changes.
- A **graceful shutdown** flushes logs and attempts controlled leadership transfer to available replicas. For rolling maintenance, wait for replicas to catch up before stopping the next broker.
- Use **kafka-topics.sh** or an administrative API to delete a topic when deletion is enabled. Manually removing log files or consumer offsets is not a supported substitute for topic deletion.
- **Quotas** throttle producer bytes, consumer bytes or request resource use by configured client/user entities. They protect shared broker resources from monopolization; ACLs authorize actions and groups coordinate consumption.
Kafka security and access control
Listeners and encrypted transport
- Kafka listener security protocols are **PLAINTEXT, SSL, SASL_PLAINTEXT and SASL_SSL**. SSL is Kafka's protocol name for TLS. SASL is an authentication framework, not a complete listener protocol name.
- **PLAINTEXT** supplies neither transport encryption nor authenticated client identity. Authorization requires an authorizer and policies; do not assume a basic broker installation has these protections enabled.
- **listeners** defines bound endpoints; **advertised.listeners** supplies endpoints clients must reach. Named listeners use **listener.security.protocol.map** to map names to security protocols.
- Use separate **internal and external listeners** for appropriate endpoints and authentication settings. To migrate clients to TLS gradually, add a secure listener, migrate clients, then retire the plaintext listener.
- **TLS** encrypts traffic and authenticates the server. **Mutual TLS** additionally authenticates clients with certificates. REST clients can use **HTTPS** to secure communication with Confluent REST Proxy.
SASL authentication mechanisms
- Kafka supports **PLAIN**, **SCRAM-SHA-256/SCRAM-SHA-512**, **GSSAPI (Kerberos)** and **OAUTHBEARER**. Select a mechanism supported by both the client and broker configuration.
- **PLAIN** sends username/password credentials through SASL and should be protected with TLS. **SCRAM** uses a challenge-response exchange; TLS still protects application traffic.
- **GSSAPI** integrates Kerberos identities. **OAUTHBEARER** carries bearer tokens and requires suitable token acquisition and validation. Authentication establishes the principal; authorization determines its permissions.
ACL evaluation and metadata storage
- A Kafka **ACL** matches a principal, host, operation and resource pattern, with an Allow or Deny result. Brokers authorize relevant resource operations as requests are handled, rather than granting permanent access at connection time.
- For the built-in ACL authorizer, **super.users** bypass normal ACL checks. Otherwise, a matching **Deny** overrides Allow; a matching Allow is required under the normal default-deny configuration.
- **allow.everyone.if.no.acl.found** changes behavior for resources with no applicable ACLs. Keep this exception distinct from an explicit Deny and from superuser access.
- In ZooKeeper mode, **AclAuthorizer** stores ACLs in ZooKeeper and brokers cache them; older deployments used **SimpleAclAuthorizer**. In KRaft, **StandardAuthorizer** stores ACLs in cluster metadata.
- **RBAC** assigns permissions through roles and is distinct from Kafka's built-in ACL storage implementation. Enabling authentication alone does not define the operations a principal may perform.
Confluent integration and stream processing
Kafka Connect workers and tasks
- **Kafka Connect** integrates Kafka with external systems. A **source connector** imports records into Kafka; a **sink connector** exports records from Kafka. Connect workers execute connector tasks.
- **Distributed mode** coordinates work across workers and redistributes tasks after membership changes. **tasks.max** is an upper bound, not a guaranteed task count; actual parallelism depends on the connector and source.
- For a **table-polling JDBC source**, multiple tables can provide parallel work. Increasing tasks may help when one task is overloaded; adding workers alone cannot split a single task. Some CDC connectors remain single-task.
- Distributed workers use **config.storage.topic**, **offset.storage.topic** and **status.storage.topic**. Common names are connect-configs, connect-offsets and connect-status, but names are configurable.
- These internal topics use **compaction**; the config topic has one partition, while offset and status topics can have more. Replicate internal topics suitably. Converters control serialization independently of task assignment.
Schemas, REST access and replication
- **Schema Registry** stores and retrieves **Avro, JSON Schema and Protobuf** schemas through a REST interface. JSON Schema defines a schema language; arbitrary JSON is a data representation. gRPC is not a schema type.
- **Compatibility policies** govern schema evolution. Serializers and deserializers integrate schema IDs with record encoding; Schema Registry does not perform general stream transformations.
- **REST Proxy** exposes HTTP access to Kafka. **Replicator** copies records between clusters for migration or disaster recovery; it serves a different purpose from Kafka's in-cluster replica followers.
- Source and destination **offsets can differ** during cross-cluster replication. Do not compare equal numeric offsets as record identities. Plan offset translation or consumer failover explicitly and monitor replication lag.
Streams, ksqlDB and query types
- **Kafka Streams** is an application library for stream processing. **ksqlDB** offers SQL-based stream processing. Both support continuous transformations rather than merely storing or transporting records.
- Continuous processing suits **fraud detection, contextual recommendations and live fault monitoring**. Batch settlement and historical reporting have different latency requirements.
- A ksqlDB **stream** models events; a **table** models current keyed state. **CREATE STREAM/TABLE AS SELECT** and **INSERT INTO ... SELECT** create persistent processing that writes results to Kafka.
- A **push query** streams results to the requesting client; a **pull query** retrieves current materialized state. A plain CREATE TABLE registers a table definition; it does not by itself generate records. **INSERT INTO ... VALUES** writes supplied records.
Processing guarantees and sizing
- **At-least-once** processing can repeat records after failure. **Exactly-once** coordinates consumed offsets, state updates and Kafka output transactionally; arbitrary external side effects require their own guarantees.
- For supported ksqlDB deployments, set **ksql.streams.processing.guarantee=exactly_once_v2** in server properties. Older configurations may use exactly_once. **auto.offset.reset** chooses a starting position and does not provide exactly-once processing.
- Exactly-once protects the **read-process-write operation** from failure-induced duplicates. It does not automatically deduplicate distinct input records carrying the same business event.
- Size ksqlDB from **input rate and record/schema size**, query count and complexity, joins/windows, state size and input partition count. Retention and recovery needs affect storage; partitioning bounds useful processing parallelism.