feat: As a user, I want new upstream peers in the EWMA balancer to be initialized with a warm score derived from existing peers, so that newly added pods receive a gradual traffic ramp-up
- Dominant language
- Lua
- Stars
- 17.1k
- Forks
- 2.9k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 63
Description
### Description
As an engineer running Apisix at high throughput, I want new upstream peers to be initialized with a meaningful EWMA score based on the current pool average, so that scale-out events are handled gracefully without overwhelming new pods before they are ready to serve traffic.
### Background
The current EWMA balancer initializes new peers with score = 0. Since the algorithm routes preferentially to lower-scored peers, this causes new pods to immediately absorb a disproportionate share of traffic. At low-to-moderate throughput, the score matures quickly and the impact is negligible. At high throughput, the burst during the warm-up window is large enough to crash the new pod before it stabilises .
Nginx's EWMA implementation avoids this by seeding new peers with the current mean score of active peers, ensuring proportional ramp-up from the moment a pod joins the pool.
### Proposed behavior
On peer registration, compute the mean EWMA score across all currently active peers in the upstream pool
Assign that mean as the initial score for the new peer Fall back to a configurable non-zero default when the pool is empty or no score history exists yet.
This enhancement has been validated in production via a local patch to
apisix/balancer/ewma.lua.
Happy to submit a PR with the implementation and benchmark data.
Contributor guide
Research direction
Start with apisix/balancer/ewma.lua and trace peer registration and score initialization. Confirm how active-peer scores and the empty-pool fallback should be handled, then validate the warm-up behavior with the benchmark data described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- backend-api-design, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100