Advanced Load Balancing

Distribute traffic across multiple origin servers using configurable algorithms, session affinity, and weighted routing.

Algorithms

AlgorithmDescriptionBest For
round_robinRotate through origins sequentiallyStateless services with uniform load
weighted_round_robinRotate proportionally to configured weightsGradual traffic migration / canary deploys
least_connectionsRoute to origin with fewest active connectionsLong-lived connections (WebSockets, SSE)
ip_hashHash client IP to deterministic originSticky sessions without cookies

Dashboard Setup & Configuration

You can configure and manage origins and load balancing pools directly in the EdgeWrap Dashboard:

  1. Navigate to your project in the dashboard at https://app.edgewrap.pro.
  2. 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).
  3. Go to the Load Balancer page in the sidebar.
  4. Click the Create Pool button.
  5. Select the balancing algorithm (such as Weighted Round Robin).
  6. Toggle Session Affinity to pin users to the same server using cookies, and define custom cookie parameters.
  7. Map your configured origins to the pool, specifying the target distribution weights.
  8. Click Save Pool to begin routing traffic.

API Configuration

Alternatively, you can manage your load balancing pools programmatically:

ParamTypeDescription
namestringPool display name (1–100 chars)
algorithmenumround_robin | weighted_round_robin | least_connections | ip_hash
sessionAffinityEnabledbooleanEnable sticky cookie affinity(default: false)
stickyCookieNamestringCookie name for session affinity
stickyCookieTtlSecintegerCookie 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=Lax

Adding 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

PlanOrigins / Project
Free2
Starter5
Pro10
Team25
Enterprise999