Programming

Spark Standalone 클러스터의 작업자, 실행자, 코어 란 무엇입니까?

procodes 2020. 5. 12. 20:38
반응형

Spark Standalone 클러스터의 작업자, 실행자, 코어 란 무엇입니까?


클러스터 모드 개요를 읽었 지만 Spark Standalone 클러스터 의 여러 프로세스 와 병렬 처리를 여전히 이해할 수 없습니다 .

작업자가 JVM 프로세스입니까? 나는을 실행하고 bin\start-slave.sh실제로 JVM 인 작업자를 생성했다는 것을 알았습니다.

위 링크에 따라 실행 프로그램은 작업을 실행하는 작업자 노드의 응용 프로그램에 대해 시작된 프로세스입니다. 집행자는 또한 JVM입니다.

이것들은 나의 질문입니다 :

  1. 집행자는 응용 프로그램마다 있습니다. 그렇다면 노동자의 역할은 무엇입니까? 실행기와 협조하여 결과를 운전자에게 다시 전달합니까? 아니면 운전자가 직접 유언 집행 인과 대화합니까? 그렇다면 근로자의 목적은 무엇입니까?

  2. 응용 프로그램의 실행 프로그램 수를 제어하는 ​​방법은 무엇입니까?

  3. 실행 프로그램 내에서 작업을 병렬로 실행할 수 있습니까? 그렇다면 실행기의 스레드 수를 구성하는 방법은 무엇입니까?

  4. 작업자, 집행자 및 집행자 코어 (--total-executor-cores)의 관계는 무엇입니까?

  5. 노드 당 더 많은 작업자가 있다는 것은 무엇을 의미합니까?

업데이트

이해를 돕기 위해 예를 들어 봅시다.

예 1 : 기본 설정으로 응용 프로그램을 시작할 때 작업자 노드가 5 개인 독립형 클러스터 (각 노드에 코어가 8 개임)

예 2 예 1과 동일한 클러스터 구성이지만 다음 설정 --executor-cores 10 --total-executor-cores 10으로 응용 프로그램을 실행합니다.

예제 3 예제 1과 동일한 클러스터 구성이지만 다음 설정 --executor-cores 10 --total-executor-cores 50으로 애플리케이션을 실행합니다.

예 4 예 1과 동일한 클러스터 구성이지만 다음 설정 --executor-cores 50 --total-executor-cores 50으로 응용 프로그램을 실행합니다.

예제 5 예제 1과 동일한 클러스터 구성이지만 다음 설정 --executor-cores 50 --total-executor-cores 10으로 애플리케이션을 실행합니다.

이러한 각 예에서 얼마나 많은 유언 집행 인이 있습니까? executor 당 몇 개의 스레드가 있습니까? 코어는 몇 개입니까? 응용 프로그램 당 실행자 수는 어떻게 결정됩니까? 항상 노동자 수와 동일합니까?


여기에 이미지 설명을 입력하십시오

Spark는 마스터 / 슬레이브 아키텍처를 사용합니다. 그림에서 볼 수 있듯이 분산 된 많은 작업자 (실행자)와 통신하는 중앙 조정자 (드라이버)가 하나 있습니다. 드라이버와 각 실행 프로그램은 자체 Java 프로세스에서 실행됩니다.

운전사

드라이버는 기본 메소드가 실행되는 프로세스입니다. 먼저 사용자 프로그램을 작업으로 변환 한 후 실행 프로그램의 작업을 예약합니다.

임원

실행자는 주어진 Spark 작업에서 개별 작업을 실행하는 작업자 노드의 프로세스입니다. Spark 응용 프로그램의 시작 부분에서 시작되며 일반적으로 응용 프로그램의 전체 수명 동안 실행됩니다. 일단 작업을 실행하면 결과를 드라이버로 보냅니다. 또한 블록 관리자를 통해 사용자 프로그램에 의해 캐시되는 RDD를위한 인 메모리 스토리지를 제공합니다.

응용 프로그램 실행 흐름

이를 염두에두고 spark-submit을 사용하여 클러스터에 응용 프로그램을 제출하면 내부적으로 발생합니다.

  1. 독립형 응용 프로그램은 인스턴스를 시작하고 인스턴스화 SparkContext합니다 (응용 프로그램을 드라이버로 호출 할 수있는 경우에만 해당).
  2. 드라이버 프로그램은 실행 프로그램을 시작하기 위해 클러스터 관리자에게 자원을 요청합니다.
  3. 클러스터 관리자가 실행 프로그램을 시작합니다.
  4. 드라이버 프로세스는 사용자 응용 프로그램을 통해 실행됩니다. RDD 작업을 통한 조치 및 변환에 따라 실행 프로그램으로 전송됩니다.
  5. 실행자는 작업을 실행하고 결과를 저장합니다.
  6. 작업자가 충돌하면 작업이 다른 실행 프로그램으로 전송되어 다시 처리됩니다. "Learning Spark : Lightning-Fast Big Data Analysis"책에서 Spark 및 Fault Tolerance에 대해 설명합니다.

Spark automatically deals with failed or slow machines by re-executing failed or slow tasks. For example, if the node running a partition of a map() operation crashes, Spark will rerun it on another node; and even if the node does not crash but is simply much slower than other nodes, Spark can preemptively launch a “speculative” copy of the task on another node, and take its result if that finishes.

  1. With SparkContext.stop() from the driver or if the main method exits/crashes all the executors will be terminated and the cluster resources will be released by the cluster manager.

YOUR QUESTIONS

  1. When executors are started they register themselves with the driver and from so on they communicate directly. The workers are in charge of communicating the cluster manager the availability of their resources.

  2. In a YARN cluster you can do that with --num-executors. In a standalone cluster you will get one executor per worker unless you play with spark.executor.cores and a worker has enough cores to hold more than one executor. (As @JacekLaskowski pointed out, --num-executors is no longer in use in YARN https://github.com/apache/spark/commit/16b6d18613e150c7038c613992d80a7828413e66)

  3. You can assign the number of cores per executor with --executor-cores

  4. --total-executor-cores is the max number of executor cores per application

  5. As Sean Owen said in this thread: "there's not a good reason to run more than one worker per machine". You would have many JVM sitting in one machine for instance.

UPDATE

I haven't been able to test this scenarios, but according to documentation:

예 1 : Spark는 스케줄러가 제공하는만큼 많은 코어 및 실행기를 확보합니다. 결국 8 개의 코어를 가진 5 개의 실행기를 얻게됩니다.

예 2 ~ 5 : Spark는 단일 작업자에게 요청한만큼의 코어를 할당 할 수 없으므로 실행기가 시작되지 않습니다.

참고 : https://stackoverflow.com/questions/32621990/what-are-workers-executors-cores-in-spark-standalone-cluster

반응형