Skip to Content
Apache Spark によるストリーム処理
book

Apache Spark によるストリーム処理

by Gerard Maas, Francois Garillot
May 2025
Intermediate to advanced
452 pages
6h 3m
Japanese
O'Reilly Media, Inc.
Content preview from Apache Spark によるストリーム処理

第16章. Sparkストリーミングを導入する

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

Spark Streamingは、Sparkの分散処理機能の上に構築された最初のストリーム処理フレームワークであり、今日では、大規模なデータストリームを処理するために業界で広く採用されている成熟したAPIを提供している。

Sparkは、設計上、マシンのクラスタ上に分散したデータを処理するのが得意なシステムである。 Sparkの核となる抽象化であるレジリエンス分散データセット(RDD)とその流暢な関数型APIは、分散データをコレクションとして扱うプログラムの作成を可能にする。 この抽象化によって、分散データセットの変換という形でデータ処理ロジックを推論することができる。 そうすることで、スケーラブルな分散データ処理プログラムの作成と実行に必要だった認知負荷が軽減される。

Spark Streamingは、Sparkの分散コンピューティング機能をストリーム処理に適用することで、連続的なデータストリームをSparkが演算子として使用できる個別のデータコレクションに変換するという、シンプルかつ強力な前提に基づいて作成された。

図16-1を見るとわかるように、 、Spark Streamingの主なタスクは、ストリームからデータを取得し、それを小さなバッチにパッケージングし、さらに処理するためにSparkに提供することである。 出力はその後、下流のシステムに出力される。

spas 1601
図16-1. SparkとSpark Streamingの動き

Dストリームの抽象化

Part IIで学んだ Structured Streamingが、Spark SQLの抽象化であるDataFrameDataset の上にストリーミング機能を構築しているのに対して、Spark StreamingはRDDというもっと基本的なSparkの抽象化に依存している。 同時に、Spark Streamingは新しい概念である離散化ストリームDiscretized StreamまたはDStream)を導入している。 DStreamは、図16-2でわかるように、ストリームをデータの離散的なブロックで表し、それが時間経過とともにRDDとして表現される。

spas 1602
図16-2. Spark StreamingにおけるDStreamとRDD

DStream抽象化は主に実行モデルであり、関数型プログラミングモデルと組み合わせることで、ストリーミング・アプリケーションを開発・実行するための完全なフレームワークを提供する。

プログラミング・モデルとしてのDStreams

DStreamsの コード表現は、RDD APIと一貫性のある機能的なプログラミングAPIを提供し、集約、時間ベースの操作、ステートフルな計算を処理するためのストリーム固有の関数で補強されている。 Spark Streamingでは、SocketInputStream ...

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Apache Flinkによるストリーム処理

Apache Flinkによるストリーム処理

Fabian Hueske, Vasiliki Kalavri

Publisher Resources

ISBN: 9798341650602