Home > Network > 2024 > ๐ŸŒ[Network] Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?

๐ŸŒ[Network] Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?
Network

๐ŸŒ[Network] Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)๋ž€ ๋ฌด์—‡์ผ๊นŒ์š”?

๐Ÿ“Œ Intro.

  • โ†˜๏ธŽ Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)๋Š” ๋„คํŠธ์›Œํฌ ํŠธ๋ž˜ํ”ฝ์„ ์—ฌ๋Ÿฌ ์„œ๋ฒ„๋กœ ๋ถ„์‚ฐ์‹œ์ผœ ์‹œ์Šคํ…œ์˜ ์„ฑ๋Šฅ, ์•ˆ์ •์„ฑ, ๊ฐ€์šฉ์„ฑ์„ ๋†’์ด๋Š” ๊ธฐ์ˆ  ๋˜๋Š” ์žฅ์น˜์ž…๋‹ˆ๋‹ค.

1๏ธโƒฃ Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)์˜ ํ•ต์‹ฌ ์—ญํ• .

  • 1๏ธโƒฃ ํŠธ๋ž˜ํ”ฝ ๋ถ„์‚ฐ:
    • โ†˜๏ธŽ ์—ฌ๋Ÿฌ ์„œ๋ฒ„(๋…ธ๋“œ)์— ์‚ฌ์šฉ์ž ์š”์ฒญ(ํŠธ๋ž˜ํ”ฝ)์„ ๊ณ ๋ฅด๊ฒŒ ๋ถ„์‚ฐ.
    • โ†˜๏ธŽ ํŠน์ • ์„œ๋ฒ„์— ๊ณผ๋ถ€ํ•˜๊ฐ€ ๊ฑธ๋ฆฌ์ง€ ์•Š๋„๋ก ๊ด€๋ฆฌ.
  • 2๏ธโƒฃ ๊ณ ๊ฐ€์šฉ์„ฑ(High Availability):
    • โ†˜๏ธŽ ์ผ๋ถ€ ์„œ๋ฒ„๊ฐ€ ๋‹ค์šด๋˜๋”๋ผ๋„ ๋‹ค๋ฅธ ์„œ๋ฒ„๊ฐ€ ํŠธ๋ž˜ํ”ฝ์„ ์ฒ˜๋ฆฌํ•˜์—ฌ ์„œ๋น„์Šค ์ค‘๋‹จ ๋ฐฉ์ง€.
  • 3๏ธโƒฃ ํ™•์žฅ์„ฑ(Scalability):
    • โ†˜๏ธŽ ์„œ๋ฒ„๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์ œ๊ฑฐํ•˜์—ฌ ํŠธ๋ž˜ํ”ฝ ์ฒ˜๋ฆฌ ๋Šฅ๋ ฅ์„ ์‰ฝ๊ฒŒ ํ™•์žฅ.
  • 4๏ธโƒฃ ์žฅ์•  ๊ฐ์ง€ ๋ฐ ๋ณต๊ตฌ:
    • โ†˜๏ธŽ ์ฃผ๊ธฐ์ ์œผ๋กœ ์„œ๋ฒ„ ์ƒํƒœ๋ฅผ ํ™•์ธ(Health Check).
    • โ†˜๏ธŽ ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š” ์„œ๋ฒ„๋กœ์˜ ํŠธ๋ž˜ํ”ฝ ์ „๋‹ฌ์„ ์ค‘๋‹จ.

2๏ธโƒฃ Load Balancer(๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ)์˜ ์ž‘๋™ ์›๋ฆฌ.

  • 1๏ธโƒฃ ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ:
    • โ†˜๏ธŽ ์‚ฌ์šฉ์ž๊ฐ€ ์›น์‚ฌ์ดํŠธ๋‚˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ์š”์ฒญ์„ ๋ณด๋ƒ„.
  • 2๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋กœ ์ „๋‹ฌ:
    • โ†˜๏ธŽ ์š”์ฒญ์€ ๋จผ์ € ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋กœ ์ „๋‹ฌ๋จ.
  • 3๏ธโƒฃ ์„œ๋ฒ„ ์„ ํƒ:
    • โ†˜๏ธŽ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋Š” ์—ฌ๋Ÿฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ตœ์ ์˜ ์„œ๋ฒ„๋ฅผ ์„ ํƒ.
  • 4๏ธโƒฃ ์š”์ฒญ ์ „๋‹ฌ:
    • โ†˜๏ธŽ ์„ ํƒ๋œ ์„œ๋ฒ„๋กœ ์š”์ฒญ์„ ์ „๋‹ฌ.
  • 5๏ธโƒฃ ์‘๋‹ต ๋ฐ˜ํ™˜:
    • โ†˜๏ธŽ ์„œ๋ฒ„๋Š” ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•œ ํ›„, ์‘๋‹ต์„ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋ฅผ ํ†ตํ•ด ํด๋ผ์ด์–ธํŠธ๋กœ ๋ฐ˜ํ™˜.

3๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์‹ฑ ์•Œ๊ณ ๋ฆฌ์ฆ˜(Load Balancing Algorithm)

  • 1๏ธโƒฃ ๋ผ์šด๋“œ ๋กœ๋นˆ(Round Robin)
    • โ†˜๏ธŽ ์š”์ฒญ์„ ๊ฐ ์„œ๋ฒ„์— ์ˆœ์ฐจ์ ์œผ๋กœ ๋ถ„์‚ฐ.
  • 2๏ธโƒฃ ๊ฐ€์ค‘ ๋ผ์šด๋“œ ๋กœ๋นˆ(Weighted Round Robin)
    • โ†˜๏ธŽ ์„œ๋ฒ„์— ๊ฐ€์ค‘์น˜๋ฅผ ๋ถ€์—ฌํ•ด ๋” ๊ฐ•๋ ฅํ•œ ์„œ๋ฒ„์— ๋” ๋งŽ์€ ์š”์ฒญ ์ „๋‹ฌ.
  • 3๏ธโƒฃ ์ตœ์†Œ ์—ฐ๊ฒฐ(Least Connections)
    • โ†˜๏ธŽ ํ˜„์žฌ ๊ฐ€์žฅ ์ ์€ ์—ฐ๊ฒฐ์„ ๊ฐ€์ง„ ์„œ๋ฒ„๋กœ ์š”์ฒญ ์ „๋‹ฌ.
  • 4๏ธโƒฃ IP ํ•ด์‹œ(IP Hash)
    • โ†˜๏ธŽ ํด๋ผ์ด์–ธํŠธ์˜ IP ์ฃผ์†Œ๋ฅผ ํ•ด์‹œ๋กœ ๋ณ€ํ™˜ํ•˜์—ฌ ํŠน์ • ์„œ๋ฒ„๋กœ ํ•ญ์ƒ ์—ฐ๊ฒฐ.
  • 5๏ธโƒฃ ์‘๋‹ต ์‹œ๊ฐ„ ๊ธฐ๋ฐ˜(Least Response Time)
    • โ†˜๏ธŽ ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ์‘๋‹ตํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋ฒ„์— ์š”์ฒญ ์ „๋‹ฌ.

4๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)์˜ ์œ ํ˜•.

  • 1๏ธโƒฃ ํ•˜๋“œ์›จ์–ด ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Hardware Load Balancer)
    • โ†˜๏ธŽ ์ „์šฉ ์žฅ๋น„๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์‚ฐ
      • โ†˜๏ธŽ ์˜ˆ: F5, Citrix NetScaler
  • 2๏ธโƒฃ ์†Œํ”„ํŠธ์›จ์–ด ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Software Load Balancer)
    • โ†˜๏ธŽ ์†Œํ”„ํŠธ์›จ์–ด๋กœ ๊ตฌํ˜„๋œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)
      • โ†˜๏ธŽ ์˜ˆ: Nginx, HAProxy
  • 3๏ธโƒฃ ํด๋ผ์šฐ๋“œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Cloud Load Balancer)
    • โ†˜๏ธŽ ํด๋ผ์šฐ๋“œ ์„œ๋น„์Šค ์ œ๊ณต์ž๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)
      • โ†˜๏ธŽ ์˜ˆ: AWS ELB(Elastic Load Balancer), GCP Load Balancer, Azure Load Balancer

5๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)์˜ ๊ณ„์ธต.

  • 1๏ธโƒฃ L4(Layer 4) ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ
    • โ†˜๏ธŽ OSI 4๊ณ„์ธต(Transport Layer)์—์„œ ์ž‘๋™.
    • โ†˜๏ธŽ TCP/UDP ํ”„๋กœํ† ์ฝœ ๊ธฐ๋ฐ˜์˜ ํŠธ๋ž˜ํ”ฝ ๋ถ„์‚ฐ.
    • โ†˜๏ธŽ ์†๋„๊ฐ€ ๋น ๋ฅด๊ณ  ํšจ์œจ์ .
  • 2๏ธโƒฃ L7(Layer 7) ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ
    • โ†˜๏ธŽ OSI 7๊ณ„์ธต(Application Layer)์—์„œ ์ž‘๋™.
    • โ†˜๏ธŽ HTTP/HTTPS ํŠธ๋ž˜ํ”ฝ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ถ„์‚ฐ.
    • โ†˜๏ธŽ URL, ์ฟ ํ‚ค, HTTP ํ—ค๋” ๋“ฑ์œผ๋กœ ์„ธ๋ถ€์ ์ธ ํŠธ๋ž˜ํ”ฝ ์ œ์–ด ๊ฐ€๋Šฅ.

6๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)์˜ ์žฅ์ .

  • 1๏ธโƒฃ ๊ณ ๊ฐ€์šฉ์„ฑ ๋ฐ ์•ˆ์ •์„ฑ
    • โ†˜๏ธŽ ์„œ๋ฒ„ ์žฅ์•  ์‹œ ์ž๋™์œผ๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋‹ค๋ฅธ ์„œ๋ฒ„๋กœ ์ „๋‹ฌ.
  • 2๏ธโƒฃ ํ™•์žฅ์„ฑ
    • โ†˜๏ธŽ ์ˆ˜์š”๊ฐ€ ์ฆ๊ฐ€ํ•  ๋•Œ ์„œ๋ฒ„๋ฅผ ์†์‰ฝ๊ฒŒ ์ถ”๊ฐ€ ๊ฐ€๋Šฅ.
  • 3๏ธโƒฃ ๋ณด์•ˆ ๊ฐ•ํ™”
    • โ†˜๏ธŽ DDoS ๊ณต๊ฒฉ ๋ฐฉ์–ด, SSL ์•”ํ˜ธํ™” ์ง€์›.
  • 4๏ธโƒฃ ์„ฑ๋Šฅ ์ตœ์ ํ™”
    • โ†˜๏ธŽ ํŠธ๋ž˜ํ”ฝ์„ ํšจ์œจ์ ์œผ๋กœ ๋ถ„์‚ฐํ•˜์—ฌ ์„œ๋ฒ„ ๊ณผ๋ถ€ํ•˜ ๋ฐฉ์ง€.

7๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)์˜ ์‚ฌ์šฉ ์‚ฌ๋ก€.

  • 1๏ธโƒฃ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜
    • โ†˜๏ธŽ ์—ฌ๋Ÿฌ ์›น ์„œ๋ฒ„๋กœ ํŠธ๋ž˜ํ”ฝ์„ ๋ถ„์‚ฐํ•˜์—ฌ ๋น ๋ฅธ ์‘๋‹ต ์ œ๊ณต.
  • 2๏ธโƒฃ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋ถ€ํ•˜ ๋ถ„์‚ฐ
    • โ†˜๏ธŽ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ฝ๊ธฐ/์“ฐ๊ธฐ ์š”์ฒญ์„ ์—ฌ๋Ÿฌ DB ์„œ๋ฒ„๋กœ ๋ถ„์‚ฐ.
  • 3๏ธโƒฃ ํด๋ผ์šฐ๋“œ ํ™˜๊ฒฝ
    • โ†˜๏ธŽ AWS, Azure, GCP ๋“ฑ์—์„œ ํด๋ผ์šฐ๋“œ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Cloud Load Balancer) ์‚ฌ์šฉ.
  • 4๏ธโƒฃ API Gateway
    • โ†˜๏ธŽ API ์š”์ฒญ์„ ์—ฌ๋Ÿฌ ์„œ๋ฒ„๋กœ ๋ถ„์‚ฐ ์ฒ˜๋ฆฌ.

8๏ธโƒฃ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer) ์„ ํƒ ๊ธฐ์ค€.

  • 1๏ธโƒฃ ํŠธ๋ž˜ํ”ฝ ์œ ํ˜•
    • โ†˜๏ธŽ HTTP/HTTPS ํŠธ๋ž˜ํ”ฝ์ด๋ฉด Layer 7 ์‚ฌ์šฉ.
    • โ†˜๏ธŽ TCP/UDP ํŠธ๋ž˜ํ”ฝ์ด๋ฉด Layer 4 ์‚ฌ์šฉ.
  • 2๏ธโƒฃ ํ™•์žฅ์„ฑ ์š”๊ตฌ์‚ฌํ•ญ
    • โ†˜๏ธŽ ์ˆ˜์ง ํ™•์žฅ ๋˜๋Š” ์ˆ˜ํ‰ ํ™•์žฅ
  • 3๏ธโƒฃ ๋ณด์•ˆ ์š”๊ตฌ์‚ฌํ•ญ
    • โ†˜๏ธŽ SSL/TLS ์ง€์› ์—ฌ๋ถ€
  • 4๏ธโƒฃ ์˜ˆ์‚ฐ๊ณผ ๋น„์šฉ
    • โ†˜๏ธŽ ํ•˜๋“œ์›จ์–ด vs ์†Œํ”„ํŠธ์›จ์–ด vs ํด๋ผ์šฐ๋“œ

๐Ÿš€ ๊ฒฐ๋ก .

  • โ†˜๏ธŽ ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋Š” ํŠธ๋ž˜ํ”ฝ ๋ถ„์‚ฐ, ๊ณ ๊ฐ€์šฉ์„ฑ, ํ™•์žฅ์„ฑ, ๋ณด์•ˆ์„ ์œ„ํ•œ ํ•ต์‹ฌ ์š”์†Œ.
  • โ†˜๏ธŽ ํด๋ผ์šฐ๋“œ ๊ธฐ๋ฐ˜์—์„œ ์šด์˜ ์ค‘์ด๋ผ๋ฉด AWS ELB, Azure Load Balancer์™€ ๊ฐ™์€ ์„œ๋น„์Šค๋ฅผ ๊ณ ๋ ค.
  • โ†˜๏ธŽ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์š”๊ตฌ์‚ฌํ•ญ์— ๋”ฐ๋ผ L4 ๋˜๋Š” L7 ๋กœ๋“œ ๋ฐธ๋Ÿฐ์„œ(Load Balancer)๋ฅผ ์„ ํƒ.
  • ๐Ÿ”‘ ํ•ต์‹ฌ: โ€œ์„œ๋ฒ„์˜ ๋ถ€๋‹ด์„ ๋‚˜๋ˆ„๊ณ , ์žฅ์• ๋ฅผ ์ตœ์†Œํ™”ํ•˜๋ฉฐ, ์„œ๋น„์Šค ๊ฐ€์šฉ์„ฑ์„ ๋†’์ธ๋‹ค.โ€