SparkInternals

by JerryLead

JerryLead / SparkInternals

Notes talking about the design and implementation of Apache Spark

4.3K Stars 1.7K Forks Last release: Not found 168 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Spark Internals

Spark Version: 1.0.2 Doc Version: 1.0.2.0

Authors

| Weibo/Twitter ID | Name | Contributions | |:-----------|:-------------|:-------------| |@JerryLead | Lijie Xu | Author of the original Chinese version, and English version update | |@juhanlol | Han JU | English version and update (Chapter 0, 1, 3, 4, and 7) | |@invkrh | Hao Ren | English version and update (Chapter 2, 5, and 6)| |@AorJoa | Bhuridech Sudsee | Thai 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

  • PDF https://www.gitbook.com/download/pdf/book/yourtion/sparkinternals
  • EPUB https://www.gitbook.com/download/epub/book/yourtion/sparkinternals
  • MOBI https://www.gitbook.com/download/mobi/book/yourtion/sparkinternals

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:

  • @Andrew-Xia Participated in the discussion of BlockManager's implemetation's impact on broadcast(rdd).

  • @CrazyJVM Participated in the discussion of BlockManager's implementation.

  • @王联辉 Participated in the discussion of BlockManager's implementation.

Thanks to the following for complementing the document:

| Weibo ID | Chapter | Content | Revision status | |:-----------|:-------------|:-------------|:-------------| | @OopsOutOfMemory | Overview | Relation 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 Id | Chapter | Error/Issue | Revision status | |:-----------|:-------------|:-------------|:-------------| | @Joshuawangzj | Overview | When multiple applications are running, multiple Backend process will be created | Corrected, but need to be confirmed. No idea on how to control the number of Backend processes | | @_cs_cm | Overview | Latest groupByKey() has removed the mapValues() operation, there's no MapValuesRDD generated | Fixed groupByKey() related diagrams and text | | @染染生起 | JobLogicalPlan | N:N relation in FullDepedency N:N is a NarrowDependency | Modified the description of NarrowDependency into 3 different cases with detaild explaination, clearer than the 2 cases explaination before | | @zzl0 | Fisrt four chapters | Lots of typos,such as "groupByKey has generated the 3 following RDDs",should be 2. Check pull request。 | All fixed | | @左手牵右手TEL | Cache and Broadcast chapter | Lots of typos | All fixed | | @cloud-fan | JobLogicalPlan | Some arrows in the Cogroup() diagram should be colored red | All fixed | | @CrazyJvm | Shuffle details | Starting from Spark 1.1, the default value for spark.shuffle.file.buffer.kb is 32k, not 100k | All 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.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.