100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Big Data & Distributed Computing
35 minintermediate

Spark Structured Streaming Fundamentals

Spark Structured Streaming is a fault-tolerant, exactly-once stream processing engine built on the Spark SQL execution engine. It models a live data stream as an unbounded table that grows continuously — each new batch of arriving data appends rows to this table — and allows users to express streaming queries using the same DataFrame and SQL API used for batch processing. This unified API means a Spark engineer who knows batch DataFrame transformations can write streaming pipelines immediately, with the framework handling state management, fault recovery, and output consistency automatically.

The key design insight of Structured Streaming is that a streaming query is a continuously running batch job: Spark periodically polls the source for new data, processes it using the same Catalyst-optimised plan as a batch query, and writes results to the output sink. The trigger interval controls how frequently this micro-batch runs — from 500ms to hours. This micro-batch model sacrifices true event-at-a-time latency (minimum ~100ms) for the simplicity and correctness guarantees of the batch execution model, making Structured Streaming the right choice for most analytics streaming workloads.

Analogy🏏Cricket
🏏 Think of it like cricket: Imagine the DRS review system deployed across three independent video-review centres in Mumbai, Chennai, and London, each holding a copy of the ball-tracking data. A CAP partition is a network outage that cuts communication between them. A CP system says: if the centres cannot synchronise, no review decision is issued — no player walks until the system is restored. Consistency is guaranteed; availability is sacrificed. An AP system says: each centre issues its own decision based on its local data, even if that means Mumbai says out and London says not out — reviews continue but different centres may give different verdicts. Partition tolerance is non-negotiable because the network always has the possibility of failing; the choice is whether umpires wait for consensus or proceed with local data.
Lesson 25 of 35
0% complete