SlideShare a Scribd company logo
1 of 45
Download to read offline
Spark	
  
Introduction	
蘑菇街 FST - 天火
¡  分布式计算框架	
  
¡  等等,关我什么事?	
  
§  太多的分布式计算框架	
  
¡  因为它很Cool	
  
¡  所以你不想Out?	
  
¡  出身背景很Cool	
  
§  UC	
  Berkeley	
  AMPLab实验室	
  
¡  主要开发者很Cool	
  
§  DataBricks	
  
§  Intel	
  /	
  Yahoo	
  /	
  Cloudera	
  	
  
¡  应用场景很Cool	
  
§  ETL、OLAP、机器学习、基因⼯工程	
  
¡  开发语⾔言很Cool	
  
§  scala	
  
	
  
¡  很Cool的背景	
  
§  理论架构的先进性	
  
§  性能	
  
¡  很Cool的开发团队	
  
§  持续发展的动⼒力源泉	
  
	
  
¡  很Cool的应用场景	
  
§  活跃的社区	
  
§  不⾄至于成为屠龙之技	
  
¡  很Cool的开发语⾔言	
  
§  开发效率	
  
§  ⾼高(zhuang)逼格的资本 lol	
  
¡  快速从Apache	
  Incubator项目毕业成为
Apache顶级项目	
  
¡  ⼤大数据解决⽅方案提供商的支持	
  
§  Cloudera	
  /	
  MapR	
  	
  /	
  Hortonworks	
  /	
  Pivotal	
  /	
  SAP	
  …	
  
§  华为	
  /	
  星环科技	
  
¡  应用	
  
§  阿里/百度/爱奇艺/优酷/京东…	
  
¡  2014年⼤大数据领域最活跃的开源项目	
  
¡  分布式计算框架	
  
¡  基于内存的调度和运算模型	
  
¡  兼容Hadoop⽣生态环境	
  
§  数据存储格式	
  
§  Works	
  with	
  Hdfs/Yarn/Hive/Hbase/kaQa…	
  etc.	
  
¡  丰富的应用场景	
  
§  离线处理 /	
  实时计算	
  
§  SQL	
  /	
  机器学习 /	
  图计算	
  
¡  更加⾼高效和通用的编程模型	
  
§  相比MapReduce模型,更加适用于两种类型的
应用	
  
▪  迭代算法类(机器学习,图计算)	
  
▪  交互式数据挖掘	
  
¡  良好的用户体验	
  
▪  编程效率:基于Scala的核⼼心模块,提供Java/python编
程接⼝口	
  
▪  功能强⼤大的API,丰富的操作算⼦子	
  
▪  交互式的解释执⾏行接⼝口(调试,学习)	
  
 
Step Step Step Step Step
Client	
  
Step Step Step Step Step
Client	
  
¡  计算模型固定	
  
¡  每个MapReduce阶段之间需要落盘	
  
¡  容错性好
Map	
  
Map	
  
Map	
  
Reduce	
  
Reduce	
  
Input	
   Output	
  
Dryad-­‐like	
  DAGs	
  
Pipelines	
  functions	
  
within	
  a	
  stage	
  
	
  
Cache-­‐aware	
  work	
  
reuse	
  &	
  locality	
  
	
  
Partitioning-­‐aware	
  
to	
  avoid	
  shuffles	
  
join	
  
union	
  
groupBy	
  
map	
  
Stage	
  3	
  
Stage	
  1	
  
Stage	
  2	
  
A:	
   B:	
  
C:	
   D:	
  
E:	
  
F:	
  
G:	
  
=	
  cached	
  data	
  partition	
  
!
¡  Resilient	
  distributed	
  datasets	
  (RDDs)	
  
¡  http://dl.acm.org/citation.cfm?id=2228301	
  
§  不可变的,按分区组织的数据对象	
  
§  ⼀一个RDD可以通过各种(map,	
  filter,	
  groupBy,	
  
Join…)操作转换为另⼀一个RDD	
  
§  源头的RDD的数据来源可以是外部存储,如
HDFS,也可以动态⽣生成	
  
§  可以采用各种缓存⽅方式加速处理	
  
§  容错,	
  数据本地性,	
  可扩展性	
  
¡  分布式运算环境下的数据容错模型往往是影响
整个系统的核⼼心机制之⼀一	
  
¡  其它基于内存的类似计算框架系统采用细颗粒
度的数据备份或者LOG机制	
  
¡  RDD采用基于⾎血统关系(Lineage)的容错模型	
  
§  Lineage记录的是粗颗粒度的数据变换操作⾏行为	
  
§  当RDD的部分分区数据丢失时,它可以通过Lineage
信息重新运算和恢复丢失的数据分区。	
  
§  这种粗颗粒的数据模型,限制了Spark的运用场合,
但同时相比细颗粒度的数据模型,也带来了性能的
提升。
RDDs	
  maintain	
  lineage	
  information	
  that	
  can	
  be	
  
used	
  to	
  reconstruct	
  lost	
  partitions	
  
Ex:	
  
	
  
	
  
messages = textFile(...).filter(_.startsWith(“ERROR”))
Result = messages.map(_.split(‘t’)(2))
HDFS	
  File	
   Filtered	
  RDD	
   Mapped	
  RDD	
  
filter	
  
(func	
  =	
  _.startsWith(...))	
  
map	
  
(func	
  =	
  _.split(...))	
  
lines = spark.textFile(“hdfs://...”)
errors = lines.filter(_.startsWith(“ERROR”))
messages = errors.map(_.split(‘t’)(2))
cachedMsgs = messages.cache()
Block	
  1	
  
Block	
  2	
  
Block	
  3	
  
Worker	
  
Worker	
  
Worker	
  
Driver	
  
cachedMsgs.filter(_.contains(“foo”)).count
cachedMsgs.filter(_.contains(“bar”)).count
. . .
tasks	
  
results	
  
Cache	
  1	
  
Cache	
  2	
  
Cache	
  3	
  
Base	
  RDD	
  
Transformed	
  RDD	
  
Action	
  
¡  围绕RDD的概念,实现核⼼心运⾏行调度逻辑	
  
§  Scheduler:作业和任务的调度管理	
  
§  BlockManager:RDD/Shuffle等数据块的管理	
  
§  RDD:各种RDD数据结构表达和算法实现	
  
§  Shuffle:管理Shuffle逻辑和相关数据流程	
  
§  NetWork:跨节点数据通讯相关	
  
§  Yarn:	
  基于Yarn的任务调度管理模块	
  
§  其它…	
  
¡  其它各种上层模块都是基于Core的衍⽣生	
  
§  RDD核⼼心思想在不同领域的拓展和定制化实现	
  
§  RDD数据模型的通用性和灵活性,从本质上决
定了它很容易被应用到各种具体的编程模型上
¡  本质上是Micro-­‐batches	
  RDDs的处理	
  
§  相比于小Batch的Hadoop	
  Job,Task启动代价小,
latency低	
  
§  近实时(相比Storm)	
  
▪  默认200ms⼀一个批次	
  
§  吞吐率⾼高	
  
§  相对于其它模块,最早在业界得到应用	
  
§  与普通RDD批处理统⼀一的编程模型	
  
§  基于Lineage的容错模型	
  
§  丰富的数据源	
  
	
  
val	
  conf	
  =	
  new	
  SparkConf()	
  
val	
  ssc	
  =	
  new	
  StreamingContext(conf,	
  Seconds(1))	
  
val	
  lines	
  =	
  ssc.textFileStream(args(1))	
  
val	
  words	
  =	
  lines.flatMap(_.split("	
  "))	
  
val	
  result	
  =	
  words.map(x	
  =>	
  (x,	
  1)).reduceByKey(_	
  +	
  _).collect()	
  
ssc.start()	
  
val	
  conf	
  =	
  new	
  SparkConf()	
  
val ハsc ハ= ハnew ハSparkContext(conf)	
  	
  
val ハlines ハ ハ= ハsc.textFile(args(1))	
  	
  
val ハwords ハ= ハlines.fl゚atMap(_.split("	
  "))
val result = words.map(x ハ=> ハ(x, ハ1)).reduceByKey(_	
  +	
  _).collect()
n Hive-­‐like	
  interface(JDBC	
  
Service	
  /	
  CLI)	
  
n Both	
  Hive	
  QL	
  &	
  Simple	
  SQL	
  
dialects	
  are	
  Supported	
  
n DDL	
  is	
  100%	
  compatible	
  with	
  
Hive	
  Metastore	
  
n Hive	
  QL	
  aims	
  to	
  100%	
  
compatible	
  with	
  Hive	
  DML	
   Spark	
  Core	
  
Spark	
  Execution	
  Operators	
  
Catalyst	
  
Hive	
  QL	
   Simple	
  SQL	
  
SQL	
  API	
  CLI	
  
User Application	
JDBC	
  Service	
  
Data	
  Analyst
Hive	
  Meta	
  Store	
   Simple	
  Catalog	
  
n First	
  released	
  in	
  Spark	
  1.0	
  (May,	
  2014)	
  
n Initial	
  committed	
  by	
  Michael	
  Armbrust	
  &	
  
Reynold	
  Xin	
  from	
  Databricks	
  
¡  MLlib	
  机器学习算法库:	
  
§  Initial	
  contribution	
  from	
  AMPLab,	
  UC	
  Berkeley	
  	
  
§  Shipped	
  with	
  Spark	
  since	
  version	
  0.8	
  (Sep	
  2013)	
  	
  
¡  数据类型	
  
§  Dense	
  
§  Sparse	
  (	
  Since	
  1.0)	
  
▪  现实世界中,众多的数据集都是稀疏的	
  
¡  算法集	
  
§  Classification	
  /	
  Regression	
  /collaborative	
  filtering	
  /	
  
Clustering	
  /	
  Decomposition	
  
¡  Bagel	
  :	
  Spark	
  0.6,	
  2013-­‐08	
  
¡  Graphx-­‐Branch	
  :	
  Spark	
  0.8,	
  2013-­‐09
¡  Graphx-­‐Alpha	
  :	
  Spark	
  0.9,	
  2014-­‐03	
  
¡  图计算的模型	
  
§  类Pregel的思想	
  
§  Super	
  Step	
  
▪  更新Vertex和Edge	
  
¡  图切割	
  
§  实现分布式的关键所在	
  
§  Move	
  vertex	
  to	
  Edge	
  
¡  本质上是在RDD基础上
构建	
  
§  合理的数据表达⽅方式	
  
§  针对性的API设计	
  
¡  用于交互式运⾏行测试Spark程序	
  
§  便于快速测试程序局部逻辑	
  
¡  构建在Scala	
  Repl的基础上	
  
§  Repl:读取 执⾏行 打印 循环	
  
§  拓展:	
  
▪  Modified	
  wrapper	
  code	
  generation	
  so	
  that	
  each	
  line	
  
typed	
  has	
  references	
  to	
  objects	
  for	
  its	
  dependencies	
  
▪  Distribute	
  generated	
  classes	
  over	
  the	
  network	
  
¡  Pluggable	
  shuffl゚e	
  Interface	
  
§  Hash	
  -­‐>	
  Sort	
  
▪  Memory/performance	
  etc.
¡  Improved	
  Data	
  transfer	
  mechanism	
  
§  Pluggable	
  
§  Employ	
  Netty	
  
¡  Others	
  
§  pySpark	
  /	
  JDBC	
  server	
  /	
  Dynamic	
  metric	
  …	
  
¡  Core	
  
§  Pluggable	
  Storage	
  Interface	
  
▪  To	
  support	
  various	
  Storage	
  type,	
  SSD,HDFS	
  Cache	
  etc ハ
¡  Spark ハSQL	
  
§  更多的数据源的支持	
  
▪  (Cassandra, MongoDB)	
  RDMS	
  (SAP/Vertica/Oracle)
§  性能优化(code	
  gen,	
  faster	
  joins,	
  etc)	
  
§  语法增强(towards	
  SQL92)	
  
¡  Graphx	
  
§  Move	
  graphx	
  out	
  of	
  “Alpha”	
  
¡  稳定性和可扩展性
¡  Better	
  Yarn	
  Integration	
  
§  Security	
  
§  Dynamic	
  resource	
  adjustment
¡  More	
  Algorithms	
  for	
  Mllib	
  
§  On	
  June,	
  15+	
  
§  Should	
  Double	
  quickly.
¡  Spark ハStreaming
§  Streaming	
  SQL	
  /	
  More	
  data	
  source	
  etc.
¡  以推荐算法所需数据源的处理流程为例	
  
§  Log⽂文件	
  /	
  KaQa	
  /	
  HDFS	
  /	
  MapReduce	
  /	
  Hive	
  /	
  
Hbase	
  /	
  DB	
  /	
  Solr	
  /	
  Redis	
  
§  战线漫长,模块众多,关系复杂,模式各异	
  
¡  离线模型训练	
  
§  计算密集型,迭代运算	
  
¡  实时推荐	
  
§  离线和实时计算模型统⼀一?	
  
¡  目前主要问题?	
  
¡  相关项目	
  
§  Tez	
  /	
  Dryad	
  /	
  Flink
蘑菇街 天火 tianhuo@mogujie.com
Weibo: @冷冻蚂蚁
http://blog.csdn.net/colorant

More Related Content

What's hot

Spark 巨量資料處理基礎教學
Spark 巨量資料處理基礎教學Spark 巨量資料處理基礎教學
Spark 巨量資料處理基礎教學NUTC, imac
 
給初學者的Spark教學
給初學者的Spark教學給初學者的Spark教學
給初學者的Spark教學Chen-en Lu
 
Cassandra
CassandraCassandra
CassandraFEG
 
基于Spring batch的大数据量并行处理
基于Spring batch的大数据量并行处理基于Spring batch的大数据量并行处理
基于Spring batch的大数据量并行处理Jacky Chi
 
MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習孜羲 顏
 
From Java Stream to Java DataFrame
From Java Stream to Java DataFrameFrom Java Stream to Java DataFrame
From Java Stream to Java DataFrameChen-en Lu
 
Hadoop introduction
Hadoop introductionHadoop introduction
Hadoop introductionTianwei Liu
 
Introduction of Spark by Wang Haihua
Introduction of Spark by Wang HaihuaIntroduction of Spark by Wang Haihua
Introduction of Spark by Wang HaihuaWang Haihua
 
Hadoop-分布式数据平台
Hadoop-分布式数据平台Hadoop-分布式数据平台
Hadoop-分布式数据平台Jacky Chi
 
Concurrency model for mysql data processing@rubyconf.tw 2012
Concurrency model for mysql data processing@rubyconf.tw 2012Concurrency model for mysql data processing@rubyconf.tw 2012
Concurrency model for mysql data processing@rubyconf.tw 2012Mu-Fan Teng
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討Billy Yang
 
Elastic stack day-1
Elastic stack day-1Elastic stack day-1
Elastic stack day-1YI-CHING WU
 
How to plan a hadoop cluster for testing and production environment
How to plan a hadoop cluster for testing and production environmentHow to plan a hadoop cluster for testing and production environment
How to plan a hadoop cluster for testing and production environmentAnna Yen
 
Log collection
Log collectionLog collection
Log collectionFEG
 
Hbase运维碎碎念
Hbase运维碎碎念Hbase运维碎碎念
Hbase运维碎碎念haiyuan ning
 
Hadoop 設定與配置
Hadoop 設定與配置Hadoop 設定與配置
Hadoop 設定與配置鳥 藍
 

What's hot (20)

Spark 巨量資料處理基礎教學
Spark 巨量資料處理基礎教學Spark 巨量資料處理基礎教學
Spark 巨量資料處理基礎教學
 
給初學者的Spark教學
給初學者的Spark教學給初學者的Spark教學
給初學者的Spark教學
 
Cassandra
CassandraCassandra
Cassandra
 
基于Spring batch的大数据量并行处理
基于Spring batch的大数据量并行处理基于Spring batch的大数据量并行处理
基于Spring batch的大数据量并行处理
 
SMACK Dev Experience
SMACK Dev ExperienceSMACK Dev Experience
SMACK Dev Experience
 
MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習MapReduce 簡單介紹與練習
MapReduce 簡單介紹與練習
 
Why use MySQL
Why use MySQLWhy use MySQL
Why use MySQL
 
From Java Stream to Java DataFrame
From Java Stream to Java DataFrameFrom Java Stream to Java DataFrame
From Java Stream to Java DataFrame
 
Hadoop introduction
Hadoop introductionHadoop introduction
Hadoop introduction
 
Introduction of Spark by Wang Haihua
Introduction of Spark by Wang HaihuaIntroduction of Spark by Wang Haihua
Introduction of Spark by Wang Haihua
 
Hadoop-分布式数据平台
Hadoop-分布式数据平台Hadoop-分布式数据平台
Hadoop-分布式数据平台
 
Concurrency model for mysql data processing@rubyconf.tw 2012
Concurrency model for mysql data processing@rubyconf.tw 2012Concurrency model for mysql data processing@rubyconf.tw 2012
Concurrency model for mysql data processing@rubyconf.tw 2012
 
Elasticsearch 簡介
Elasticsearch 簡介Elasticsearch 簡介
Elasticsearch 簡介
 
HDFS與MapReduce架構研討
HDFS與MapReduce架構研討HDFS與MapReduce架構研討
HDFS與MapReduce架構研討
 
Hadoop hive
Hadoop hiveHadoop hive
Hadoop hive
 
Elastic stack day-1
Elastic stack day-1Elastic stack day-1
Elastic stack day-1
 
How to plan a hadoop cluster for testing and production environment
How to plan a hadoop cluster for testing and production environmentHow to plan a hadoop cluster for testing and production environment
How to plan a hadoop cluster for testing and production environment
 
Log collection
Log collectionLog collection
Log collection
 
Hbase运维碎碎念
Hbase运维碎碎念Hbase运维碎碎念
Hbase运维碎碎念
 
Hadoop 設定與配置
Hadoop 設定與配置Hadoop 設定與配置
Hadoop 設定與配置
 

Viewers also liked

Adobe Spark Step by Step Guide
Adobe Spark Step by Step GuideAdobe Spark Step by Step Guide
Adobe Spark Step by Step Guidechairmanarnold
 
Spark, the new age of data scientist
Spark, the new age of data scientistSpark, the new age of data scientist
Spark, the new age of data scientistMassimiliano Martella
 
Preso spark leadership
Preso spark leadershipPreso spark leadership
Preso spark leadershipsjoerdluteyn
 
Spark the next top compute model
Spark   the next top compute modelSpark   the next top compute model
Spark the next top compute modelDean Wampler
 
The Future of Data Science
The Future of Data ScienceThe Future of Data Science
The Future of Data Sciencesarith divakar
 
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)Hadoop / Spark Conference Japan
 
Pixie dust overview
Pixie dust overviewPixie dust overview
Pixie dust overviewDavid Taieb
 
Why dont you_create_new_spark_jl
Why dont you_create_new_spark_jlWhy dont you_create_new_spark_jl
Why dont you_create_new_spark_jlShintaro Fukushima
 
Spark tutorial py con 2016 part 2
Spark tutorial py con 2016   part 2Spark tutorial py con 2016   part 2
Spark tutorial py con 2016 part 2David Taieb
 
Tiny Batches, in the wine: Shiny New Bits in Spark Streaming
Tiny Batches, in the wine: Shiny New Bits in Spark StreamingTiny Batches, in the wine: Shiny New Bits in Spark Streaming
Tiny Batches, in the wine: Shiny New Bits in Spark StreamingPaco Nathan
 
How Spark is Enabling the New Wave of Converged Applications
How Spark is Enabling  the New Wave of Converged ApplicationsHow Spark is Enabling  the New Wave of Converged Applications
How Spark is Enabling the New Wave of Converged ApplicationsMapR Technologies
 
Spark tutorial pycon 2016 part 1
Spark tutorial pycon 2016   part 1Spark tutorial pycon 2016   part 1
Spark tutorial pycon 2016 part 1David Taieb
 
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016StampedeCon
 
Introduction to Structured Data Processing with Spark SQL
Introduction to Structured Data Processing with Spark SQLIntroduction to Structured Data Processing with Spark SQL
Introduction to Structured Data Processing with Spark SQLdatamantra
 
Adobe spark video oluşturma aracı
Adobe spark video oluşturma aracıAdobe spark video oluşturma aracı
Adobe spark video oluşturma aracıNurcan Ari
 

Viewers also liked (20)

Adobe Spark Step by Step Guide
Adobe Spark Step by Step GuideAdobe Spark Step by Step Guide
Adobe Spark Step by Step Guide
 
Spark - Philly JUG
Spark  - Philly JUGSpark  - Philly JUG
Spark - Philly JUG
 
Spark, the new age of data scientist
Spark, the new age of data scientistSpark, the new age of data scientist
Spark, the new age of data scientist
 
Preso spark leadership
Preso spark leadershipPreso spark leadership
Preso spark leadership
 
Performance
PerformancePerformance
Performance
 
Apache Spark with Scala
Apache Spark with ScalaApache Spark with Scala
Apache Spark with Scala
 
Spark the next top compute model
Spark   the next top compute modelSpark   the next top compute model
Spark the next top compute model
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
 
The Future of Data Science
The Future of Data ScienceThe Future of Data Science
The Future of Data Science
 
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)
A Deeper Understanding of Spark Internals (Hadoop Conference Japan 2014)
 
Pixie dust overview
Pixie dust overviewPixie dust overview
Pixie dust overview
 
Why dont you_create_new_spark_jl
Why dont you_create_new_spark_jlWhy dont you_create_new_spark_jl
Why dont you_create_new_spark_jl
 
Spark in 15 min
Spark in 15 minSpark in 15 min
Spark in 15 min
 
Spark tutorial py con 2016 part 2
Spark tutorial py con 2016   part 2Spark tutorial py con 2016   part 2
Spark tutorial py con 2016 part 2
 
Tiny Batches, in the wine: Shiny New Bits in Spark Streaming
Tiny Batches, in the wine: Shiny New Bits in Spark StreamingTiny Batches, in the wine: Shiny New Bits in Spark Streaming
Tiny Batches, in the wine: Shiny New Bits in Spark Streaming
 
How Spark is Enabling the New Wave of Converged Applications
How Spark is Enabling  the New Wave of Converged ApplicationsHow Spark is Enabling  the New Wave of Converged Applications
How Spark is Enabling the New Wave of Converged Applications
 
Spark tutorial pycon 2016 part 1
Spark tutorial pycon 2016   part 1Spark tutorial pycon 2016   part 1
Spark tutorial pycon 2016 part 1
 
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016
What’s New in Spark 2.0: Structured Streaming and Datasets - StampedeCon 2016
 
Introduction to Structured Data Processing with Spark SQL
Introduction to Structured Data Processing with Spark SQLIntroduction to Structured Data Processing with Spark SQL
Introduction to Structured Data Processing with Spark SQL
 
Adobe spark video oluşturma aracı
Adobe spark video oluşturma aracıAdobe spark video oluşturma aracı
Adobe spark video oluşturma aracı
 

Similar to Spark introduction - In Chinese

使用Dsl改善软件设计
使用Dsl改善软件设计使用Dsl改善软件设计
使用Dsl改善软件设计mingjin
 
Spark调研串讲
Spark调研串讲Spark调研串讲
Spark调研串讲jie cao
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践taobao.com
 
分区表基础知识培训
分区表基础知识培训分区表基础知识培训
分区表基础知识培训maclean liu
 
分布式索引构建
分布式索引构建分布式索引构建
分布式索引构建智杰 付
 
Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 zhen chen
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版Jackson Tian
 
[系列活動] 手把手教你R語言資料分析實務
[系列活動] 手把手教你R語言資料分析實務[系列活動] 手把手教你R語言資料分析實務
[系列活動] 手把手教你R語言資料分析實務台灣資料科學年會
 
Practical data analysis in R: from data collection to data insight
Practical data analysis in R: from data collection to data insight Practical data analysis in R: from data collection to data insight
Practical data analysis in R: from data collection to data insight Chun-Min Chang
 
Practical Data Analysis in R
Practical Data Analysis in RPractical Data Analysis in R
Practical Data Analysis in RChun-Ming Chang
 
Coreseek/Sphinx 全文检索实践指南
Coreseek/Sphinx 全文检索实践指南Coreseek/Sphinx 全文检索实践指南
Coreseek/Sphinx 全文检索实践指南HonestQiao
 
2015中国软件技术大会-开放云介绍
2015中国软件技术大会-开放云介绍2015中国软件技术大会-开放云介绍
2015中国软件技术大会-开放云介绍Li Jiansheng
 
Hadoop学习总结
Hadoop学习总结Hadoop学习总结
Hadoop学习总结ordinary2012
 
COSCUP 2019 - 開源大數據引擎 Greenplum
COSCUP 2019 - 開源大數據引擎 GreenplumCOSCUP 2019 - 開源大數據引擎 Greenplum
COSCUP 2019 - 開源大數據引擎 GreenplumOmni-Alex Chen
 
Dreaming Infrastructure
Dreaming InfrastructureDreaming Infrastructure
Dreaming Infrastructurekyhpudding
 
Hadoop与数据分析
Hadoop与数据分析Hadoop与数据分析
Hadoop与数据分析George Ang
 
Kmeans in-hadoop
Kmeans in-hadoopKmeans in-hadoop
Kmeans in-hadoopTianwei Liu
 
浅谈电商网站数据访问层(DAL)与 ORM 之适用性
浅谈电商网站数据访问层(DAL)与 ORM 之适用性浅谈电商网站数据访问层(DAL)与 ORM 之适用性
浅谈电商网站数据访问层(DAL)与 ORM 之适用性Xuefeng Zhang
 

Similar to Spark introduction - In Chinese (20)

使用Dsl改善软件设计
使用Dsl改善软件设计使用Dsl改善软件设计
使用Dsl改善软件设计
 
Spark调研串讲
Spark调研串讲Spark调研串讲
Spark调研串讲
 
Node.js在淘宝的应用实践
Node.js在淘宝的应用实践Node.js在淘宝的应用实践
Node.js在淘宝的应用实践
 
分区表基础知识培训
分区表基础知识培训分区表基础知识培训
分区表基础知识培训
 
分布式索引构建
分布式索引构建分布式索引构建
分布式索引构建
 
Hadoop 介紹 20141024
Hadoop 介紹 20141024Hadoop 介紹 20141024
Hadoop 介紹 20141024
 
Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储 Ria的强力后盾:rest+海量存储
Ria的强力后盾:rest+海量存储
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版
 
[系列活動] 手把手教你R語言資料分析實務
[系列活動] 手把手教你R語言資料分析實務[系列活動] 手把手教你R語言資料分析實務
[系列活動] 手把手教你R語言資料分析實務
 
Practical data analysis in R: from data collection to data insight
Practical data analysis in R: from data collection to data insight Practical data analysis in R: from data collection to data insight
Practical data analysis in R: from data collection to data insight
 
Practical Data Analysis in R
Practical Data Analysis in RPractical Data Analysis in R
Practical Data Analysis in R
 
Coreseek/Sphinx 全文检索实践指南
Coreseek/Sphinx 全文检索实践指南Coreseek/Sphinx 全文检索实践指南
Coreseek/Sphinx 全文检索实践指南
 
2015中国软件技术大会-开放云介绍
2015中国软件技术大会-开放云介绍2015中国软件技术大会-开放云介绍
2015中国软件技术大会-开放云介绍
 
Hadoop学习总结
Hadoop学习总结Hadoop学习总结
Hadoop学习总结
 
COSCUP 2019 - 開源大數據引擎 Greenplum
COSCUP 2019 - 開源大數據引擎 GreenplumCOSCUP 2019 - 開源大數據引擎 Greenplum
COSCUP 2019 - 開源大數據引擎 Greenplum
 
Dreaming Infrastructure
Dreaming InfrastructureDreaming Infrastructure
Dreaming Infrastructure
 
Hadoop与数据分析
Hadoop与数据分析Hadoop与数据分析
Hadoop与数据分析
 
Cdc@ganji.com
Cdc@ganji.comCdc@ganji.com
Cdc@ganji.com
 
Kmeans in-hadoop
Kmeans in-hadoopKmeans in-hadoop
Kmeans in-hadoop
 
浅谈电商网站数据访问层(DAL)与 ORM 之适用性
浅谈电商网站数据访问层(DAL)与 ORM 之适用性浅谈电商网站数据访问层(DAL)与 ORM 之适用性
浅谈电商网站数据访问层(DAL)与 ORM 之适用性
 

Spark introduction - In Chinese

  • 2. ¡  分布式计算框架   ¡  等等,关我什么事?   §  太多的分布式计算框架   ¡  因为它很Cool   ¡  所以你不想Out?  
  • 3. ¡  出身背景很Cool   §  UC  Berkeley  AMPLab实验室   ¡  主要开发者很Cool   §  DataBricks   §  Intel  /  Yahoo  /  Cloudera     ¡  应用场景很Cool   §  ETL、OLAP、机器学习、基因⼯工程   ¡  开发语⾔言很Cool   §  scala    
  • 4.
  • 5. ¡  很Cool的背景   §  理论架构的先进性   §  性能   ¡  很Cool的开发团队   §  持续发展的动⼒力源泉     ¡  很Cool的应用场景   §  活跃的社区   §  不⾄至于成为屠龙之技   ¡  很Cool的开发语⾔言   §  开发效率   §  ⾼高(zhuang)逼格的资本 lol  
  • 6. ¡  快速从Apache  Incubator项目毕业成为 Apache顶级项目   ¡  ⼤大数据解决⽅方案提供商的支持   §  Cloudera  /  MapR    /  Hortonworks  /  Pivotal  /  SAP  …   §  华为  /  星环科技   ¡  应用   §  阿里/百度/爱奇艺/优酷/京东…   ¡  2014年⼤大数据领域最活跃的开源项目  
  • 7.
  • 8. ¡  分布式计算框架   ¡  基于内存的调度和运算模型   ¡  兼容Hadoop⽣生态环境   §  数据存储格式   §  Works  with  Hdfs/Yarn/Hive/Hbase/kaQa…  etc.   ¡  丰富的应用场景   §  离线处理 /  实时计算   §  SQL  /  机器学习 /  图计算  
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. ¡  更加⾼高效和通用的编程模型   §  相比MapReduce模型,更加适用于两种类型的 应用   ▪  迭代算法类(机器学习,图计算)   ▪  交互式数据挖掘   ¡  良好的用户体验   ▪  编程效率:基于Scala的核⼼心模块,提供Java/python编 程接⼝口   ▪  功能强⼤大的API,丰富的操作算⼦子   ▪  交互式的解释执⾏行接⼝口(调试,学习)  
  • 14.   Step Step Step Step Step Client   Step Step Step Step Step Client  
  • 15. ¡  计算模型固定   ¡  每个MapReduce阶段之间需要落盘   ¡  容错性好 Map   Map   Map   Reduce   Reduce   Input   Output  
  • 16. Dryad-­‐like  DAGs   Pipelines  functions   within  a  stage     Cache-­‐aware  work   reuse  &  locality     Partitioning-­‐aware   to  avoid  shuffles   join   union   groupBy   map   Stage  3   Stage  1   Stage  2   A:   B:   C:   D:   E:   F:   G:   =  cached  data  partition  
  • 17. !
  • 18. ¡  Resilient  distributed  datasets  (RDDs)   ¡  http://dl.acm.org/citation.cfm?id=2228301   §  不可变的,按分区组织的数据对象   §  ⼀一个RDD可以通过各种(map,  filter,  groupBy,   Join…)操作转换为另⼀一个RDD   §  源头的RDD的数据来源可以是外部存储,如 HDFS,也可以动态⽣生成   §  可以采用各种缓存⽅方式加速处理   §  容错,  数据本地性,  可扩展性  
  • 19. ¡  分布式运算环境下的数据容错模型往往是影响 整个系统的核⼼心机制之⼀一   ¡  其它基于内存的类似计算框架系统采用细颗粒 度的数据备份或者LOG机制   ¡  RDD采用基于⾎血统关系(Lineage)的容错模型   §  Lineage记录的是粗颗粒度的数据变换操作⾏行为   §  当RDD的部分分区数据丢失时,它可以通过Lineage 信息重新运算和恢复丢失的数据分区。   §  这种粗颗粒的数据模型,限制了Spark的运用场合, 但同时相比细颗粒度的数据模型,也带来了性能的 提升。
  • 20. RDDs  maintain  lineage  information  that  can  be   used  to  reconstruct  lost  partitions   Ex:       messages = textFile(...).filter(_.startsWith(“ERROR”)) Result = messages.map(_.split(‘t’)(2)) HDFS  File   Filtered  RDD   Mapped  RDD   filter   (func  =  _.startsWith(...))   map   (func  =  _.split(...))  
  • 21. lines = spark.textFile(“hdfs://...”) errors = lines.filter(_.startsWith(“ERROR”)) messages = errors.map(_.split(‘t’)(2)) cachedMsgs = messages.cache() Block  1   Block  2   Block  3   Worker   Worker   Worker   Driver   cachedMsgs.filter(_.contains(“foo”)).count cachedMsgs.filter(_.contains(“bar”)).count . . . tasks   results   Cache  1   Cache  2   Cache  3   Base  RDD   Transformed  RDD   Action  
  • 22.
  • 23. ¡  围绕RDD的概念,实现核⼼心运⾏行调度逻辑   §  Scheduler:作业和任务的调度管理   §  BlockManager:RDD/Shuffle等数据块的管理   §  RDD:各种RDD数据结构表达和算法实现   §  Shuffle:管理Shuffle逻辑和相关数据流程   §  NetWork:跨节点数据通讯相关   §  Yarn:  基于Yarn的任务调度管理模块   §  其它…  
  • 24. ¡  其它各种上层模块都是基于Core的衍⽣生   §  RDD核⼼心思想在不同领域的拓展和定制化实现   §  RDD数据模型的通用性和灵活性,从本质上决 定了它很容易被应用到各种具体的编程模型上
  • 25. ¡  本质上是Micro-­‐batches  RDDs的处理   §  相比于小Batch的Hadoop  Job,Task启动代价小, latency低   §  近实时(相比Storm)   ▪  默认200ms⼀一个批次   §  吞吐率⾼高   §  相对于其它模块,最早在业界得到应用  
  • 26. §  与普通RDD批处理统⼀一的编程模型   §  基于Lineage的容错模型   §  丰富的数据源    
  • 27. val  conf  =  new  SparkConf()   val  ssc  =  new  StreamingContext(conf,  Seconds(1))   val  lines  =  ssc.textFileStream(args(1))   val  words  =  lines.flatMap(_.split("  "))   val  result  =  words.map(x  =>  (x,  1)).reduceByKey(_  +  _).collect()   ssc.start()   val  conf  =  new  SparkConf()   val ハsc ハ= ハnew ハSparkContext(conf)     val ハlines ハ ハ= ハsc.textFile(args(1))     val ハwords ハ= ハlines.fl゚atMap(_.split("  ")) val result = words.map(x ハ=> ハ(x, ハ1)).reduceByKey(_  +  _).collect()
  • 28. n Hive-­‐like  interface(JDBC   Service  /  CLI)   n Both  Hive  QL  &  Simple  SQL   dialects  are  Supported   n DDL  is  100%  compatible  with   Hive  Metastore   n Hive  QL  aims  to  100%   compatible  with  Hive  DML   Spark  Core   Spark  Execution  Operators   Catalyst   Hive  QL   Simple  SQL   SQL  API  CLI   User Application JDBC  Service   Data  Analyst Hive  Meta  Store   Simple  Catalog  
  • 29. n First  released  in  Spark  1.0  (May,  2014)   n Initial  committed  by  Michael  Armbrust  &   Reynold  Xin  from  Databricks  
  • 30. ¡  MLlib  机器学习算法库:   §  Initial  contribution  from  AMPLab,  UC  Berkeley     §  Shipped  with  Spark  since  version  0.8  (Sep  2013)     ¡  数据类型   §  Dense   §  Sparse  (  Since  1.0)   ▪  现实世界中,众多的数据集都是稀疏的   ¡  算法集   §  Classification  /  Regression  /collaborative  filtering  /   Clustering  /  Decomposition  
  • 31. ¡  Bagel  :  Spark  0.6,  2013-­‐08   ¡  Graphx-­‐Branch  :  Spark  0.8,  2013-­‐09 ¡  Graphx-­‐Alpha  :  Spark  0.9,  2014-­‐03  
  • 32.
  • 33. ¡  图计算的模型   §  类Pregel的思想   §  Super  Step   ▪  更新Vertex和Edge   ¡  图切割   §  实现分布式的关键所在   §  Move  vertex  to  Edge   ¡  本质上是在RDD基础上 构建   §  合理的数据表达⽅方式   §  针对性的API设计  
  • 34. ¡  用于交互式运⾏行测试Spark程序   §  便于快速测试程序局部逻辑   ¡  构建在Scala  Repl的基础上   §  Repl:读取 执⾏行 打印 循环   §  拓展:   ▪  Modified  wrapper  code  generation  so  that  each  line   typed  has  references  to  objects  for  its  dependencies   ▪  Distribute  generated  classes  over  the  network  
  • 35.
  • 36. ¡  Pluggable  shuffl゚e  Interface   §  Hash  -­‐>  Sort   ▪  Memory/performance  etc. ¡  Improved  Data  transfer  mechanism   §  Pluggable   §  Employ  Netty   ¡  Others   §  pySpark  /  JDBC  server  /  Dynamic  metric  …  
  • 37. ¡  Core   §  Pluggable  Storage  Interface   ▪  To  support  various  Storage  type,  SSD,HDFS  Cache  etc ハ ¡  Spark ハSQL   §  更多的数据源的支持   ▪  (Cassandra, MongoDB)  RDMS  (SAP/Vertica/Oracle) §  性能优化(code  gen,  faster  joins,  etc)   §  语法增强(towards  SQL92)   ¡  Graphx   §  Move  graphx  out  of  “Alpha”   ¡  稳定性和可扩展性
  • 38. ¡  Better  Yarn  Integration   §  Security   §  Dynamic  resource  adjustment ¡  More  Algorithms  for  Mllib   §  On  June,  15+   §  Should  Double  quickly. ¡  Spark ハStreaming §  Streaming  SQL  /  More  data  source  etc.
  • 39. ¡  以推荐算法所需数据源的处理流程为例   §  Log⽂文件  /  KaQa  /  HDFS  /  MapReduce  /  Hive  /   Hbase  /  DB  /  Solr  /  Redis   §  战线漫长,模块众多,关系复杂,模式各异   ¡  离线模型训练   §  计算密集型,迭代运算   ¡  实时推荐   §  离线和实时计算模型统⼀一?  
  • 40. ¡  目前主要问题?   ¡  相关项目   §  Tez  /  Dryad  /  Flink
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. 蘑菇街 天火 tianhuo@mogujie.com Weibo: @冷冻蚂蚁 http://blog.csdn.net/colorant