Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Clusters & Endpoints

A cluster is a logical group of upstream backend endpoints that share a load balancing policy, circuit breaker, and connection pool.

[[clusters]]
name = "api-backend"
lb_policy = "round_robin"
connect_timeout_ms = 5000
max_idle_connections = 8
endpoints = [
  { address = "10.0.1.1:8080", weight = 1 },
  { address = "10.0.1.2:8080", weight = 2 },
  { address = "10.0.1.3:8080", weight = 1 },
]

Fields

FieldTypeRequiredDefaultDescription
namestringyesUnique cluster name
lb_policystringyesLoad balancing algorithm
connect_timeout_msintegeryesUpstream TCP connect timeout
max_idle_connectionsintegerno8Max idle pooled connections per endpoint
endpointsarrayyesList of backend endpoints
circuit_breakertablenosee belowCircuit breaker limits
health_checktablenononeActive health check config

Load Balancing Policies

PolicyDescription
round_robinCycles through healthy endpoints sequentially
least_requestPower-of-two-choices: picks the endpoint with fewer active requests
maglevConsistent hashing for sticky sessions (minimal disruption on changes)
randomRandom selection among healthy endpoints

Endpoint Weights

Endpoints with higher weights receive proportionally more traffic. A weight of 2 receives roughly twice the traffic of weight 1.

Circuit Breaker

[clusters.circuit_breaker]
max_connections = 1024
max_pending_requests = 1024
max_requests = 1024

When limits are exceeded, the proxy returns 503 Service Unavailable instead of overloading the backend. Circuit breaker state is managed via RAII guards — the slot is automatically released when the request completes or the connection drops.

Connection Pooling

Meridian maintains a pool of idle TCP connections to each endpoint. When a new request arrives, it checks out a pooled connection instead of performing a TCP handshake. Connections are returned to the pool after use if the upstream supports keep-alive.

  • Max idle per endpoint: configurable (default 8)
  • Max connection age: 90 seconds (expired connections are evicted)
  • LIFO ordering: most recently returned connection is reused first (warmest cache)