<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
tspry/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

AlgorithmWhen to use
Round robinStateless services, equal capacity upstreams
Least connectionsLong-lived connections, variable request duration
IP hashSession affinity needed (sticky sessions)
WeightedUpstreams 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 fail
keepalive 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: /health
port: 3000
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3

Debugging Traffic Distribution

bash
# Check Nginx upstream status (if status module enabled)
curl http://localhost/nginx_status
# Watch access logs to verify distribution
tail -f /var/log/nginx/access.log | awk '{print $7}'
# Test upstream directly
curl -v http://10.0.0.1:3000/health
curl -v http://10.0.0.2:3000/health

Common Issues

SymptomCauseFix
All traffic to one upstreamSticky sessions / IP hashCheck algorithm config
Upstream marked down incorrectlyHealth evidence or thresholds do not match failure behaviorCompare probe results with request traces before changing fail_timeout
502 during deployConnection lifecycle, readiness, or termination sequencingVerify drain/readiness behavior; retry only eligible idempotent requests within a bounded budget
Uneven distributionWeight mismatch or keepalive skewingReview weights and keepalive settings
All versions