Offset Management
Offsets record a consumer’s position within a topic partition. Kafka can:- Auto-commit offsets at regular intervals
- Let you manually commit offsets for precise control
- Fault tolerance
- Seamless consumer restarts
- Exactly-once or at-least-once delivery semantics
Consider manual commits when you need tight control over message acknowledgment and processing guarantees.
Poison Pill
A poison pill is a malformed or unexpected message that can crash your consumer and stall the pipeline. Best practices include:- Catch exceptions around message deserialization or processing
- Log the offending payload for analysis
- Route bad records to a dead letter queue (DLQ)
- Resume the pipeline without interruption
Failing to handle poison pills can halt downstream systems and lead to data loss.
Legacy Coordination: ZooKeeper
ZooKeeper has historically managed:- Cluster metadata
- Broker configurations
- Leader election
Modern Coordination: KRaft (Kafka Raft)
KRaft is Kafka’s built-in consensus layer, replacing ZooKeeper by using the Raft protocol to handle:- Metadata storage
- Controller duties
- Simplified architecture
- Easier deployments in containers and Kubernetes
- Faster cluster scaling

Coordination Comparison
| Mechanism | Advantages | Drawbacks |
|---|---|---|
| ZooKeeper | Battle-tested, stable | Additional cluster to manage |
| KRaft | Native consensus, simpler deployments | Newer, evolving community |
KRaft in Action
With KRaft:- Brokers fetch metadata directly from the controller broker
- Eliminates ZooKeeper setup steps
- Speeds up cluster scaling
- Simplifies broker integration in dynamic environments (e.g., Kubernetes)
Security in Kafka
Kafka’s security stack includes:| Feature | Mechanism | Benefit |
|---|---|---|
| Encryption | TLS | Protects data in transit |
| Authentication | SASL (PLAIN, SCRAM, etc.) | Verifies client identity |
| Authorization | ACLs | Granular access control for topics/users |

We’ve now covered:
- Offset management strategies
- Handling poison-pill messages
- Cluster coordination with ZooKeeper vs. KRaft
- End-to-end security using TLS, SASL, and ACLs