티스토리 뷰

BigData/Spark

Spark Memory Tuning Case-Study

Tomining 2024. 4. 14. 14:54

Spark 기본 구조

 

Spark Memory

JVM 내부

  • Reserved Memory
  • Spark Memory

JVM 외부

  • OffHeap Memory
  • External Process Memory

 

5GB 기준 메모리 영역 예제

참고: https://community.cloudera.com/t5/Community-Articles/Spark-Memory-Management/ta-p/317794

 

 

Q) 빠르다고 해서 Spark 를 사용하는데, 느려요~???

  • Memory 는 충분한가?
    • 무한정 늘릴 순 없다
    • YARN (Resource Manager) 적절히 분배해 주는가? => Spark Properties
  • 정해진 메모리를 효율적으로 사용하고 있는가?
    • spark.executor.memory 늘려준다
    • spark.executor.cores 조정
      • (얼마가 적당할까?) 참고: executor 개수 정히가
      • 많으면 좋을까? 적은게 좋을까? => 왕도가 없음. 적절한 수치를 찾아야 함.
    • 효율적 가이드 (케이스마다 다르니 꼭 테스트 할 것!)
      • spark.executor.memory >= 4G
      • 1 < spark.executor.cores <= 5

 

Q) 이게 다 인가???

  • Partition 수 조정 (Shuffle Partition)
    • spark.sql.files.maxPartitionBytes
    • coalesce vs repartition
      • repartition: full shuffle. 데이터 균등 분배. 파티션 수 늘리기 가능. 특정 컬럼 기준으로 파티션 가능
      • coalesce: partial shuffle. 데이터 skew. 파티션 수 늘리기 불가. 컬럼 기준으로 파티션 불가.
        • partial shuffle이라 보통 더 빠르지만, 불균형하게 분배된 데이터에서는 더 느릴 수 있음
  • spark.memory.fraction or spark.memory.storageFraction
  • Spill 방지
    • file 을 나눠서 처리

 

YARN

참고

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함