부하 분산
How P2C + EWMA 작동합니다
섹션 제목: “How P2C + EWMA 작동합니다”flowchart LR
Client --> P2C
subgraph "P2C Algorithm"
P2C["Pick 2 random
candidates"] --> Compare["Compare EWMA
load scores"]
Compare --> Winner["Route to lower-load
instance"]
end
Winner --> A["Instance A :8081
EWMA=0.3"]
Winner --> B["Instance B :8082
EWMA=0.8"]
Winner --> C["Instance C :8083
EWMA=0.5"]
- 이 항목은 해당 기능의 사용 방법, 설정, 주의 사항을 설명합니다.
- Compare their EWMA (Exponentially Weighted Moving Average) 부하 score.
- 라우트 Request 로 lower-load instance.
- 후에 응답, 업데이트 EWMA 사용하여 actual round-trip time.
Why better than round-robin?
- Round-robin distributes 요청, 아님 부하. 느린 instances pile up.
- P2C 라우트 away 에서 느린 instances 자동으로, 없이 전역 coordination.
자동 Activation
섹션 제목: “자동 Activation”OrderRpc: Etcd: Hosts: - 127.0.0.1:2379 Key: order.rpcStatic 엔드포인트 (Dev / 테스트)
섹션 제목: “Static 엔드포인트 (Dev / 테스트)”OrderRpc: Endpoints: - 127.0.0.1:8080 - 127.0.0.1:8081 - 127.0.0.1:8082Direct 연결 (Single Instance)
섹션 제목: “Direct 연결 (Single Instance)”OrderRpc: Target: "direct://127.0.0.1:8080"Kubernetes DNS
섹션 제목: “Kubernetes DNS”OrderRpc: Target: "k8s:// 예시입니다Observing Balancer
섹션 제목: “Observing Balancer”Prometheus: Host: 0.0.0.0 Port: 9101 Path: /metricsKey 메트릭:
| Metric | 설명 |
|---|---|
rpc_client_requests_total{target="..."} | Request count 별 upstream instance |
rpc_client_duration_ms_bucket{target="..."} | Latency histogram 별 instance |
타임아웃과 Keep-alive
섹션 제목: “타임아웃과 Keep-alive”OrderRpc: Etcd: Hosts: [127.0.0.1:2379] Key: order.rpc Timeout: 2000 # 예시입니다 KeepaliveTime: 20000 # 예시입니다