Chapter 4. Apache Spark as a Stream-Processing Engine
In Chapter 3, we pictured a general architectural diagram of a streaming data platform and identified where Spark, as a distributed processing engine, fits in a big data system.
This architecture informed us about what to expect in terms of interfaces and links to the rest of the ecosystem, especially as we focus on stream data processing with Apache Spark. Stream processing, whether in its Spark Streaming or Structured Streaming incarnation, is another execution mode for Apache Spark.
In this chapter, we take a tour of the main features that make Spark stand out as a stream-processing engine.
The Tale of Two APIs
As we mentioned in “Introducing Apache Spark”, Spark offers two different stream-processing APIs, Spark Streaming and Structured Streaming:
- Spark Streaming
-
This is an API and a set of connectors, in which a Spark program is being served small batches of data collected from a stream in the form of microbatches spaced at fixed time intervals, performs a given computation, and eventually returns a result at every interval.
- Structured Streaming
-
This is an API and a set of connectors, built on the substrate of a SQL query optimizer, Catalyst. It offers an API based on
DataFrames and the notion of continuous queries over an unbounded table that is constantly updated with fresh records from the stream.
The interface that Spark offers on these fronts is particularly rich, to the point where this book devotes large ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access