1. EC2 Spot Instance Request
โถ Can get a discount up to 90% compared to On-demand
โถ Define max spot price and get the instance while current spot price < max
- ์ธ์คํด์ค์ ์คํ ๊ฐ๊ฒฉ์ด ์ฐ๋ฆฌ๊ฐ ์ง๋ถํ๊ณ ์ ํ๋ ์ต๋ ๊ฐ๊ฒฉ๋ณด๋ค ๋ฎ๋ค๋ฉด ํด๋น ์ธ์คํด์ค ์ ์ง
โถ The hourly spot price varies based on offer and capacity.
- ์๊ฐ๋น ์คํ์ ์คํผ๋ ์ฉ๋์ ๋ฐ๋ผ ๋ค๋ฅด๋ค.
โญ If the current spot price > your max price you can choose to stop or terminate your instance with a 2 minutes grace period.
โถ ํ์ฌ ์คํ ๊ฐ๊ฒฉ์ด ์ ์๋ ์ต๋ ๊ฐ๊ฒฉ์ ์ด๊ณผํ๋ฉด, ๋ ๊ฐ์ง๋ฅผ ์ ํ ํ ์ ์๋ค. (2๋ถ์ ์ ์๊ธฐ๊ฐ ์ ๊ณต๋จ)
โถ Option1_ ์ธ์คํด์ค ์ค์ง: ํ๋ ์์
์ค์งํ๊ณ ์ด๋ ๋ ์คํ ๊ฐ๊ฒฉ์ด ์ต๋ ๊ฐ๊ฒฉ ์๋๋ก ๋ด๋ ค๊ฐ๋ฉด ์ค๋จํ๋ ๊ณณ๋ถํฐ ์ธ์คํด์ค ๋ค์ ์์
โถ Option2_ ๋ ์ด์ ํ์ํ์ง ์๋ค๋ฉด ๊ทธ๋ฅ ์ธ์คํด์ค ์ข
๋ฃํ๊ณ ์์
๋ค์ ์์ํ ๋ ์๋ก์ด ์ธ์คํด์ค๋ก ์์
โถ Other strategy: Spot Block
- AWS ๊ฐ ์คํ ์ธ์คํด์ค๋ฅผ ํ์ํ๋ ๊ฒ์ ์ํ์ง ์๋๋ค๋ฉด ์คํ ๋ธ๋ญ ์ฌ์ฉ
- ์คํ ๋ธ๋ญ์ ์ง์ ๋ ๊ธฐ๊ฐ ๋์ ์คํ ์ธ์คํด์ค ์ฐจ๋จํ๋ ๊ฒ
- "block" spot instance during a specified time frame(1 to 6 hours) without interruptions
- In rare situations, the instance may be reclaimed
๐ฅ Spot Blocks are no longer available to new AWS customers since July 1st 2021 And won't be supported after
December 31 2022 but Still, they might appear in the exam
- 2022๋
์ดํ๋ก ์๋น์ค๊ฐ ์ข
๋ฃ๋์์ผ๋ ์ํ์ ๋์ฌ ์ ์์ผ๋ฏ๋ก ์์๋์
โถ EC2 Spot Instance is Used for batch jobs, data analysis, or workloads that are resilient to failures.
โถ Spot prices are based on AZ (region, ect)
![](https://blog.kakaocdn.net/dn/SKAIZ/btsL1sKConX/lXv6ZJdaKq0Ot1zMvEkQd1/img.png)
โญ If your user-defined max-price be something like $0.06 per hour, then no spot instance will be reclaimed.
2. How to terminate Spot Instances?
![](https://blog.kakaocdn.net/dn/dhNJ4m/btsL1jGxJoc/uG2EafPXQuCSGFkAJ43vWK/img.png)
![](https://blog.kakaocdn.net/dn/kzvqB/btsL1yKdmnn/KF9ZIwJYMpZ0sBQROB3uj0/img.png)
2-1. Spot Instance Request (์คํ ์ธ์คํด์ค ์์ฒญ)
Spot Instance๋ฅผ ์์ฒญํ๋ ๊ณผ์ ์์, ์ฌ์ฉ์๋ Spot Request๋ฅผ ์์ฑํ๋ค.
โถ Spot Request ์ํ
Open: ์์ฒญ์ด ์์ง ์ ๋ ์ํ, ์ธ์คํด์ค๋ฅผ ์คํํ ์ ์๋ ์์์ด ์ค๋น๋์ง ์์.
Active: ์์ฒญ์ด ์ถฉ์กฑ๋์ด Spot Instance๊ฐ ์คํ ์ค์ธ ์ํ
Disabled: ์ฌ์ฉ์๊ฐ ์์ฒญ์ ๋นํ์ฑํํ๊ฑฐ๋ ํน์ ์กฐ๊ฑด์ ๋ฐ๋ผ ๋นํ์ฑํ๋ ์ํ
โญ Spot Instance Request๋ Open, Active, Disabled ์ํ์ผ ๋๋ง ์ทจ์ํ ์ ์๋ค.
- ์ทจ์ ํ ์ ์๋ ๊ฒฝ์ฐ: Failed, Cancelled, Closed
โญ Spot Request๋ฅผ ์ทจ์ํด๋ Spot Instance๋ ์ค์ง๋์ง ์๋๋ค. ๋ณ๋๋ก ์ธ์คํด์ค๋ฅผ ์ค์งํ๊ฑฐ๋ ์ข
๋ฃํด์ผ ํ๋ค.
โญ Spot Instance๋ฅผ ์ค์งํ๋ ค๋ฉด ๋จผ์ Spot Request๋ฅผ ์ทจ์ํด์ผ ํ๋ค.
- ์ทจ์ํ๋ ๊ฒ์ ์ด์ ์ ์์ํ ์ธ์คํด์ค๋ฅผ ์ข
๋ฃํ๋ ๊ฒ์ด ์๋๋ค.
- ์ธ์คํด์ค๋ฅผ ์ข
๋ฃํ๋ ๊ฒ์ ์ ์ ๊ฐ ํ ์ผ์ด์ง AWS ๊ฐ ํ๋ ์ผ์ด ์๋๋ค.
๐ฅ ๋ฐ๋ผ์ ์คํ ์ธ์คํด์ค๋ฅผ ์์ ํ ์ข ๋ฃํ๊ณ ๋ค์ ์์๋์ง ์๋๋ก ํ๋ ค๋ฉด, ๋จผ์ ์คํ ์์ฒญ์ ์ทจ์ํ ๋ค์, ํด๋น ์คํ ์ธ์คํด์ค๋ฅผ ์ข ๋ฃํด์ผ ํ๋ค.
์๋ํ๋ฉด ์คํ ์ธ์คํด์ค๋ฅผ ๋จผ์ ์ข ๋ฃํ๋ฉด AWS๋ ํ์ฑํ๋ ์คํ ์์ฒญ(Active Spot Request)์ ๊ธฐ์ค์ผ๋ก ๋ค์ ์์์ ํ ๋นํด ์ธ์คํด์ค๋ฅผ ์ฌ์์ฑํ๋ ค๊ณ ์๋ํ๊ธฐ ๋๋ฌธ์ด๋ค. ์คํ ์์ฒญ์ ์ฌ์ฉ์๊ฐ ๋ช ์์ ์ผ๋ก ์ทจ์ํ์ง ์๋ ํ ๊ณ์ ๋จ์์๊ธฐ ๋๋ฌธ์, ์์ฒญ ์ํ๋ฅผ ๋จผ์ ์ฒ๋ฆฌํ์ง ์์ผ๋ฉด ์ธ์คํด์ค๊ฐ ์๋์ผ๋ก ๋ค์ ์คํ๋ ๊ฐ๋ฅ์ฑ์ด ์๋ค.
๐ ์์๊ฐ ์ค์ํ ์ด์
์คํ ์์ฒญ์ ์ทจ์ํ๋ฉด, AWS๋ ํด๋น ์์ฒญ๊ณผ ๊ด๋ จ๋ ์ฌํ ๋น ์์ ์ ์คํ๋ค.
๊ทธ๋ฐ ๋ค์, ์คํ ์ค์ธ ์คํ ์ธ์คํด์ค๋ฅผ ์ข ๋ฃํ๋ฉด ๋ ์ด์ ์ธ์คํด์ค๊ฐ ๋ค์ ์์ฑ๋์ง ์๋๋ค.
์ด๋ ๊ฒ ํด์ผ ์คํ ์ธ์คํด์ค์ ์์ฒญ ๋ชจ๋ ์์ ํ ์ข ๋ฃ๋๊ณ , ๋น์ฉ ๋ฐ์๋ ์ค๋จ๋๋ค.
3. Spot Fleets
โถ Spot Feets = set of Spot Instances + (optional) On-Demand Isntances
โถ The Spot Fleet will try to meet the target capacity with price constraints.
- Define possible launch pools: instance type (m5.large), OS, Availability Zone
- Can have multiple launch pools, so that the fleet can choose
- Spot Fleets stops launching instances when reaching capacity or max cost
โถ Strategies to allocate Spot Instances:
- lowestPrice: from the pool with the lowest price (cost optimization, short workload)
- diversified: distributed across all pools (great for availability, long workloads)
ํน์ ์ ํ์ Spot Instance(์: t3.large)๋ฅผ ์์ฒญํ๋ฉด, ํด๋น ์ธ์คํด์ค ์ ํ์ ์ฌ๋ฌ Spot Capacity Pool์์ ์ ๊ณต๋๋ค.Diversified ์ ๋ต์ ํ ํ์ด ์์ง๋๊ฑฐ๋ ์ค๋จ๋ ๊ฒฝ์ฐ ๋ค๋ฅธ ํ์์ ์ธ์คํด์ค๋ฅผ ์ ์งํ๋๋ก ์ค๊ณ๋์ด, ๊ฐ์ฉ์ฑ์ด ๋๋ค.
- capacityOptimized: pool with the optimal capacity for the number of instance
- priceCapacityOptimized (recommeded): pools with highest capacity available, then select the pool with the lowest price (best choice for most workloads)
๊ฐ๊ฒฉ ์ฉ๋ ์ต์ ํ๋ ๋จผ์ ์ฌ์ฉ ๊ฐ๋ฅํ ์ฉ๋์ด ๊ฐ์ฅ ํฐ ํ์ ์ ํํ๊ณ ๊ทธ ์ค ๊ฐ๊ฒฉ์ด ๊ฐ์ฅ ๋ฎ์ ํ์ ์ ํํ๋ ์ ๋ต
โญ Spot fleets allow us to automatically request Spot Instances with the lowest price
4. Spot Instances VS Spot Fleets ์ ๋ฆฌ
4-1. Spot Instances
โถ AWS์ EC2 ์ธ์คํด์ค ์ ํ ์ค ํ๋๋ก, ๋ฏธ์ฌ์ฉ EC2 ์ฉ๋์ ๊ฒฝ๋งค ๋ฐฉ์์ผ๋ก ์ ๊ณตํ๋ค.
โถ ์ผ๋ฐ ์จ๋๋งจ๋ ์ธ์คํด์ค๋ณด๋ค ์ต๋ 90% ์ ๋ ดํ์ง๋ง, AWS๊ฐ ํ์ํ๋ฉด ์ธ์ ๋ ์ง ์ธ์คํด์ค๋ฅผ ์ข
๋ฃํ ์ ์๋ค.
โถ ํน์ ํ ๋จ์ผ ์ธ์คํด์ค๋ฅผ ์์ฒญํด ์ฌ์ฉํ๋ ๋ฐฉ์์ด๋ค.
โถ ๋จ์ผ ์ธ์คํด์ค ์์ฒญ.
โถ ํน์ ์ํฌ๋ก๋์ ํ์ฉ (์: ๋ฐฐ์น ์ฒ๋ฆฌ, ๋ฐ์ดํฐ ๋ถ์, CI/CD ์์
)
โถ ๊ฐ๊ฒฉ์ ๋ณ๋ ๊ฐ๋ฅ (AWS Spot ์์ฅ ์ํฉ์ ๋ฐ๋ผ)
โถ ๊ฐ์์ค๋ฌ์ด ์ค๋จ์ ๋๋นํด์ผ ํจ. (Spot Instance ์ค๋จ ํต๋ณด๋ 2๋ถ ์ ์ ์ ๊ณต)
4-2. Spot Fleets
โถ Spot Instances์ ์งํฉ์ ๊ด๋ฆฌํ๋ ์๋น์ค๋ก, ์ฌ๋ฌ ๊ฐ์ฉ ์์ญ, ์ธ์คํด์ค ์ ํ, ๊ตฌ๋งค ์ต์
์ ์กฐํฉํด ์ต์ ์ ๋น์ฉ ํจ์จ์ฑ์ ์ ๊ณตํ๋ค.
โถ Spot Fleet ์์ฒญ์ ์์ฑํ๋ฉด AWS๊ฐ ์ฌ์ฉ์๊ฐ ์ค์ ํ ์ ์ฑ
(์: ๋น์ฉ ์ต์ ํ, ๊ฐ์ฉ์ฑ)์ ๊ธฐ์ค์ผ๋ก ์ฌ๋ฌ Spot Instances๋ฅผ ํ ๋น ๋ฐ ๊ด๋ฆฌํ๋ค.
โถ ๋ค์ํ ์ธ์คํด์ค์ ์์ญ ์กฐํฉ: ์จ๋๋งจ๋, ์์ฝ ์ธ์คํด์ค, Spot Instances๋ฅผ ํผํฉ ๊ฐ๋ฅํ๋ค.
โถ ์๋ ์ค์ผ์ผ๋ง: ์์ฒญ์ ๋ฐ๋ผ ์๋์ผ๋ก ์ธ์คํด์ค๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ์ ๊ฑฐํ๋ค.
โถ Fleet์์ ์ข
๋ฃ๋ Spot Instance๊ฐ ์์ผ๋ฉด ์ ์ธ์คํด์ค๋ก ๋์ฒด ๊ฐ๋ฅํ๋ค.
โถ ๋น์ฉ ๊ด๋ฆฌ ์ ์ฑ
(์ต์ ๋น์ฉ, ์ต๋ ์ฒ๋ฆฌ๋ ๋ฑ) ์ค์ ๊ฐ๋ฅํ๋ค.
Spot Instances โ ๋ฐฐ์น ์์ , ๊ฐ๋ฐ ํ ์คํธ ํ๊ฒฝ, ์ผํ์ฑ ์ํฌ๋ก๋
Spot Fleets โ ๋ถ์ฐ ์ฒ๋ฆฌ, ๋๊ท๋ชจ ๋ฐ์ดํฐ ๋ถ์, ๋จธ์ ๋ฌ๋ ๋ชจ๋ธ ํ์ต, ์น ์ ํ๋ฆฌ์ผ์ด์ ์ค์ผ์ผ๋ง
ํน์ง | Spot Instances | Spot Fleet |
๊ด๋ฆฌ ๋จ์ | ๋จ์ผ Spot Instance ์์ฒญ | ์ฌ๋ฌ ์ธ์คํด์ค ์์ฒญ ๊ด๋ฆฌ (Fleet ๋จ์) |
๊ตฌ์ฑ ๊ฐ๋ฅ์ฑ | ๋จ์ผ ๊ฐ์ฉ์ญ์ญ, ๊ฐ๋ณ์ ์ผ๋ก ์ฌ์ฉํ๋ ๊ฒฝ์ฐ | ๋ค์ํ ๊ฐ์ฉ ์์ญ, ์ธ์คํด์ค ์ ํ + ๊ตฌ๋งค์ต์ ์กฐํฉ |
์๋ํ ์์ค | ์ฌ์ฉ์๊ฐ ์๋์ผ๋ก ๊ด๋ฆฌ | Fleet์ด ์๋์ผ๋ก ์ธ์คํด์ค ์ถ๊ฐ & ๋์ฒด |
ํ์ฉ ๋ฒ์ | ๋จ์ผ ์์ , ์์ workloads | ๋๊ท๋ชจ ์์ , ๋น์ฉ ์ต์ ํ๊ฐ ์ค์ํ ํ๊ฒฝ |