Skip to main content
Version: 3.21.0

Configure Upstream Slow Start

New or restarted application instances can need time to warm caches or initialize connections before handling their normal share of traffic. Upstream slow start gradually increases a node's effective load-balancing weight after it is added or returns from observed unavailability, while existing nodes continue serving requests.

Slow start changes the distribution of traffic, not the total request rate. A single-node upstream still receives every request. If every available node is ramping, those nodes still handle all traffic between them.

Prerequisite(s)​

Start Sample Upstream Services​

Set GATEWAY_CONTAINER to your running APISIX container. Connect it and two echo servers to a dedicated network:

export GATEWAY_CONTAINER=replace-with-apisix-container-name
docker network create apisix-slow-start-net
docker network connect apisix-slow-start-net "$GATEWAY_CONTAINER"
docker run -d --name slow-start-existing --hostname existing \
--network apisix-slow-start-net jmalloc/echo-server:v0.3.7
docker run -d --name slow-start-new --hostname new \
--network apisix-slow-start-net jmalloc/echo-server:v0.3.7

The servers identify themselves in their responses. Both servers are running, but only the existing server will initially belong to the upstream.

Create an Upstream and Route​

Create an upstream with one node and a 60-second warm-up window:

curl "http://127.0.0.1:9180/apisix/admin/upstreams/slow-start" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-d '{
"type": "roundrobin",
"nodes": {
"slow-start-existing:8080": 100
},
"warm_up_conf": {
"slow_start_time_seconds": 60,
"min_weight_percent": 10
}
}'

Create a route referencing that upstream:

curl "http://127.0.0.1:9180/apisix/admin/routes/slow-start" -X PUT \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-d '{
"uri": "/slow-start",
"upstream_id": "slow-start"
}'

Before adding the second node, send a request and confirm that the response identifies existing:

curl "http://127.0.0.1:9080/slow-start"

Send this request before adding the second node so APISIX records the existing node as already warmed. If you configure both nodes before the first request, APISIX treats both as initial members and does not ramp one relative to the other.

APISIX keeps slow-start lifecycle state in the upstream-slow-start shared-memory dictionary, including across graceful reloads. To repeat this walkthrough and observe a fresh ramp, create a new upstream and route with new IDs and a new request path. Alternatively, fully restart the APISIX container before recreating the resources. Reapplying the same IDs immediately may reuse the previous node state.

Add a Node and Observe Slow Start​

Add the second node with the same configured weight. PATCH merges this node into the existing nodes map:

curl "http://127.0.0.1:9180/apisix/admin/upstreams/slow-start" -X PATCH \
-H "X-API-KEY: ${ADMIN_API_KEY}" \
-d '{
"nodes": {
"slow-start-new:8080": 100
}
}'

Send batches of requests over the next minute and count the responses from each server. A batch provides enough samples to make the changing traffic share visible:

for elapsed in $(seq 0 10 60); do
echo "After ${elapsed} seconds:"
seq 1 100 | xargs -P 20 -I {} \
curl -sS "http://127.0.0.1:9080/slow-start" | \
grep -o 'Request served by [^[:space:]]*' | sort | uniq -c
[ "$elapsed" -lt 60 ] && sleep 10
done

The new node starts at an effective weight of 10 compared with the existing node's weight of 100. Its share grows toward half the requests as its weight reaches 100. Exact counts vary because configuration updates and requests are distributed across gateway workers. The minimum percentage is a percentage of the node's configured weight, not of all traffic.

Tune Slow Start​

Configure these fields in the warm_up_conf object of the upstream:

FieldRequiredDefaultValid valuesDescription
slow_start_time_secondsYesN/AInteger greater than or equal to 1Seconds for a newly available node to reach its configured weight.
min_weight_percentYesN/AInteger from 1 through 100Minimum percentage of the configured node weight.
intervalNo1Integer from 1 through slow_start_time_secondsSeconds between effective weight refreshes.
aggressionNo1Number greater than or equal to 0.01Ramp shape. 1 is linear, values above 1 increase weight faster initially, and values below 1 increase it more slowly.
startup_grace_period_secondsNo0Integer greater than or equal to 0Seconds after the gateway starts during which newly observed nodes are treated as already warmed.

Weights are integers and a positive node weight never falls below 1. Use sufficiently large configured weights when you need a gradual ramp: a node with weight 1 cannot have its weight reduced further.

Slow start applies to HTTP upstreams using weighted round robin with a single node priority. Other load-balancing algorithms, stream routes, and mixed node priorities do not support it. Inline upstreams in the traffic-split plugin reject slow-start configuration.

Each APISIX instance tracks node lifecycle independently. Existing nodes are treated as warmed when slow start is first enabled, and a newly added node begins its ramp when it first becomes eligible. Once an instance observes a node unavailable, either because health checks exclude it or because it is removed from the upstream, the node's mature or ramping state ends. When the node becomes available again, it begins a new ramp from min_weight_percent, regardless of the interruption length. Changing a node's weight, including setting it to 0, does not count as unavailability. Slow start does not replace readiness checks.

Node Removal and Return Behavior​

Slow start identifies a node by hostname or address and port within its upstream scope. Replacing an application process at the same address does not automatically create a new identity. A new ramp begins only after APISIX observes the node become unavailable and then available again. Both removal from the configured node set and exclusion by health checks count as unavailability.

The following table summarizes the behavior for the 60-second window configured above:

Action observed by the gatewayExpected result
Add the new node after the first baseline requestIts weight ramps from 10 to 100 over 60 seconds.
Let it become mature, remove it, and return itIt begins a new ramp from 10, regardless of how long it was absent.
Remove it while it is ramping and then return itThe original ramp ends and a new 60-second ramp begins from 10.
Let health checks exclude it and then mark it healthyIt begins a new ramp from 10.
Change its configured weight, including to 0The weight changes without resetting its slow-start lifecycle.

Send traffic after each node-list change and check configuration propagation before timing the absence. If a remove-and-add happens before the gateway observes the removal, it may see no lifecycle change. Measure per-node traffic over batches as above, not from one response.

An observed unavailability always ends the current slow-start lifecycle. slow_start_time_seconds controls the duration of the new ramp after the node returns; it is not a state-retention window.

The first reconciliation of a new upstream scope treats existing nodes as mature. Deleting and recreating an upstream, changing its ID, or restarting the gateway therefore does not guarantee a warm-up ramp. Establish the baseline first, then add the new node. A nonzero startup_grace_period_seconds treats only nodes observed for the first time during that gateway startup interval as mature. A previously observed node that becomes unavailable and returns during the interval still begins a new ramp. A graceful reload retains shared-memory state; a full restart does not.

Next Steps​

Combine slow start with upstream health checks so newly deployed nodes receive traffic only when they can serve it. See the Admin API reference for upstreams for the complete configuration schema.