Data Engineering · Module 09
Event streaming with Kafka
- Lessons
- 14
- Free
- 0
- Reading
- ~4 h
Your progress
0 / 14 lessons done
Sign in to trackLessons
- Event streaming: data as a continuous flowClick events, app logs and database changes arrive all day and never finish. Most data platforms put them into an event log first, so every team reads the same events without asking the app to send them twice.
- Kafka in practice: topics, partitions and offsetsEvery Kafka pipeline starts with a topic someone created, and most of its later problems trace back to that one command: too few partitions to keep up at peak, or too few copies to survive a broker going down. Reading a topic’s layout is also the first step in every Kafka incident.
- Kafka producers: keys, batching and acknowledgementsEvery event that reaches Kafka passes through a producer, and its settings decide whether a broker failure loses data, whether a retry duplicates it and whether a busy hour fits through at all. The defaults also differ between the Java and Python clients.
- Kafka consumers: groups, commits and rebalancingEvery reader of a Kafka topic, from an S3 sink to a Flink job, is a consumer in a group. When one restarts, the group hands its partitions over, and the commit rules decide whether records are skipped, read twice or left waiting.
- Delivery guarantees in Kafka pipelines“Exactly-once” is a setting in Kafka, but the numbers people read live in a database, a bucket or a warehouse. Whether a crash repeats or loses records there depends on how the last write is made, not on the setting.
- Share groups: using Kafka as a queueData teams often need a pool of workers for independent jobs: resizing images, calling an API per record, re-running a failed file. Kafka 4.2 and later can hand out those jobs one record at a time, so the team may not need a second messaging system.
- Event schemas and the schema registryEvery topic with more than one team on it has a contract, written down or not. A schema registry writes it down and refuses changes that would break a reader, before the change reaches the topic.
- Kafka Connect: moving data in and outMost data in a Kafka platform enters or leaves through Kafka Connect: database changes come in through source connectors, and topics land in S3 or a warehouse through sink connectors. Its settings decide how many files the lake gets, and whether one bad record stops the copy.
- Retention, compaction and replaying eventsSooner or later a consumer ships with a bug and a day of its output is wrong. Whether you can fix that by reading Kafka again, and how much disk that ability costs, is decided by settings most teams leave at their defaults.
- Partition keys and ordering guaranteesKafka promises order only inside a partition, so the key decides which events a consumer sees in order and which it doesn’t. A wrong key, one busy key or a partition count changed in a hurry turns into wrong numbers or wrong messages to customers, often without a single error.
- Operating Kafka: lag, scaling and broker failuresA Kafka cluster rarely fails all at once. A reader falls behind, a broker disappears at the busiest hour, a new broker sits empty. The engineer on call has to tell which of these needs action now, and lag and a few broker counters are how they tell.
- Case: PhonePe’s Kafka at 100 billion events a dayMost teams that run Kafka for long enough meet PhonePe’s problems in a smaller form: producers that can’t afford to lose events, readers that slow down writers, and no clear signal for when to add brokers. Knowing which fixes match which scale keeps a small platform from copying a large one.
- Managed streaming services or self-hosted KafkaEvery team that runs Kafka is asked, sooner or later, why it doesn’t pay a cloud provider to run it. Answering well means pricing your own traffic, not a vendor’s example, and knowing which work never leaves your team.
- Design: a clickstream pipeline for an online storeMost online products send a click stream to a data platform, and the same handful of choices decide whether it survives a sale: the key, the partition count, the acknowledgements, the schema rules, the sink’s files and the alerts. This lesson puts them on one page, so you can defend each one and know what breaks when it’s wrong.
Practise with
No tools or paper guides for this module yet.
Terms this module teaches 43
Open glossaryacks (producer acknowledgements)
The Kafka producer setting that decides when the leader broker confirms a write: never (0), after its own write (1), or after every in-sync replica has it (all).
Acquisition lock
The time limit during which a record handed to one share group member can’t be given to another. If the member doesn’t accept, release or reject the record in time, it becomes available again. 30 seconds by default in Kafka 4.4.
Apache Kafka
An open-source event streaming platform that stores events in ordered, replicated logs that many readers can consume.
At-most-once delivery
A delivery guarantee where a message is never delivered twice, but a failure may lose it.
Availability zone
One of several separate data centres inside a cloud region, with its own power and network, so a failure in one usually leaves the others running.
Connect task
One unit of copying work in Kafka Connect; a connector splits its job into at most tasks.max tasks, and a sink task owns some of the topic’s partitions.
Connect worker
A Kafka Connect process that runs connectors and their tasks; in distributed mode, workers with the same group.id form one cluster and share the tasks.
Consumer
A program that reads events from an event log, moving forward from a position it remembers. Reading does not remove the events.
Consumer rebalance
The process in which a Kafka consumer group changes which member owns which partition, after a member joins, leaves, fails or stops polling, or the topic gains partitions.
Converter (Kafka Connect)
The Kafka Connect component that turns the bytes stored in Kafka into typed records with a schema, and back; keys and values each have one.
Cost attribution
Measuring how much of a shared platform each team uses and assigning the matching cost to that team.
Cross-zone data transfer
Data that moves between availability zones in one cloud region, billed per GB in each direction.
Delivery count
How many times a share group has handed a record to a member. When it reaches the group’s limit (5 by default in Kafka 4.4), the record is archived instead of offered again, and goes to the dead-letter topic if one is set.
Delivery report
The producer’s notice that a record was written or failed for good, passed to an application callback; in confluent-kafka it runs only inside poll() or flush().
Group coordinator
The Kafka broker that manages one consumer group: it tracks members through heartbeats, stores the group’s committed offsets and, under the new consumer protocol, computes which member owns which partition.
High watermark (Kafka)
The offset up to which every in-sync copy of a partition holds the records; consumers can read only below it.
Idempotent producer
A Kafka producer mode in which each batch carries a producer id and sequence number, so a broker can discard a retried batch it has already written.
In-flight requests (Kafka producer)
How many produce requests a Kafka producer may have sent to one broker without a reply yet, set by max.in.flight.requests.per.connection; above 1, retries can reorder records unless idempotence is on.
Kafka API-compatible
A streaming system built on its own engine that speaks Kafka's network protocol, so Kafka clients can read and write to it.
Kafka broker
A Kafka server that stores copies of partitions and answers producers’ writes and consumers’ reads.
Kafka Connect
Kafka’s framework for running connectors that copy data into Kafka from other systems, or out of Kafka into them, without writing producer or consumer code.
Kafka controller
A Kafka server that keeps the cluster’s metadata in a KRaft log and decides which broker leads each partition.
Kafka producer
The client library an application uses to write records to Kafka topics; it picks each record’s partition, batches records and retries failed sends.
Kafka transaction
A group of writes to Kafka partitions, optionally with a consumer group’s offsets, that a transactional producer commits or aborts as one unit.
Log end offset
The offset a Kafka partition’s leader will give the next record it writes.
Log segment
One file in a Kafka partition’s log, holding a run of records in offset order; the broker appends to the active segment and deletes or compacts only closed ones.
Managed Kafka service
Kafka run for you by a provider, which takes over the servers, disks, broker failures and upgrades while you keep topics, clients and schemas.
MirrorMaker 2
Kafka’s tool for copying topics, their settings and consumer group offsets from one Kafka cluster to another, built on Kafka Connect.
Partition leader
The one copy of a Kafka partition that takes all writes; the other copies fetch from it, and one of them takes over if it fails.
Partition reassignment
Moving copies of Kafka partitions from some brokers to others, usually to fill new brokers or empty old ones, while the cluster keeps serving.
Partitioner
The part of a Kafka producer that chooses a record’s partition, usually by hashing its key; the hash function differs between clients unless configured.
read_committed (Kafka)
A Kafka consumer setting, isolation.level=read_committed, under which the consumer returns only records from committed transactions and skips aborted ones.
Record batch
A group of records for one Kafka partition that a producer sends, and a broker stores, as one unit; it closes when full or when linger.ms has passed.
Schema id
The number a schema registry assigns to a schema. A Kafka record carries it in its first bytes, so a reader can fetch the exact schema that wrote the record.
Schema subject
A named list of schema versions in a schema registry, checked against each other under one compatibility mode. By default a Kafka serializer names it after the topic plus -value or -key.
Single message transform (SMT)
A small Kafka Connect function that changes one record at a time, such as adding, renaming or dropping a field or changing the topic name; transforms chain in a set order.
Sink connector
A Kafka Connect connector that reads records from Kafka topics and writes them to another system; its tasks form one consumer group.
Source connector
A Kafka Connect connector that reads from another system and writes records into Kafka topics.
Tiered storage
A Kafka feature that copies closed log segments to remote storage such as S3 and keeps only recent segments on the brokers’ disks, so a topic can keep longer history.
Transactional ID
The name a Kafka producer sets with transactional.id so the transaction coordinator recognises it across restarts, finishes its open transaction and rejects any older instance still using the same name.
Under-replicated partition
A Kafka partition with fewer in-sync copies than copies in total. It still serves reads and writes, but has less room for the next failure.
Zombie consumer
A consumer that the group has already removed but that keeps working, so it can still write results for partitions now owned by another member.