RDD

RDD five main properties  Method Location Input Output
A list of partitions getPartitions ? - [Partition]
A function for computing each split compute ? Partition Iterable
A list of dependencies on other RDD getDependencies ? - [Dependency]
(Optional)A partitioner for key-value RDDS
(Optional)A list of preferred lications to compute each split

屏幕快照 2019-05-17 05.16.47

屏幕快照 2019-05-17 05.23.48




RDD: transformation action
     cache
     

JMM: Java Memory Model (Java内存模型) 

计算,我们通过CPU来的;数据是在内存里面的;现在信息技术这么发达,CPU的速度比你从内存/磁盘读数据的速度快的多,所以会导致CPU很多地方就消耗了. 一般会在,读内存上面 在组内存和CPU之间会有一个三层缓冲区(L1、L2、L3),先把数据加载到内存里面,CPU在处理的时候,就会去内存里面找,然后改完之后,再刷到内存里面. 

当然,这样就会产生一系列的问题,你的数据一致性,就有问题了.

三层缓冲区L1、L2、L3,会产生数据一致性(数据一致性 -> 很难保证,多线程,每一个core都有自己的线程运行,每个线程都有自己的缓冲区,多线程去访问共享资源的时候,肯定会有问题.)
数据一致性: 原子性、可见性、顺序性
    => volatile(保证可见性,顺序性, i++ 在多线程中存在线程安全)
    
把数据集放到内存里面 ,放到executor里面
      

cache lazy  需要Action来触发



Spark Core: MEMORY_ONLY MEMORY_ONLY_SER

Dependency
    Narrow: 一个父RDD的partition只能被子RDD的某个partition使用一次
    Wide(shuffle): 一个父RDD的partition只能被子RDD的某个partition使用多次
    
  action -->  Job  -->  n stages  --> n task
  
注意: **遇到join,要分情况**

RDD dependency

RDD stage

上图中,黑色的部分,就代表丢失的数据

中间丢了,要从头开始算

MR: 1+1+1+1
    1+1 -> 2
         2+1 -> 3
              3+1 -> 4


pipeline    一个partition就是一个task

窄依赖中,一个stage,可以干到死


Spark on YARN Overview
    MR: base-process
        each task in its own process: MapTask   ReduceTask  proces  
        when a task completes, the process goes away
    Spark: base-thread
        many tasks can run concurrently in a single process  
        this process sticks around for the lifetime of the Spark Application  
        enen no jobs are running   
        advantage:   
        speed, tasks can start up very quickly   
        in-memory
        
Cluster Manager  
    Spark Application  ==>  CM
    Local   standalone  YARN    Mesos   K8s ==>  Pluggable  
    
ApplicationMaster: AM  
YARN Application ==> AM(first container)  
Worker:  
    YARN X  executor runs in container(memory of container > executor memory)  
    Standalone(Not concerned)  
Spark仅仅只是一个客户端而已

Spark on YARN Submitting
    Deploy Mode:
        client: Driver local
        cluster: Driver Cluster
    慢?能不能解决?   ==> production(生产上的优化点)
    3   3   5120
    
    1 job == n stage == n task

屏幕快照 2019-05-17 10.19.42

Driver跑到集群里面,看日志怎么看? 节点很多, 你不知道Driver运行在哪个节点上? 屏幕快照 2019-05-17 10.51.14

Container的内存要大于spark的内存,spark的内存有哪些,executor内存、AM内存,AM跑在Container里面也是占内存的,占512M,如果你需要,还可以调整

屏幕快照 2019-05-17 10.59.37

Spark on YARN总结:
1) Driver: Local/Cluster
2) Client: (很多场景下还是用Client)
    AM: requesting resources
 Cluster:  (用这个也没有问题)
    AM: requesting resources
        task schedule(本来是由Driver来做的,但是Driver跑在Cluster上,所以两个在一块)
    
原文地址:https://www.cnblogs.com/suixingc/p/rdd.html