Data Engineering · Module 10
Stream processing with Flink
- Lessons
- 13
- Free
- 0
- Reading
- ~4 h
Your progress
0 / 13 lessons done
Sign in to trackLessons
- Stream processing: computing on data in motionLive dashboards, fraud signals and real-time features all need counts that stay correct while events keep arriving and machines keep failing. A stream processor such as Flink is where most data teams put that logic, instead of writing their own consumer loop for each metric.
- Event time vs processing timeEvery streaming job that counts per minute or per second has to pick a clock. Pick the wrong one and the numbers look fine on a quiet day, then jump the moment the job restarts or falls behind.
- Windows: tumbling, sliding and sessionEvery live count on a stream, from a dashboard tile to a fraud signal, is a window. The type you pick decides how fresh the number is, how many rows you write and how much memory the job holds, and a wrong argument order gives a number that looks fine and means something else.
- Watermarks: deciding when late events stop countingEvery event-time job decides, millisecond by millisecond, when it has seen enough to publish a result. Get the watermark wrong and a dashboard either freezes, as Kartly’s did for four hours, or quietly undercounts every minute.
- Stateful stream processing and state backendsEvery streaming job that counts, joins or remembers anything keeps state. Where that state lives, and whether it ever shrinks, decides whether the job runs for months or falls over a week after launch.
- Checkpoints: recovering without losing resultsEvery streaming job crashes sooner or later. Whether the numbers people read stay right after the restart depends on the checkpoint, the sink and how the job is upgraded, not on the crash.
- Flink architecture: jobs, tasks and slotsEvery Flink job you deploy asks you for a parallelism and a number of slots, and every streaming outage you debug happens in one of its processes. Knowing how operators become tasks and tasks land in slots is how you size a job for a sale, and how you read its web UI when it falls behind.
- Flink SQL: streaming with SQLMany streaming jobs are a source, a filter, a window and a sink, and SQL says that in a dozen lines that analysts can read and review. The catch is that some SQL queries keep changing their answers, and your sink decides whether that works or fails.
- Stream joins and enrichmentAlmost every streaming job needs data its events don’t carry: a category, a customer’s tier, the order that followed a click. The join you pick decides how much state the job holds, how much load it puts on a database, and whether a replay gives the same answer twice.
- Flink, Spark Streaming or Kafka StreamsMost teams that start streaming already run Spark or Kafka. Before adding a third system, someone asks whether the tools they have can do the job, and the honest answer depends on the job’s latency, its state and who will run it.
- Scaling and operating streaming jobsA streaming job that works on a normal day meets its real test at the busiest hour of the year. The engineer on call has minutes to find which operator is slow, whether more machines will help, and how to add them without losing the job’s state.
- Case: Razorpay’s fraud checks in 200 ms with FlinkFraud checks, credit decisions and abuse filters all need a verdict while a person waits, built from that person’s recent history. Razorpay’s design shows which parts of that problem a stream processor solves well, and which ones it moves somewhere else.
- Design: real-time fraud signals for paymentsFraud checks, rate limits and “too many tries” warnings all need a count that is seconds old, read in a few milliseconds, inside someone else’s request. Building one means choosing where the count is made, where it is stored, and what the request does when either is missing.
Practise with
No tools or paper guides for this module yet.
Terms this module teaches 46
Open glossaryAllowed lateness
How long after a window fires a stream processor still accepts its late events and fires the window again with updated results.
Apache Flink
An open-source stream processor that runs continuously over events, keeping state and counting by event time.
Async I/O (Flink)
A Flink operator that calls an outside service without blocking, keeping many requests waiting at once and passing each result on when it returns.
Card fingerprint
A token from the payment provider that is the same every time the same card is used, so a store can recognise a card without keeping its number.
Changelog stream
The ordered list of changes to a query’s result (inserts, retractions of old rows, new versions and deletes) that a streaming engine sends to its sink.
Changelog topic
A compacted Kafka topic where Kafka Streams writes every update to a local state store, so another instance can rebuild the store after a failure.
Checkpoint alignment
In an aligned Flink checkpoint, the wait at an operator with several inputs until the checkpoint barrier has arrived on every input, before it snapshots its state.
Checkpoint barrier
A marker Flink sends through a job in line with the records, splitting the stream into the part a checkpoint includes and the part after it.
Complex event processing (CEP)
Finding a sequence of events that meet conditions in a set order, within a time limit, in a continuous stream, and acting on each match.
Continuous query
A query over a dynamic table that never finishes and keeps its result up to date as new rows arrive.
Cumulative window
A window with a fixed start whose end grows by a step until it reaches its full size, emitting a result at each step.
Dynamic table
A table whose rows change over time, such as a Kafka topic read by Flink SQL, which gains a row with every record.
Flink autoscaler
Part of the Flink Kubernetes Operator that measures how busy each operator is and changes its parallelism, so that normal load uses a target share of capacity and backlogs clear within a set time.
Flink Kubernetes Operator
Apache Flink’s Kubernetes controller that turns a FlinkDeployment resource into a running Flink cluster and handles its upgrades, savepoints and rescaling.
Incremental checkpoint
A checkpoint that uploads only what changed since the last completed checkpoint and refers to the files it shares with earlier ones.
Interval join
A join of two append-only streams on a key plus a time condition that bounds both sides, so the stream processor can drop rows once no later row can match.
JobManager
The Flink process that coordinates a job: it hands out task slots, schedules subtasks into them, triggers checkpoints and restarts work after a failure.
Kafka record timestamp
The time stored with each Kafka record: by default the time the producer created it (CreateTime), or the time the broker appended it if the topic uses LogAppendTime.
Key group
One of a fixed number of buckets Flink hashes keys into; subtasks own ranges of key groups, and their count is the job’s maximum parallelism.
Keyed state
Values a stream processor keeps for each key of a partitioned stream, such as a count per product or the last click per device, read and written only by the task that owns that key.
Lookup join
A stream join that queries an external table, such as a database, for each arriving row at processing time, usually through a cache, instead of keeping the table in the stream processor’s state.
Managed memory (Flink)
Memory outside the Java heap that a Flink TaskManager reserves for components such as the RocksDB state backend, sorting and hash tables.
Operator chaining
Flink running neighbouring operators in one thread as one task, passing records by function call instead of through buffers.
Operator ID (uid)
A fixed name set with uid() on a step of a Flink job, which Flink uses to match saved state to that step when the job is restored from a savepoint.
Out-of-order event
An event that reaches a stream processor after an event with a later event time, so arrival order disagrees with the order things happened.
Real-time Mode (Spark)
A Spark Structured Streaming trigger, added in Spark 4.1, where records flow through long-running tasks instead of micro-batches, for latency of milliseconds.
Repartition topic
An internal Kafka topic Kafka Streams writes records to, under a new key, so records with the same new key reach the same task.
Savepoint
A snapshot of a Flink job’s state that a person or tool takes on purpose, kept until deleted, and used to restart the job after a code change, rescaling or upgrade.
Session window
A window per key that has no fixed edges: it starts with an event and stays open until no event arrives for a set gap, merging events closer than the gap.
Side output
A second output stream from a stream operator, for records that don’t belong in its main result, such as events that arrive after their window closed.
Sliding window (stream)
A fixed-size time window that starts every slide interval, so windows overlap and each event is counted in size ÷ slide of them. Flink SQL calls it HOP.
Slot sharing
Flink placing one subtask of each task of a job in the same slot, so the job needs as many slots as its highest parallelism.
Source idleness
Marking a source partition that has sent nothing for a set time as idle, so its stalled watermark stops holding back the job’s watermark.
Spark Structured Streaming
Spark’s streaming engine: it treats a stream as a growing table and, by default, processes it as a series of small Spark jobs called micro-batches.
State backend
The part of a stream processor that decides where a job’s state is stored, such as objects in memory or an on-disk key-value store, and how it is written into checkpoints.
State store
A key-value store a streaming engine keeps next to each task for running values such as counts, with a copy kept elsewhere for recovery.
State TTL
A time-to-live on a stream processor’s state: a value is treated as gone once a set time has passed since it was last written, and is removed later in the background.
Stream operator
One step in a stream processing job: it takes events in, may keep state, and sends results on to the next step.
Subtask
One parallel copy of a Flink task, run as one thread in a task slot; a task at parallelism 12 has 12 subtasks.
Task slot (Flink)
A fixed share of a TaskManager’s managed memory where subtasks run; slots split memory, not CPU.
TaskManager
A Flink worker process that runs subtasks in its task slots, holds their state and exchanges records with other TaskManagers.
Temporal join
A stream join that matches each event to the version of a row in a versioned table that was valid at the event’s time, written in Flink SQL with FOR SYSTEM_TIME AS OF.
Unaligned checkpoint
A Flink checkpoint in which barriers overtake buffered records and those in-flight records are saved as part of the state, so tasks don’t wait for all inputs’ barriers.
Valkey
An open-source in-memory key-value store that speaks the Redis protocol, used where reads must take about a millisecond.
Versioned table
A table with a primary key and a time column that keeps each row’s past versions, so a query can ask what a row was at a given moment.
Windowing table-valued function
A Flink SQL function that takes a table and returns its rows with window_start, window_end and window_time added, so a GROUP BY can count per window.