Upstreams & Targets
Upstreams are backend server pools. Targets are individual servers within an upstream.
Upstream Structure
Section titled “Upstream Structure”interface Upstream { id: string; name: string; algorithm?: string; // Load balancing algorithm hashOn?: string; // Hash input for hash algorithm slots?: number; // Consistent hash slots healthcheck?: object; // Health check config tags?: string[];}Target Structure
Section titled “Target Structure”interface Target { id: string; upstreamId: string; target: string; // URL or IP:port weight?: number; // Weight for weighted algorithms tags?: string[];}Creating Upstreams
Section titled “Creating Upstreams”Load Balancing Algorithms
Section titled “Load Balancing Algorithms”Target Weight
Section titled “Target Weight”Distribute requests proportionally:
// Targets with weights{ "target": "server-a", "weight": 3 }{ "target": "server-b", "weight": 1 }Distribution: A receives 75% of requests, B receives 25%.
Managing Upstreams
Section titled “Managing Upstreams”List Upstreams
Section titled “List Upstreams”curl http://localhost:8080/api/upstreamsGet Upstream Details
Section titled “Get Upstream Details”curl http://localhost:8080/api/upstreams/upstream_abc123Update Algorithm
Section titled “Update Algorithm”curl -X PATCH http://localhost:8080/api/upstreams/upstream_abc123 \ -H "Content-Type: application/json" \ -d '{ "algorithm": "least-connections" }'Delete Upstream
Section titled “Delete Upstream”curl -X DELETE http://localhost:8080/api/upstreams/upstream_abc123Managing Targets
Section titled “Managing Targets”List Targets for Upstream
Section titled “List Targets for Upstream”curl http://localhost:8080/api/targets?upstreamId=upstream_abc123Update Target Weight
Section titled “Update Target Weight”curl -X PATCH http://localhost:8080/api/targets/target_xyz789 \ -H "Content-Type: application/json" \ -d '{ "weight": 5 }'Remove Target
Section titled “Remove Target”curl -X DELETE http://localhost:8080/api/targets/target_xyz789Target URLs
Section titled “Target URLs”Targets can use various formats:
Connecting Routes to Upstreams
Section titled “Connecting Routes to Upstreams”Routes reference upstreams through service configuration:
- Create route pointing to service
- Service defines upstream connection
- Upstream provides targets
Next Steps
Section titled “Next Steps”- Load Balancing - Algorithm details
- Routes - Route to upstreams
- Services - Service configuration