๐Ÿ“‚ AWS/AWS Developer - Associate

[AWS] Developer Associate #3 Elastic Load Balancing(ELB)

dhyuck 2024. 4. 14. 00:18
๋ฐ˜์‘ํ˜•

๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ(Load balancing)์ด๋ž€?

  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์€ ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ์„œ๋ฒ„๋“ค์—๊ฒŒ ๋„คํŠธ์›Œํฌ ํŠธ๋ž˜ํ”ฝ์„ ๊ท ๋“ฑํ•˜๊ฒŒ ๋ถ„๋ฐฐํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ์ˆ˜ํ–‰ํ•˜๋Š” ์žฅ์น˜๋‚˜ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ๋กœ๋“œ๋ฐธ๋Ÿฐ์„œ(Load balancer)๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.
  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ํ†ตํ•ด ๋ถ€ํ•˜๋ฅผ ๋ถ„์‚ฐํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๊ฐ€์šฉ์„ฑ๊ณผ ํ™•์žฅ์„ฑ ๋ฐ ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ฌ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ์— ์ปดํ“จํŒ… ๋ฆฌ์†Œ์Šค๋ฅผ ์ถ”๊ฐ€ ๋ฐ ์ œ๊ฑฐํ•˜์—ฌ ์ˆ˜ํ‰์  ํ™•์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • AWS๋Š” ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ ์„œ๋น„์Šค๋กœ ELB(Elastic Load Balancing)๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

ELB(Elastic Load Balancing)๋ž€?

  • ELB๋Š” ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ํŠธ๋ž˜ํ”ฝ์„ ๋ฐ›์•„ ๋“ฑ๋ก๋œ ๋Œ€์ƒ(target)์œผ๋กœ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.

  • ELB๋Š” ํด๋ผ์ด์–ธํŠธ์— ๋Œ€ํ•œ ๋‹จ์ผ ์ ‘์ (single point of contact) ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค.

  • ELB๋Š” ๋ฆฌ์Šค๋„ˆ์™€ ํƒ€๊ฒŸ ๊ทธ๋ฃน์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • ๋ฆฌ์Šค๋„ˆ(Listeners)๋Š” ํ”„๋กœํ† ์ฝœ๊ณผ ํฌํŠธ ๋ฒˆํ˜ธ๋กœ ๊ตฌ์„ฑ๋œ ํ”„๋กœ์„ธ์Šค๋กœ ELB๋กœ ๋“ค์–ด์˜ค๋Š” ์š”์ฒญ์„ LISTENํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

  • ํƒ€๊ฒŸ ๊ทธ๋ฃน(target group)์€ ๋ถ€ํ•˜ ๋ถ„์‚ฐ ๋Œ€์ƒ์„ ์ •์˜ํ•œ ๊ฒƒ์œผ๋กœ ๋ฆฌ์Šค๋„ˆ์— ์˜ํ•ด ํŠธ๋ž˜ํ”ฝ์ด ์ „๋‹ฌ๋˜๋Š” ๋Œ€์ƒ์ž…๋‹ˆ๋‹ค.

  • ELB๋Š” ํ—ฌ์Šค์ฒดํฌ๋ฅผ ํ†ตํ•ด target์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  target์˜ ์ƒํƒœ๊ฐ€ ๋น„์ •์ƒ์ด๋ผ๋ฉด ํŠธ๋ž˜ํ”ฝ์„ ์ „๋‹ฌํ•˜์ง€ ์•Š๊ณ  ์ƒํƒœ๊ฐ€ ์ •์ƒ์ธ target์œผ๋กœ๋งŒ ํŠธ๋ž˜ํ”ฝ์„ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.
    target์ด ๋‹ค์‹œ ์ •์ƒ์œผ๋กœ ๊ฐ์ง€๋˜๋ฉด ํŠธ๋ž˜ํ”ฝ์„ ๋‹ค์‹œ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.

  • ํ—ฌ์Šค ์ฒดํฌ๋Š” target group์„ ๋‹จ์œ„๋กœ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.

  • ELB๋Š” public IP๋ฅผ ๊ฐ€์ง€๋Š” internet-facing ๋˜๋Š” private IP๋งŒ ๊ฐ€์ง€๋Š” internal๋กœ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    internet-facing ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ์™€ internal ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋Š” ๋ชจ๋‘ private IP๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ target์œผ๋กœ ์š”์ฒญ์„ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.

  • ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋Š” amazonaws.com ๋„๋ฉ”์ธ์„ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— ํด๋ผ์ด์–ธํŠธ๋Š” ELB์— ์š”์ฒญ์„ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด์„œ Amazon DNS ์„œ๋ฒ„๋ฅผ ์ด์šฉํ•˜์—ฌ ELB์˜ IP๋ฅผ ํ™•์ธํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  • Elastic Load Balancing(ELB)์€ 4๊ฐ€์ง€ ์œ ํ˜•์˜ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.

  • CLB๋Š” ELB v1์ด๋ผ๊ณ  ํ•˜๋ฉฐ ALB, NLB, GWLB๋Š” ELB v2๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

CLB(Classic Load Balancer)

  • EC2-Classic ๋„คํŠธ์›Œํฌ์—์„œ ์‹คํ–‰ ์ค‘์ธ ๊ธฐ์กด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด ์žˆ๋Š” ๊ฒฝ์šฐ CLB๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • CLB๋Š” ์ƒˆ๋กœ์šด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

ALB(Application Load Balancer)

  • ALB๋Š” HTTP ๋ฐ HTTPS ํŠธ๋ž˜ํ”ฝ์„ ์ฒ˜๋ฆฌํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • ALB๋Š” L7 ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋กœ request ์ˆ˜์ค€์—์„œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.
  • ALB๋Š” ๋งˆ์ดํฌ๋กœ ์„œ๋น„์Šค์™€ ์ปจํ…Œ์ด๋„ˆ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋Œ€์ƒ์œผ๋กœ ๊ณ ๊ธ‰ ๋ผ์šฐํŒ… ๊ธฐ๋Šฅ๊ณผ ๊ฐ€์‹œ์„ฑ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
  • ALB์˜ IP๋Š” ๊ณ ์ •๋˜์ง€ ์•Š๊ณ  ๋ณ€ํ™”ํ•ฉ๋‹ˆ๋‹ค.
  • ALB์˜ ๋ฆฌ์Šค๋„ˆ๋Š” ๋‹ค์–‘ํ•œ routing rule์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
    • Host header ๋ผ์šฐํŒ…์€ ํ˜ธ์ŠคํŠธ ์ด๋ฆ„์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.
    • Path based ๋ผ์šฐํŒ…์€ URL์˜ ๊ฒฝ๋กœ(Path)๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.
    • HTTP method์€ request์˜ HTTP method(GET, POST ๋“ฑ)์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.
    • Source IP๋Š” request์˜ IP์ฃผ์†Œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.
    • Query string์€ ์ฟผ๋ฆฌ ๋ฌธ์ž์—ด์˜ ํ‚ค/๊ฐ’์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ผ์šฐํŒ…ํ•ฉ๋‹ˆ๋‹ค.

NLB(Network Load Balancer)

  • NLB๋Š” ๊ณ ์„ฑ๋Šฅ์˜ ๋กœ๋“œ๋ฐธ๋Ÿฐ์‹ฑ, ๋Œ€๊ทœ๋ชจ TLS offloading, UDP ์ง€์›, Static IP ์ฃผ์†Œ๊ฐ€ ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • NLB๋Š” L4 ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋กœ connection ์ˆ˜์ค€์—์„œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.
  • NLB๋Š” ultra-lowํ•œ ์ง€์—ฐ ์‹œ๊ฐ„์„ ์œ ์ง€ํ•˜๋ฉด์„œ ์ดˆ๋‹น ์ˆ˜๋ฐฑ๋งŒ๊ฐœ์˜ ์š”์ฒญ์„ ์•ˆ์ „ํ•˜๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • NLB๋Š” ๊ณ ์ • IP๋ฅผ ์ œ๊ณตํ•˜๋ฏ€๋กœ ALB์— ๊ณ ์ • IP๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ๋งŽ์ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • NLB์˜ ๋ฆฌ์Šค๋„ˆ๋Š” ์ˆ˜์‹ ํ•œ ์š”์ฒญ์„ ์ „๋‹ฌํ•  target group์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

GWLB(Gateway Load Balancer)

  • GWLB๋Š” GENEVE๋ฅผ ์ง€์›ํ•˜๋Š” third-party virtual appliance๋ฅผ ๋ฐฐํฌํ•ด์•ผํ•˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
  • GWLB๋Š” L3 ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๋กœ ๋ชจ๋“  ํฌํŠธ์—์„œ ๋ชจ๋“  IP ํŒจํ‚ท์„ ์ˆ˜์‹ ํ•˜๊ณ  target์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค.
  • GWLB์™€ virtual appliance๋Š” 6081 GENEVE ํ”„๋กœํ† ์ฝœ์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠธ๋ž˜ํ”ฝ์„ ๊ตํ™˜ํ•ฉ๋‹ˆ๋‹ค.
  • third-party appliance๋Š” ๋ณด์•ˆ๊ณผ ์ปดํ”Œ๋ผ์ด์–ธ์Šค(๋‚ด๋ถ€ํ†ต์ œ)๋ฅผ ๊ฐ•ํ™”ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ(Cross-zone load balancing)

  • ๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ํ™œ์„ฑํ™”ํ•˜๋ฉด ๋ชจ๋“  target์— ๋™์ผํ•˜๊ฒŒ ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
  • ๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ๋น„ํ™œ์„ฑํ™”ํ•˜๋ฉด AZ ์ˆ˜์ค€์—์„œ ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
  • ALB๋Š” ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ ์ˆ˜์ค€์—์„œ ๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์ด ํ•ญ์ƒ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. target group์—์„œ ๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์„ ๋น„ํ™œ์„ฑํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • NLB์™€ GWLB๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ต์ฐจ ์˜์—ญ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ์ด ๋น„ํ™œ์„ฑํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

SSL/TLS

  • SSL์€ CLB, ALB, NLB์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • CLB๋Š” 1๊ฐœ์˜ SSL ์ธ์ฆ์„œ๋งŒ์„ ์ ์šฉ ๊ฐ€๋Šฅํ•˜๊ณ  ALB์™€ NLB๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ SSL ์ธ์ฆ์„œ๋ฅผ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Sticky session

  • Sticky session(๊ณ ์ • ์„ธ์…˜)์€ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ์‚ฌ์šฉ์ž์˜ ๋ชจ๋“  ์š”์ฒญ์„ ๋™์ผํ•œ target์œผ๋กœ ์ „์†กํ•˜๋„๋ก ํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.
  • Sticky session์˜ ํ•ต์‹ฌ์€ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ๊ฐ€ ์–ผ๋งˆ๋‚˜ ๋™์•ˆ ์‚ฌ์šฉ์ž์˜ ์š”์ฒญ์„ ๋™์ผํ•œ ๋Œ€์ƒ์œผ๋กœ ์ „๋‹ฌํ•˜๋„๋ก ํ• ์ง€๋ฅผ ๊ฒฐ์ •ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
  • Sticky session์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ cookie๋ฅผ ์ง€์›ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • Sticky session์€ target group ์ˆ˜์ค€์—์„œ ํ™œ์„ฑํ™”๋ฉ๋‹ˆ๋‹ค.
  • Sticky session์€ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ง€์†์ ์ธ ์„œ๋น„์Šค๋ฅผ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด state๋ฅผ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค.
  • Sticky session์€ Session affinity๋ผ๊ณ ๋„ ํ•ฉ๋‹ˆ๋‹ค.
๋ฐ˜์‘ํ˜•