Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Spark 프로필 전체 설정 참조

프로필은 Spark 설정의 묶음입니다. 먼저 프로젝트에 가져온 뒤 변환에서 사용하며, 같은 키를 여러 프로필이 지정하면 목록의 뒤쪽 값이 우선합니다. 적용 방법과 자원 선택 기준을 함께 확인합니다.

JVM 메모리, 컨테이너의 추가 오버헤드와 네이티브 off-heap 분율은 서로 다른 설정입니다. 또한 실행기 수, 실행기 코어 수와 태스크당 코어 수를 구분해야 병렬성을 해석할 수 있습니다.

예를 들어 EXECUTOR_MEMORY_MEDIUM 뒤에 EXECUTOR_MEMORY_OVERHEAD_LARGE를 적용하면 JVM 메모리는 13g, 오버헤드는 4g가 됩니다. 순서를 뒤집으면 MEDIUM 프로필이 오버헤드도 2g로 다시 지정합니다.

열별 추가 통계는 spark.foundry.build.stats.enableColumnStats로 제어합니다. 기본적으로 비활성화되어 열별 null 개수와 데이터셋 수준의 행 수 같은 지표를 계산합니다. 아래 ENABLE_COLUMN_STATS 항목의 설정 값도 false이므로 이름만 보고 min, max와 mean이 활성화된 것으로 판단하지 않습니다. 추가 통계가 목적이라면 적용된 프로필의 정의와 최종 실행 설정에서 이 키의 활성화 여부를 확인합니다.

드라이버 코어

spark.driver.cores를 설정합니다. 같은 Spark 모듈에서 많은 작업을 함께 실행하는 경우 등을 제외하면 기본값을 유지하는 편이 권장됩니다.

프로필 이름설정
DRIVER_CORES_SMALLspark.driver.cores: 1
DRIVER_CORES_MEDIUMspark.driver.cores: 2
DRIVER_CORES_LARGEspark.driver.cores: 4
DRIVER_CORES_EXTRA_LARGEspark.driver.cores: 8
DRIVER_CORES_EXTRA_EXTRA_LARGEspark.driver.cores: 16

드라이버 JVM 메모리

spark.driver.memory와 일부 결과 크기 제한을 설정합니다. 많은 데이터를 드라이버에 모으거나 큰 브로드캐스트 조인을 수행할 때 검토합니다. Python 프로세스의 메모리를 늘리는 설정과는 구분합니다.

프로필 이름설정
DRIVER_MEMORY_SMALLspark.driver.memory: 3g
DRIVER_MEMORY_MEDIUMspark.driver.memory: 6g
spark.driver.maxResultSize: 4g
DRIVER_MEMORY_LARGEspark.driver.memory: 13g
spark.driver.maxResultSize: 8g
DRIVER_MEMORY_EXTRA_LARGEspark.driver.memory: 27g
spark.driver.maxResultSize: 16g
DRIVER_MEMORY_EXTRA_EXTRA_LARGEspark.driver.memory: 54g
spark.driver.maxResultSize: 32g

드라이버 메모리 오버헤드

드라이버 JVM 메모리 외의 추가 메모리 구성을 설정합니다. 로컬 Python 및 pandas 처리에서 필요한 메모리를 JVM 힙 값만으로 판단하지 않습니다.

프로필 이름설정
DRIVER_MEMORY_OVERHEAD_SMALLspark.driver.memoryOverhead: 1g
DRIVER_MEMORY_OVERHEAD_MEDIUMspark.driver.memoryOverhead: 2g
DRIVER_MEMORY_OVERHEAD_LARGEspark.driver.memoryOverhead: 4g
DRIVER_MEMORY_OVERHEAD_EXTRA_LARGEspark.driver.memoryOverhead: 8g
DRIVER_MEMORY_OVERHEAD_EXTRA_EXTRA_LARGEspark.driver.memoryOverhead: 16g

실행기 코어

spark.executor.cores는 실행기별 CPU와 동시 태스크 수에 영향을 줍니다. 일반 변환에서는 자주 변경하지 않는 것이 권장됩니다.

프로필 이름설정
EXECUTOR_CORES_EXTRA_SMALLspark.executor.cores: 1
EXECUTOR_CORES_SMALLspark.executor.cores: 2
EXECUTOR_CORES_MEDIUMspark.executor.cores: 4
EXECUTOR_CORES_LARGEspark.executor.cores: 6
EXECUTOR_CORES_EXTRA_LARGEspark.executor.cores: 8

실행기 메모리

실행기 JVM 메모리와 관련 오버헤드를 함께 설정합니다. 한 실행기의 태스크들이 이 메모리를 공유하므로 태스크별 데이터가 크면 메모리와 동시 태스크 수를 함께 봅니다.

프로필 이름설정
EXECUTOR_MEMORY_EXTRA_EXTRA_SMALLspark.executor.memory: 1536m
spark.executor.memoryOverhead: 384m
EXECUTOR_MEMORY_EXTRA_SMALLspark.executor.memory: 3g
spark.executor.memoryOverhead: 768m
EXECUTOR_MEMORY_SMALLspark.executor.memory: 6g
spark.executor.memoryOverhead: 1536m
EXECUTOR_MEMORY_MEDIUMspark.executor.memory: 13g
spark.executor.memoryOverhead: 2g
EXECUTOR_MEMORY_LARGEspark.executor.memory: 27g
spark.executor.memoryOverhead: 3g

실행기 off-heap 분율

네이티브 가속 등에 사용할 off-heap 비중입니다. 이 분율 프로필을 사용하려면 Executor Memory 계열 프로필도 반드시 지정해야 합니다. JVM 밖의 비중을 늘려도 오케스트레이션을 위한 JVM 메모리는 남겨야 합니다.

프로필 이름설정
EXECUTOR_MEMORY_OFFHEAP_FRACTION_MINIMUMoff-heap 사용 비중: 30%; Executor Memory 프로필 필수
EXECUTOR_MEMORY_OFFHEAP_FRACTION_LOWoff-heap 사용 비중: 50%; Executor Memory 프로필 필수
EXECUTOR_MEMORY_OFFHEAP_FRACTION_MODERATEoff-heap 사용 비중: 70%; Executor Memory 프로필 필수
EXECUTOR_MEMORY_OFFHEAP_FRACTION_HIGHoff-heap 사용 비중: 80%; Executor Memory 프로필 필수
EXECUTOR_MEMORY_OFFHEAP_FRACTION_MAXIMUMoff-heap 사용 비중: 90%; Executor Memory 프로필 필수

실행기 메모리 오버헤드

spark.executor.memoryOverhead는 JVM 메모리 외에 컨테이너에 추가로 할당할 메모리를 설정합니다. JVM 밖에서 메모리를 많이 사용하는 작업에 적용합니다.

프로필 이름설정
EXECUTOR_MEMORY_OVERHEAD_SMALLspark.executor.memoryOverhead: 1g
EXECUTOR_MEMORY_OVERHEAD_MEDIUMspark.executor.memoryOverhead: 2g
EXECUTOR_MEMORY_OVERHEAD_LARGEspark.executor.memoryOverhead: 4g
EXECUTOR_MEMORY_OVERHEAD_EXTRA_LARGEspark.executor.memoryOverhead: 8g

실행기 수

실행기 요청 수와 관련 상한을 설정합니다. 큰 병렬 작업에 효과가 있지만 실제 병렬성이 낮으면 자원만 늘어날 수 있습니다. 로컬 제출 프로필은 별도 실행기 없이 실행하는 구성을 선택합니다.

프로필 이름설정
KUBERNETES_NO_EXECUTORSspark.kubernetes.local.submission: true
spark.sql.shuffle.partitions: 1
NUM_EXECUTORS_1spark.executor.instances: 1
spark.dynamicAllocation.maxExecutors: 1
NUM_EXECUTORS_2spark.executor.instances: 2
spark.dynamicAllocation.maxExecutors: 2
NUM_EXECUTORS_4spark.executor.instances: 4
spark.dynamicAllocation.maxExecutors: 4
NUM_EXECUTORS_8spark.executor.instances: 8
spark.dynamicAllocation.maxExecutors: 8
NUM_EXECUTORS_16spark.executor.instances: 16
spark.dynamicAllocation.maxExecutors: 16
NUM_EXECUTORS_32spark.executor.instances: 32
spark.dynamicAllocation.maxExecutors: 32
NUM_EXECUTORS_64spark.executor.instances: 64
spark.dynamicAllocation.maxExecutors: 64
NUM_EXECUTORS_128spark.executor.instances: 128
spark.dynamicAllocation.maxExecutors: 128
NUM_EXECUTORS_256spark.executor.instances: 256
spark.dynamicAllocation.maxExecutors: 256
NUM_EXECUTORS_512spark.executor.instances: 512
spark.dynamicAllocation.maxExecutors: 512

동적 할당

실행기 수를 고정하기보다 최소 및 최대 범위와 증감 조건을 설정합니다. 필요하지 않은 실행기는 반환할 수 있지만 최대 요청 수를 실제로 모두 확보한다는 보장은 없습니다. 실행마다 할당 경과가 달라질 수 있습니다.

프로필 이름설정
DYNAMIC_ALLOCATION_DISABLEDspark.dynamicAllocation.enabled: false
DYNAMIC_ALLOCATION_ENABLEDspark.dynamicAllocation.enabled: true
DYNAMIC_ALLOCATION_MIN_2spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 2
DYNAMIC_ALLOCATION_MIN_4spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 4
DYNAMIC_ALLOCATION_MIN_8spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 8
DYNAMIC_ALLOCATION_MIN_16spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 16
DYNAMIC_ALLOCATION_MAX_8spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.maxExecutors: 8
DYNAMIC_ALLOCATION_MAX_16spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.maxExecutors: 16
DYNAMIC_ALLOCATION_MAX_32spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.maxExecutors: 32
DYNAMIC_ALLOCATION_MAX_64spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.maxExecutors: 64
DYNAMIC_ALLOCATION_MAX_128spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.maxExecutors: 128
DYNAMIC_ALLOCATION_ENABLED_1_2spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 1
spark.dynamicAllocation.maxExecutors: 2
DYNAMIC_ALLOCATION_ENABLED_2_4spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 2
spark.dynamicAllocation.maxExecutors: 4
DYNAMIC_ALLOCATION_ENABLED_4_8spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 4
spark.dynamicAllocation.maxExecutors: 8
DYNAMIC_ALLOCATION_ENABLED_8_16spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 8
spark.dynamicAllocation.maxExecutors: 16
DYNAMIC_ALLOCATION_ENABLED_16_32spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 16
spark.dynamicAllocation.maxExecutors: 32
DYNAMIC_ALLOCATION_ENABLED_32_64spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 32
spark.dynamicAllocation.maxExecutors: 64
DYNAMIC_ALLOCATION_ENABLED_64_128spark.dynamicAllocation.enabled: true
spark.dynamicAllocation.minExecutors: 64
spark.dynamicAllocation.maxExecutors: 128
DYNAMIC_ALLOCATION_FAST_SCALE_DOWNspark.dynamicAllocation.executorIdleTimeout: 10s
DYNAMIC_ALLOCATION_SLOW_SCALE_UP_2Mspark.dynamicAllocation.schedulerBacklogTimeout: 2m

Shuffle 파티션 수

spark.sql.shuffle.partitions에 사용할 개수를 지정합니다. 입력 분할 수나 물리 실행기 수와 같은 개념은 아닙니다.

프로필 이름설정
SHUFFLE_PARTITIONS_SMALLspark.sql.shuffle.partitions: 20
SHUFFLE_PARTITIONS_MEDIUMspark.sql.shuffle.partitions: 200
SHUFFLE_PARTITIONS_LARGEspark.sql.shuffle.partitions: 2000
SHUFFLE_PARTITIONS_EXTRA_LARGEspark.sql.shuffle.partitions: 20000

적응형 질의 실행

AQE는 실행 중 정보를 이용해 파티션 수를 조정합니다. 기본 목표 크기는 파티션당 64MB이며, 예를 들어 512MB 출력은 약 8개를 목표로 할 수 있습니다. 자주 읽는 출력에는 128MB 이상 목표를 검토합니다. 비싼 UDF처럼 출력 크기는 작지만 계산이 무거운 작업에서는 AQE가 병렬성을 줄여 느려질 수 있어 비활성화를 검토할 수 있습니다.

프로필 이름설정
ADAPTIVE_DISABLEDspark.sql.adaptive.enabled: false
ADAPTIVE_ENABLEDspark.sql.adaptive.enabled: true
ADVISORY_PARTITION_SIZE_MEDIUMspark.sql.adaptive.enabled: true
spark.sql.adaptive.advisoryPartitionSizeInBytes: 128MB
spark.sql.adaptive.shuffle.targetPostShuffleInputSize: 128MB
ADVISORY_PARTITION_SIZE_LARGEspark.sql.adaptive.enabled: true
spark.sql.adaptive.advisoryPartitionSizeInBytes: 256MB
spark.sql.adaptive.shuffle.targetPostShuffleInputSize: 256MB

RPC 메시지 크기

Spark 제어 메시지의 최대 크기를 설정합니다. 다음 표는 해당 설정 키에 전달되는 값입니다.

프로필 이름설정
RPC_MESSAGE_MAX_SIZE_512Mspark.rpc.message.maxSize: 512
RPC_MESSAGE_MAX_SIZE_1Gspark.rpc.message.maxSize: 1024
RPC_MESSAGE_MAX_SIZE_MAXspark.rpc.message.maxSize: 2047

이전 동작과의 호환

이 프로필들은 이전 버전의 자료형, 파싱 또는 질의 처리 동작을 선택합니다. 자원 크기 조정과 달리 결과 의미가 달라질 수 있으므로 해당 로직과 함께 관리합니다.

프로필 이름설정
LEGACY_ALLOW_UNTYPED_SCALA_UDFspark.sql.legacy.allowUntypedScalaUDF: true
LEGACY_ALLOW_NEGATIVE_DECIMAL_SCALEspark.sql.legacy.allowNegativeScaleOfDecimal: true
LEGACY_ALLOW_HASH_ON_MAPTYPEspark.sql.legacy.allowHashOnMapType: true
LEGACY_NAME_NON_STRUCT_GROUPING_KEY_AS_VALUEspark.sql.legacy.dataset.nameNonStructGroupingKeyAsValue: true
LEGACY_ARRAY_EXISTS_NULL_HANDLINGspark.sql.legacy.followThreeValuedLogicInArrayExists: false
LEGACY_ALLOW_AMBIGUOUS_SELF_JOINspark.sql.analyzer.failAmbiguousSelfJoin: false
LEGACY_TIME_PARSER_POLICYspark.sql.legacy.timeParserPolicy: LEGACY
LEGACY_DATETIME_REBASE_MODEspark.sql.legacy.avro.datetimeRebaseModeInRead: LEGACY
spark.sql.legacy.parquet.datetimeRebaseModeInRead: LEGACY
spark.sql.legacy.avro.datetimeRebaseModeInWrite: LEGACY
spark.sql.legacy.parquet.datetimeRebaseModeInWrite: LEGACY
LEGACY_FROM_DAYTIME_STRINGspark.sql.legacy.fromDayTimeString.enabled: true
LEGACY_DATETIME_STRING_COMPARISONspark.sql.legacy.typeCoercion.datetimeToString.enabled: true

날짜와 시각

시간 파서 정책과 Parquet INT96 해석을 설정합니다. 입력의 날짜 표현과 저장 형식에 맞춰 사용합니다.

프로필 이름설정
TIME_PARSER_POLICY_CORRECTEDspark.sql.legacy.timeParserPolicy: CORRECTED
SPARK_ALLOW_INT96_AS_TIMESTAMPspark.sql.parquet.int96AsTimestamp: true

기타 실행 설정

버킷 정렬 활용, 중복 키 처리, 추측 실행, 태스크별 CPU와 통계 등의 설정입니다. spark.task.cpus는 태스크 하나에 할당하는 코어 수이며 실행기 코어 수와 구분합니다. 일반적으로 태스크 CPU 설정은 드물게 변경합니다.

프로필 이름설정
BUCKET_SORTED_SCAN_ENABLEDspark.sql.sources.bucketing.sortedScan.enabled: true
LAST_MAP_KEY_WINSspark.sql.mapKeyDedupPolicy: LAST_WIN
CROSS_JOIN_ENABLEDspark.sql.crossJoin.enabled: true
SPECULATIVE_EXECUTIONspark.speculation: true
spark.speculation.interval: 1s
spark.speculation.multiplier: 4.0
spark.speculation.quantile: 0.9
AUTO_BROADCAST_JOIN_DISABLEDspark.sql.autoBroadcastJoinThreshold: -1
ALLOW_ADD_MONTHSspark.foundry.sql.allowAddMonths: true
TASK_CPUS_2spark.task.cpus: 2
TASK_CPUS_4spark.task.cpus: 4
PYSPARK_ROW_FIELD_SORTING_ENABLEDspark.executorEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: true
spark.yarn.appMasterEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: true
spark.kubernetes.driverEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: true
PYSPARK_ROW_FIELD_SORTING_DISABLEDspark.executorEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: false
spark.yarn.appMasterEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: false
spark.kubernetes.driverEnv.PYSPARK_ROW_FIELD_SORTING_ENABLED: false
PYSPARK_ROW_SCHEMA_CORRUPTION_CHECK_DISABLEDspark.kubernetes.driverEnv.PYSPARK_CHECK_ROW_SCHEMA_CORRUPTION: false
spark.yarn.appMasterEnv.PYSPARK_CHECK_ROW_SCHEMA_CORRUPTION: false
spark.executorEnv.PYSPARK_CHECK_ROW_SCHEMA_CORRUPTION: false
SPARK_KYRO_REFERENCE_TRACKING_DISABLEDspark.kryo.referenceTracking: false
GEOSPARKspark.foundry.build.stats.enabled: false
SPARK_REFERENCE_TRACKING_DISABLEDspark.cleaner.referenceTracking: false
ENABLE_COLUMN_STATSspark.foundry.build.stats.enableColumnStats: false
MANAGED_PROFILE최근 실행 지표를 기준으로 관리형 프로필 최적화를 허용합니다.

Arrow 변환

pandas와 PySpark 데이터프레임 사이의 직렬화를 Arrow로 처리할지 정합니다. 사용하려면 pyarrow 의존성이 필요합니다. spark.createDataFrame()에 pandas 입력을 주거나 toPandas()를 호출할 때 변환 비용을 줄일 수 있으며, pandas 변환에서는 읽기와 쓰기 양쪽에 영향을 줍니다. 로컬 프레임 자체의 메모리 요구가 없어지는 것은 아닙니다.

프로필 이름설정
ARROW_ENABLEDspark.sql.execution.arrow.enabled: true
spark.sql.execution.arrow.pyspark.enabled: true
spark.sql.execution.arrow.sparkr.enabled: true
spark.sql.execution.arrow.fallback.enabled: true
spark.sql.execution.arrow.pyspark.fallback.enabled: true
ARROW_DISABLEDspark.sql.execution.arrow.enabled: false
spark.sql.execution.arrow.pyspark.enabled: false
spark.sql.execution.arrow.sparkr.enabled: false

CPU 아키텍처

아키텍처에 종속된 라이브러리를 사용하는 경우 AMD64 또는 ARM64 실행 환경을 선택할 수 있습니다. AMD64 자원만 있는 환경에서 ARM64를 요구하면 실행하지 못합니다. N/A는 이 표에 직접 대응하는 Spark 설정 값이 없음을 나타냅니다.

프로필 이름설정
KUBERNETES_CPU_ARCHITECTURE_OVERRIDE_AMD64N/A
KUBERNETES_CPU_ARCHITECTURE_OVERRIDE_ARM64N/A

실행기 사이 통신

분산 모델 학습처럼 실행기 간 네트워크 통신이 필요한 작업에 사용합니다.

프로필 이름설정
KUBERNETES_OPEN_PORTS_ALL분산 모델 학습에 필요한 Spark 실행기 사이의 네트워크 통신을 허용합니다.

로컬 Spark

별도 실행기 없이 제출하는 로컬 실행과 드라이버 자원 구성을 함께 지정합니다.

프로필 이름설정
KUBERNETES_NO_EXECUTORS_SMALLspark.kubernetes.local.submission: true
spark.sql.shuffle.partitions: 1
spark.kubernetes.driver.request.cores: 400m
spark.driver.cores: 1
spark.driver.memory: 3g
spark.driver.memoryOverhead: 768m

프로필 이름에 활성화 또는 비활성화가 들어 있어도 최종 동작은 실제 설정 값으로 판단합니다. 적용한 값은 Spark UI의 실행 구성을 확인하여 해석할 수 있습니다.