Home

Awesome

Spark Internals

Spark Version: 1.0.2 Doc Version: 1.0.2.0

Authors

Weibo/Twitter IDNameContributions
@JerryLeadLijie XuAuthor of the original Chinese version, and English version update
@juhanlolHan JUEnglish version and update (Chapter 0, 1, 3, 4, and 7)
@invkrhHao RenEnglish version and update (Chapter 2, 5, and 6)
@AorJoaBhuridech SudseeThai version

Introduction

This series discuss the design and implementation of Apache Spark, with focuses on its design principles, execution mechanisms, system architecture and performance optimization. In addition, there's some comparisons with Hadoop MapReduce in terms of design and implementation. I'm reluctant to call this document a "code walkthrough", because the goal is not to analyze each piece of code in the project, but to understand the whole system in a systematic way (through analyzing the execution procedure of a Spark job, from its creation to completion).

There're many ways to discuss a computer system. Here, We've chosen a problem-driven approach. Firstly one concrete problem is introduced, then it gets analyzed step by step. We'll start from a typical Spark example job and then discuss all the related important system modules. I believe that this approach is better than diving into each module right from the beginning.

The target audiences of this series are geeks who want to have a deeper understanding of Apache Spark as well as other distributed computing frameworks.

I'll try my best to keep this documentation up to date with Spark since it's a fast evolving project with an active community. The documentation's main version is in sync with Spark's version. The additional number at the end represents the documentation's update version.

For more academic oriented discussion, please check out Matei's PHD thesis and other related papers. You can also have a look at my blog (in Chinese) blog.

I haven't been writing such complete documentation for a while. Last time it was about three years ago when I was studying Andrew Ng's ML course. I was really motivated at that time! This time I've spent 20+ days on this document, from the summer break till now (August 2014). Most of the time is spent on debugging, drawing diagrams and thinking how to put my ideas in the right way. I hope you find this series helpful.

Contents

We start from the creation of a Spark job, and then discuss its execution. Finally, we dive into some related system modules and features.

  1. Overview Overview of Apache Spark
  2. Job logical plan Logical plan of a job (data dependency graph)
  3. Job physical plan Physical plan
  4. Shuffle details Shuffle process
  5. Architecture Coordination of system modules in job execution
  6. Cache and Checkpoint Cache and Checkpoint
  7. Broadcast Broadcast feature
  8. Job Scheduling TODO
  9. Fault-tolerance TODO

Other languages

Chinese Version is at markdown/. Thai Version is at markdown/thai

How to read this document

The documentation is written in markdown. The pdf version is also available here.

If you're under Mac OS X, I recommand MacDown with a github theme for reading.

Gitbook (Chinese version)

Thanks @Yourtion for creating the gitbook version.

Online reading http://spark-internals.books.yourtion.com/

Downloads

Examples

I've created some examples to debug the system during the writing, they are avaible under SparkLearning/src/internals.

Book version (NEW)

We have written a book named "The design principles and implementation of Apache Spark", which talks about the system problems, design principles, and implementation strategies of Apache Spark, and also details the shuffle, fault-tolerant, and memory management mechanisms. Currently, it is written in Chinese.

Book link: https://item.jd.com/12924768.html

Book cover: book cover

Book preface: https://github.com/JerryLead/ApacheSparkBook/blob/master/Preface.pdf

Acknowledgement

I appreciate the help from the following in providing solutions and ideas for some detailed issues:

Thanks to the following for complementing the document:

Weibo IDChapterContentRevision status
@OopsOutOfMemoryOverviewRelation between workers and executors and Summary on Spark Executor Driver's Resouce Management (in Chinese)There's not yet a conclusion on this subject since its implementation is still changing, a link to the blog is added

Thanks to the following for finding errors:

Weibo IdChapterError/IssueRevision status
@JoshuawangzjOverviewWhen multiple applications are running, multiple Backend process will be createdCorrected, but need to be confirmed. No idea on how to control the number of Backend processes
@_cs_cmOverviewLatest groupByKey() has removed the mapValues() operation, there's no MapValuesRDD generatedFixed groupByKey() related diagrams and text
@染染生起JobLogicalPlanN:N relation in FullDepedency N:N is a NarrowDependencyModified the description of NarrowDependency into 3 different cases with detaild explaination, clearer than the 2 cases explaination before
@zzl0Fisrt four chaptersLots of typos,such as "groupByKey has generated the 3 following RDDs",should be 2. Check pull requestAll fixed
@左手牵右手TELCache and Broadcast chapterLots of typosAll fixed
@cloud-fanJobLogicalPlanSome arrows in the Cogroup() diagram should be colored redAll fixed
@CrazyJvmShuffle detailsStarting from Spark 1.1, the default value for spark.shuffle.file.buffer.kb is 32k, not 100kAll fixed

Special thanks to @明风Andy for his great support.

Special thanks to the rockers (including researchers, developers and users) who participate in the design, implementation and discussion of big data systems.