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 によるストリーム処理

第6章 Sparkのレジリエンス・モデル

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

ほとんどの場合、ストリーミング・ジョブは長時間実行されるジョブである。 定義上、時間の経過とともに観測され、処理されるデータのストリームは、連続的に実行されるジョブにつながる。 データを処理するにつれて、データが処理システムを離れた後に再現するのが困難な中間結果を蓄積する可能性がある。 そのため、障害発生時のコストは相当なものになり、場合によっては完全な復旧は困難である。

分散システム、特にコモディティ・ハードウェアに依存するシステムでは、故障は規模の関数である。 システムが大きくなればなるほど、あるコンポーネントがいつでも故障する確率は高くなる。 分散ストリーム・プロセッサは、この故障の可能性を演算モデルに組み込む必要がある。

この章では、Apache Sparkプラットフォームが提供するレジリエンス、つまり部分的な障害をどのように回復できるか、また障害発生時にシステムを通過するデータに対してどのような保証が与えられるかを見ていく。 まず、Sparkのさまざまな内部コンポーネントと、それらのコアデータ構造との関係を概観することから始める。 この知識があれば、さまざまなレベルでの障害の影響と、そのような障害から回復するためにSparkが提供する手段を理解することができる。

Sparkにおけるレジリエンス分散データセット

Sparkは、 、Resilient Distributed Datasets(RDDs)上にデータ表現を構築する。2011年に発表された論文 "Resilient Distributed Datasets:RDDはSparkの基礎となるデータ構造であり、Sparkの強力な耐障害性保証はこの基礎レベルから始まる。

RDDはパーティション分割によって構成される。パーティション分割とは、個々のノードにストアされ、Sparkドライバによって追跡されるデータのセグメントであり、ユーザには位置透過的なデータ構造として提示される。

図6-1では、古典的なワードカウントアプリケーションをRDDを構成する様々な要素に分解している。

spas 0601
図6-1. 分散システムで表現されるRDD演算子

色のついたブロックはデータ要素であり、もともとは図の左端にある分散ファイルシステムに格納されている。 データはパーティション分割として格納され、ファイル内部では色のついたブロックの列として図示されている。 各パーティションはエクゼキュータに読み込まれ、横のブロックとして見える。 実際のデータ処理はエクゼキュータ内で行われる。そこでデータは、RDDレベルで説明された変換に従って変換される:

  • .flatMap(l => l.split(" ")) は文章をスペースで区切られた単語に分割する。

  • .map(w => (w,1)) は各単語を という形式のタプルに変換し、このようにして単語をカウントする準備をする。(<word>, 1)

  • .reduceByKey(_ + _) は、 をキーとしてカウントを計算し、付属の数値に合計演算を適用する。<word>

  • 最終的な結果は、部分的な結果を同じ ...

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