[Spark] Spark FAIR 스케줄링에 대하여

Woong·2022년 7월 6일
0

Apache Spark

목록 보기
18/22

애플리케이션 내에서 스케줄링

  • Spark 는 FIFO 스케줄링이 기본
    • schedulingMode 로 FIFO, FAIR 2가지 모드를 제공한다.
    • spark.scheduler.mode 옵션에 대해 "FAIR" 로 설정하여 활성화할 수 있다.
val sparkSession = SparkSession
        .builder()
        .appName(MyTest.getClass.getSimpleName)
        .config("spark.scheduler.mode", "FAIR")
        .getOrCreate()

pool 속성

  • schedulingMode : FIFO, FAIR 2가지 모드 중 선택
    • 기본값은 FIFO
  • weight : pool 의 리소스 점유율 가중치
    • 기본값은 1
    • weight 값에 따라 리소스 점유율 제어
      • ex) weight이 2면 1에 비해 2배 리소스 점유
  • minShare : 각 pool의 최소 CPU 코어수
    • 모든 활성 pool 의 CPU 코어 수만큼 충족 후 리소스 재분배
      • 우선순위와 무관하게 항상 일정 리소스를 확보하도록 하는 설정
    • 기본값은 0
  • pool 속성을 XML 파일로 관리할 수 있다.
    • spark.scheduler.allocation.file 로 로컬 혹은 HDFS 경로로 XML 파일 경로 지정
// scheduler file at local
conf.set("spark.scheduler.allocation.file", "file:///path/to/file")
// scheduler file at hdfs
conf.set("spark.scheduler.allocation.file", "hdfs:///path/to/file")
  • XML 에선 pool element 로 각 pool 의 설정을 정의
<?xml version="1.0"?>
<allocations>
  <pool name="production">
    <schedulingMode>FAIR</schedulingMode>
    <weight>1</weight>
    <minShare>2</minShare>
  </pool>
  <pool name="test">
    <schedulingMode>FIFO</schedulingMode>
    <weight>2</weight>
    <minShare>3</minShare>
  </pool>
</allocations>

reference

0개의 댓글