Spark์—์„œ ๋Š๋ฆฐ ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐ๋ฒ•. ๋Š๋ฆฌ๊ฒŒ ์‹คํ–‰๋˜๋Š” ์ž‘์—…์„ ๊ฑด๊ฐ•ํ•œ ์›Œ์ปค ๋…ธ๋“œ์— ๋ณต์ œํ•˜์—ฌ ์‹คํ–‰ํ•˜๋Š” ๊ธฐ๋ฒ•.

3 minute read

Databricks Certification ์ทจ๋“์„ ๋ชฉํ‘œ๋กœ Apache Spark๋ฅผ โ€œ์ œ๋Œ€๋กœโ€ ๊ณต๋ถ€ํ•ด๋ณด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํšŒ์‚ฌ์—์„  Databricks Unity Catalog๋ฅผ ๋„์ž…ํ•˜๋ ค๊ณ  ๋ถ„ํˆฌํ•˜๊ณ  ์žˆ๋Š”๋ฐ์š”. Spark์™€ ์ข€ ์นœํ•ด์งˆ ์ˆ˜ ์žˆ์„๊นŒ์š”? ๐ŸŽ‡ ์ „์ฒด ํฌ์ŠคํŠธ๋Š” Development - Spark์—์„œ ํ™•์ธํ•ด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Spark Speculative Execution์ด๋ž€

๋ณธ์ธ ํšŒ์‚ฌ๋Š” 2018๋…„๋ถ€ํ„ฐ Databricks๋ฅผ ๋„์ž…ํ•ด Spark๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์—ˆ๋‹ค. ์‚ฌ์šฉํ•œ์ง€ ์˜ค๋ž˜ ๋˜์–ด์„œ ๊ทธ๋Ÿฐ์ง€ Databricks Job๋“ค์— ์ •๋ง ๋‹ค์–‘ํ•œ Spark Config๋“ค์ด ์„ธํŒ… ๋˜์–ด ์žˆ์—ˆ๋‹ค. ์š”์ฆ˜ ํšŒ์‚ฌ์—์„œ ์‚ฌ์šฉํ•˜๋Š” Spark Config๋ฅผ ์ •๋ฆฌํ•ด์„œ ๋ฐœํ‘œ๋ฅผ ์ค€๋น„ํ•˜๊ณ  ์žˆ๋Š”๋ฐ, spark.speculation๋ผ๋Š” config๊ฐ€ ๋‚ด ๋ˆˆ๊ธธ์„ ๋Œ๊ฒŒ ๋˜์—ˆ๊ณ , ๊ทธ๋ ‡๊ฒŒ ์˜ค๋Š˜์˜ ์ฃผ์ œ์ธ Speculative Execution์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒŒ ๋˜์—ˆ๋‹ค.

Speculative Execution ๊ธฐ๋Šฅ์€ Spark 0.6.0๋ถ€ํ„ฐ ๋„์ž…๋œ ์œ ์„œ ๊นŠ์€ ๊ธฐ๋Šฅ์ด๋‹ค. spark.speculation๋ผ๋Š” Config๋กœ ์ œ์–ดํ•˜๋Š”๋ฐ, ์„ค๋ช…์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

Databricks: Best Practices for Enabling Speculative Execution on Large Scale Platforms

If set to โ€œtrueโ€, performs speculative execution of tasks. This means if one or more tasks are running slowly in a stage, they will be re-launched.

์ด ๊ธฐ๋Šฅ์€ Spark์—์„œ ์‹คํ–‰ํ•˜๋Š” ์ผ๋ถ€ Task๊ฐ€ ๋น„์ •์ƒ์ ์œผ๋กœ ๋Š๋ฆฌ๊ฒŒ ์‹คํ–‰๋˜๊ณ  ์žˆ์„ ๋•Œ, ๊ทธ๊ฒƒ์„ ์ธ์‹ํ•˜๊ณ  ํ•ด๋‹น Task๋ฅผ ๋‹ค๋ฅธ Worker ๋…ธ๋“œ์—์„œ ์ถ”๊ฐ€๋กœ ์‹คํ–‰ํ•ด๋ณด๋Š” ๊ธฐ๋ฒ•์ด๋‹ค. speculative๋ผ๊ณ  ์ด๋ฆ„ ๋ถ™์€ ์ด์œ ๋Š” Task๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์™„๋ฃŒ๋˜์ง€ ์•Š์„ ๊ฐ€๋Šฅ์„ฑ์„ ์ถ”์ •(speculate)ํ•ด ๋Œ€๋น„ํ•œ๊ธฐ ๋•Œ๋ฌธ์ด๋ผ๊ณ  ํ•œ๋‹ค.

๋งŒ์•ฝ ๋‹ค๋ฅธ ๋…ธ๋“œ์— ๋ณต์ œ๋œ ์ž‘์—…์ด ๋Š๋ฆฌ๊ฒŒ ์‹คํ–‰๋˜๋˜ ๊ธฐ์กด ์ž‘์—…๋ณด๋‹ค ๋จผ์ € ๋๋‚˜๊ฒŒ ๋œ๋‹ค๋ฉด, ๊ทธ ์ž‘์—…์˜ ๊ฒฐ๊ณผ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ๊ธฐ์กด ์ž‘์—…์€ ์ทจ์†Œ(kill) ์‹œํ‚จ๋‹ค.

Spark Configuration

์š” ๊ธฐ๋Šฅ์€ ๊ธฐ๋ณธ์ ์œผ๋กœ ๊บผ์ ธ์žˆ๊ณ , ๊ธฐ๋Šฅ์„ ์ผœ๊ณ  ์‹ถ๋‹ค๋ฉด spark.speculation = true๋กœ ์„ค์ •ํ•˜๋ฉด ๋œ๋‹ค.

Speculation์—์„œ ์ž‘์—…์„ ๋ณต์ œํ• ์ง€ ๋ง์ง€ ์—ฌ๋ถ€ ํŒ๋‹จ์€ spark.speculation.interval์— ๋ช…์‹œํ•œ ์ฃผ๊ธฐ๋กœ ์ผ์–ด๋‚˜๋ฉฐ, ๊ธฐ๋ณธ๊ฐ’์€ 100ms๋กœ ๋˜์–ด ์žˆ๋‹ค. ์ด๋•Œ, spark.speculation.minTaskRuntime ๊ฐ’(default: 100ms)๋ณด๋‹ค ์˜ค๋ž˜ ์‹คํ–‰๋˜๋Š” ์ž‘์—…์ด Speculation ๋Œ€์ƒ์ด ๋œ๋‹ค. ๋˜, spark.speculation.quantile ๊ฐ’(default: 0.75)์— ์˜ํ•ด ํ•ด๋‹น Task๊ฐ€ ์‹คํ–‰๋˜๋Š” Stage์˜ Task๋“ค์ด ์ผ์ • ๋น„์œจ ์ด์ƒ ์‹คํ–‰ ์™„๋ฃŒ ๋˜์–ด์•ผ Speculation ์ž‘์—…์ด ํŠธ๋ฆฌ๊ฑฐ ๋˜๊ธฐ ์‹œ์ž‘ํ•œ๋‹ค.

Speculation ๊ฒ€์‚ฌ๊ฐ€ ์‹คํ–‰๋˜๋”๋ผ๋„, ์ž‘์—…์ด ์ถฉ๋ถ„ํžˆ ๋Š๋ ค์•ผ Speculative Execution์ด ํŠธ๋ฆฌ๊ฑฐ ๋œ๋‹ค. ๊ทธ ๊ฐ’์€ spark.speculation.multiplier๋กœ ํŒ๋‹จํ•˜๋ฉฐ, ํ•ด๋‹น Task๊ฐ€ ์‹คํ–‰๋˜๋Š” Stage์—์„œ ํ•จ๊ป˜ ์‹คํ–‰๋˜๋Š” ์ž‘์—…๋“ค์˜ ํ‰๊ท  ์ž‘์—… ์™„๋ฃŒ ์‹œ๊ฐ„์„ ๊ธฐ์ค€์œผ๋กœ ๋ช‡ ๋ฐฐ(default: 1.5) ์ด์ƒ ๊ฑธ๋ฆฌ๋ฉด ๋Š๋ฆฐ ์ž‘์—…์ด๋ผ๊ณ  ํŒ๋‹จํ•˜๊ณ , ์ž‘์—…์„ ๋ณต์ œํ•œ๋‹ค.

๋งบ์Œ๋ง

์š” ๊ธฐ๋Šฅ์€ ๋ณธ๋ž˜ Hadoop์—์„œ ์œ ๋ž˜ํ•œ ๊ธฐ๋Šฅ์ด๋‹ค. ํ•˜๋‘ก์—์„œ๋„ ๊ฐ™์€ ์ด๋ฆ„์ธ โ€œSpeculative Executionโ€๋ผ๊ณ  ๋ถˆ๋ €๋‹ค. ๋Œ€๊ทœ๋ชจ ๋ถ„์‚ฐ ์‹œ์Šคํ…œ์—์„œ ์ž‘์—…์ด ์ง€์—ฐ๋˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ์ค‘์š”ํ•œ ๊ธฐ๋ฒ•์ด๋ผ๊ณ  ํ•œ๋‹ค.

๋‹ค๋งŒ, Spark์—์„œ ์ œ๊ณตํ•˜๋Š” Default Config์˜ ๊ฐ’์ด ์‹ค์ œ ํ™˜๊ฒฝ์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ์—๋Š” ๊ดด๋ฆฌ๊ฐ€ ์žˆ์–ด์„œ Linkedin์˜ ๊ฒฝ์šฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ๊ฐ’์„ ์ปค์Šคํ…€ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค.

Databricks: Best Practices for Enabling Speculative Execution on Large Scale Platforms

References

Categories:

Updated: