<< All versions
Skill v1.0.0
currentLLM-judged scan90/100tspry/superpowers-devops/load-balancing
──Details
PublishedOctober 21, 2026 at 11:37 AM
Content Hashsha256:96a632c243e73396...
Git SHA8cbe4e9399c1
──Files
Files (1 file, 2.9 KB)
SKILL.md2.9 KBactive
SKILL.md · 91 lines · 2.9 KB
version: "1.0.0" name: load-balancing description: Use when working with load balancer configuration, upstream health checks, or traffic distribution
Load Balancing
Mode Detection
- Repo mode — inspect existing load balancer configs and generate changes for the installed platform. Check
tooling/README.md; load balancer templates are not bundled. - Chat mode — user pastes config or describes traffic issue. Diagnose and provide corrected config.
Core Concepts
| Algorithm | When to use | |
|---|---|---|
| Round robin | Stateless services, equal capacity upstreams | |
| Least connections | Long-lived connections, variable request duration | |
| IP hash | Session affinity needed (sticky sessions) | |
| Weighted | Upstreams with different capacities |
Nginx Upstream Config
nginx
upstream myapp {least_conn;server 10.0.0.1:3000 weight=3;server 10.0.0.2:3000 weight=1;server 10.0.0.3:3000 backup; # only used if others failkeepalive 32; # reuse upstream connections}server {location / {proxy_pass http://myapp;proxy_next_upstream error timeout http_502 http_503;proxy_connect_timeout 5s;proxy_read_timeout 60s;}}
The timeout and retry values above are examples, not universal defaults. Align connect, queue, application, dependency, and response-read deadlines to an explicit end-to-end latency budget. Before increasing a timeout or retrying non-idempotent requests, identify the failed phase and evaluate extra concurrency, duplicate side effects, retry amplification, and rollback.
Health Checks
Passive (Nginx default): marks upstream as failed after N consecutive errors.
nginx
upstream myapp {server 10.0.0.1:3000 max_fails=3 fail_timeout=30s;}
Active (Nginx Plus / OpenResty): proactively polls upstream health endpoint.
Kubernetes readinessProbe:
yaml
readinessProbe:httpGet:path: /healthport: 3000initialDelaySeconds: 5periodSeconds: 10failureThreshold: 3
Debugging Traffic Distribution
bash
# Check Nginx upstream status (if status module enabled)curl http://localhost/nginx_status# Watch access logs to verify distributiontail -f /var/log/nginx/access.log | awk '{print $7}'# Test upstream directlycurl -v http://10.0.0.1:3000/healthcurl -v http://10.0.0.2:3000/health
Common Issues
| Symptom | Cause | Fix | |
|---|---|---|---|
| All traffic to one upstream | Sticky sessions / IP hash | Check algorithm config | |
| Upstream marked down incorrectly | Health evidence or thresholds do not match failure behavior | Compare probe results with request traces before changing fail_timeout | |
| 502 during deploy | Connection lifecycle, readiness, or termination sequencing | Verify drain/readiness behavior; retry only eligible idempotent requests within a bounded budget | |
| Uneven distribution | Weight mismatch or keepalive skewing | Review weights and keepalive settings |