refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
---
|
||||
id: wiki-2026-0508-load-balancing-strategies
|
||||
title: Load Balancing Strategies
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Load Balancer, LB, Reverse Proxy]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [networking, load-balancer, nginx, envoy, haproxy, aws-alb]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack: { language: Config, framework: Nginx/Envoy/HAProxy/AWS }
|
||||
---
|
||||
|
||||
# Load Balancing Strategies
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 LB = traffic 분산 + health check + sticky"**. 알고리즘은 균등성과 affinity의 trade-off.
|
||||
|
||||
## 매 핵심
|
||||
### 매 알고리즘
|
||||
- **Round-robin**: 순차. 단순, 동질 서버.
|
||||
- **Weighted RR**: 용량 차등.
|
||||
- **Least connections**: 활성 연결 최소. long-lived 적합.
|
||||
- **Least response time**: 평균 응답 + connection 수.
|
||||
- **IP hash**: client IP→server. session affinity.
|
||||
- **Consistent hash**: cache/shard. node 추가 시 K/n key만 재배치.
|
||||
- **Random / P2C**: power of two choices, least-loaded 선택. 간단·강력.
|
||||
|
||||
### 매 Layer
|
||||
- **L4 (TCP/UDP)**: 빠름, opaque. NLB, HAProxy TCP mode.
|
||||
- **L7 (HTTP)**: header/path 기반 라우팅, TLS 종료. ALB, Nginx, Envoy.
|
||||
|
||||
### 매 Health check
|
||||
- Active: /health 주기적 GET
|
||||
- Passive: 실제 요청 실패 카운트
|
||||
- Slow start: 신규 노드에 점진적 traffic
|
||||
- Outlier detection (Envoy): 연속 5xx → eject
|
||||
|
||||
### 매 Session affinity (sticky)
|
||||
- Cookie-based (LB가 cookie 발급)
|
||||
- Source IP (NAT 뒤에 모이면 unbalanced)
|
||||
- Header-based (custom)
|
||||
|
||||
### 매 응용
|
||||
1. Web app: ALB + multi-AZ
|
||||
2. gRPC/HTTP2: Envoy (L7 multiplex)
|
||||
3. DB read replica: ProxySQL, PgBouncer
|
||||
4. Cache shard: consistent hash (Redis cluster)
|
||||
5. Service mesh: Envoy sidecar (Istio, Linkerd)
|
||||
|
||||
## 💻 패턴
|
||||
### Nginx upstream
|
||||
```nginx
|
||||
upstream backend {
|
||||
least_conn; # algorithm
|
||||
server app1:8080 weight=3 max_fails=3 fail_timeout=30s;
|
||||
server app2:8080 weight=1;
|
||||
server app3:8080 backup; # only if others down
|
||||
keepalive 32;
|
||||
}
|
||||
server {
|
||||
location / {
|
||||
proxy_pass http://backend;
|
||||
proxy_set_header Host $host;
|
||||
proxy_next_upstream error timeout http_502 http_503;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### HAProxy
|
||||
```
|
||||
backend web
|
||||
balance leastconn
|
||||
option httpchk GET /health
|
||||
server s1 10.0.0.1:8080 check weight 100
|
||||
server s2 10.0.0.2:8080 check weight 50
|
||||
cookie SRV insert indirect nocache # sticky
|
||||
```
|
||||
|
||||
### Envoy (L7, gRPC)
|
||||
```yaml
|
||||
clusters:
|
||||
- name: api
|
||||
type: STRICT_DNS
|
||||
lb_policy: LEAST_REQUEST
|
||||
health_checks:
|
||||
- timeout: 1s
|
||||
interval: 5s
|
||||
http_health_check: { path: "/health" }
|
||||
outlier_detection:
|
||||
consecutive_5xx: 5
|
||||
base_ejection_time: 30s
|
||||
load_assignment:
|
||||
cluster_name: api
|
||||
endpoints:
|
||||
- lb_endpoints:
|
||||
- endpoint: { address: { socket_address: { address: api1, port_value: 8080 }}}
|
||||
```
|
||||
|
||||
### AWS ALB (Terraform)
|
||||
```hcl
|
||||
resource "aws_lb" "app" {
|
||||
name = "app-alb"
|
||||
load_balancer_type = "application"
|
||||
subnets = var.public_subnets
|
||||
}
|
||||
resource "aws_lb_target_group" "api" {
|
||||
port = 8080
|
||||
protocol = "HTTP"
|
||||
health_check { path = "/health"; interval = 15 }
|
||||
stickiness { type = "lb_cookie"; enabled = true }
|
||||
}
|
||||
```
|
||||
|
||||
### Consistent hash (Python sketch)
|
||||
```python
|
||||
import bisect, hashlib
|
||||
class Ring:
|
||||
def __init__(self, nodes, vnodes=150):
|
||||
self.ring = []
|
||||
for n in nodes:
|
||||
for i in range(vnodes):
|
||||
h = int(hashlib.md5(f"{n}-{i}".encode()).hexdigest(), 16)
|
||||
bisect.insort(self.ring, (h, n))
|
||||
def get(self, key):
|
||||
h = int(hashlib.md5(key.encode()).hexdigest(), 16)
|
||||
i = bisect.bisect(self.ring, (h, ""))
|
||||
return self.ring[i % len(self.ring)][1]
|
||||
```
|
||||
|
||||
### P2C (power of two choices)
|
||||
```python
|
||||
import random
|
||||
def p2c(servers, load):
|
||||
a, b = random.sample(servers, 2)
|
||||
return a if load[a] <= load[b] else b
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | LB / 알고리즘 |
|
||||
|---|---|
|
||||
| AWS web app | ALB + round_robin |
|
||||
| TCP / 빠름 | NLB / HAProxy L4 |
|
||||
| gRPC, mesh | Envoy least_request |
|
||||
| Cache shard | Consistent hash |
|
||||
| DB connection pool | PgBouncer/ProxySQL |
|
||||
| Bare metal HTTP | Nginx least_conn |
|
||||
| 동질 서버 + short req | RR/Random |
|
||||
| 이질 서버 / long conn | Weighted least-conn |
|
||||
|
||||
**기본값**: HTTP는 ALB or Nginx least_conn. 마이크로서비스는 Envoy.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Distributed-Systems]]
|
||||
- 변형: [[Consistent-Hashing]], [[Reverse-Proxy]]
|
||||
- 응용: [[High-Availability]], [[Service Mesh]], [[CDN]]
|
||||
- Adjacent: [[API-Gateway]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: config 작성, 알고리즘 선택, troubleshoot 가설.
|
||||
**언제 X**: production tuning은 metric 기반 검증 필수.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- IP hash + NAT/CGNAT (모든 client가 한 노드)
|
||||
- Sticky session 과의존 → 노드 죽으면 세션 다 잃음
|
||||
- Health check 너무 짧은 interval → flapping
|
||||
- L7 LB에서 keepalive 비활성화 → 성능↓
|
||||
- Hash ring vnode 부족 → 불균형
|
||||
- TLS termination만 보고 backend mTLS 무시
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Nginx/Envoy/HAProxy docs, Mitzenmacher P2C, AWS ELB docs). 신뢰도 A.
|
||||
- 중복: 없음.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Envoy/AWS/consistent-hash 코드 추가 |
|
||||
Reference in New Issue
Block a user