Advanced Load Balancing
Distribute traffic across multiple origin servers using configurable algorithms, session affinity, and weighted routing.
Algorithms
| Algorithm | Description | Best For |
|---|---|---|
| round_robin | Rotate through origins sequentially | Stateless services with uniform load |
| weighted_round_robin | Rotate proportionally to configured weights | Gradual traffic migration / canary deploys |
| least_connections | Route to origin with fewest active connections | Long-lived connections (WebSockets, SSE) |
| ip_hash | Hash client IP to deterministic origin | Sticky sessions without cookies |
Dashboard Setup & Configuration
You can configure and manage origins and load balancing pools directly in the EdgeWrap Dashboard:
- Navigate to your project in the dashboard at
https://app.edgewrap.pro. - Go to the Origins page under the project settings to add and manage your server origin endpoints (defining names, URLs, and active health check paths/times).
- Go to the Load Balancer page in the sidebar.
- Click the Create Pool button.
- Select the balancing algorithm (such as Weighted Round Robin).
- Toggle Session Affinity to pin users to the same server using cookies, and define custom cookie parameters.
- Map your configured origins to the pool, specifying the target distribution weights.
- Click Save Pool to begin routing traffic.
API Configuration
Alternatively, you can manage your load balancing pools programmatically:
| Param | Type | Description |
|---|---|---|
| name | string | Pool display name (1–100 chars) |
| algorithm | enum | round_robin | weighted_round_robin | least_connections | ip_hash |
| sessionAffinityEnabled | boolean | Enable sticky cookie affinity(default: false) |
| stickyCookieName | string | Cookie name for session affinity |
| stickyCookieTtlSec | integer | Cookie TTL in seconds |
| origins | { originId, weight }[] | Origins to include with weights (1–1000) |
Create a weighted load balancer pool via API
curl -X POST https://server.edgewrap.pro/v1/projects/prj_abc123/load-balancer/pools \
-H "Authorization: Bearer <your_session_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Pool",
"algorithm": "weighted_round_robin",
"sessionAffinityEnabled": true,
"stickyCookieName": "ew_sticky",
"stickyCookieTtlSec": 3600,
"origins": [
{ "originId": "orig_us_east", "weight": 70 },
{ "originId": "orig_us_west", "weight": 20 },
{ "originId": "orig_eu_central", "weight": 10 }
]
}'Tip: To implement a canary deploy, set your new origin to a low weight (e.g. 5) and gradually increase it while monitoring error rates in the analytics dashboard.
Session Affinity
When session affinity is enabled, EdgeWrap sets a cookie containing an encoded origin ID on the first response. Subsequent requests with that cookie are pinned to the same origin server for the cookie duration.
Session affinity response headers
HTTP/1.1 200 OK
Set-Cookie: ew_sticky=orig_us_east; Max-Age=3600; HttpOnly; SameSite=LaxAdding Origins via API
Origins must first be added to the project before they can be referenced in a load balancer pool.
Add an origin via API
curl -X POST https://server.edgewrap.pro/v1/projects/prj_abc123/origins \
-H "Authorization: Bearer <your_session_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "US East",
"url": "https://us-east.api.mycompany.com",
"isPrimary": false,
"healthCheckPath": "/health"
}'Origin Plan Limits
| Plan | Origins / Project |
|---|---|
| Free | 2 |
| Starter | 5 |
| Pro | 10 |
| Team | 25 |
| Enterprise | 999 |