Repository navigation
Open
Description
Problem
The Hive node pool sends each call to the fastest node that is not parked. A node's rate limit is per client IP, so the fastest node takes the whole stream, overruns its limit within seconds, answers 429 and gets parked. Then the next node gets everything.
Observed in production:
- A large share of node calls are answered 429, each one a wasted round trip that also delays the read.
- api.hive.blog is the fastest node and one of only two that serve
bridge.*_v2, yet it answers only a tiny share of calls. When its park ends it takes a burst of roughly 50 calls within seconds, then answers 429 and is parked again for 40 to 60s. It accepts a full burst again after each park, so its sustainable rate is well above what we get from it. - api.hive.blog sends no
Retry-After, so its park comes from our own 10/20/40/60s escalation.
There is also a small bug in NodeHealthTracker.RecordRateLimited: a 429 that carries Retry-After still advances the escalation streak. After a few of those, one header-less 429 jumps straight to a 40 or 60s park. The SDK's tracker only advances the streak on header-less 429s.
Proposal
Give each node a sending rate the process learns, and route within it.
- Learned rate per node (additive increase, multiplicative decrease):
- start at a moderate rate, for example 5 calls/s
- raise it slowly while calls succeed, for example +0.5/s per clean window
- halve it on a 429, and also park for
Retry-Afterwhen the 429 carries one - keep a floor so a node is never starved, and a ceiling
- Routing: among nodes with rate left, the fastest by the existing latency EWMA wins. If no node has rate left, wait briefly (short cap, for example 250ms) for the first one to free up; past the cap, send anyway as today.
- Heavy calls cost more: a
Heavycall class call counts as more than one unit against the rate. - Visible:
/ssr/statsshows each node's learned rate and current use, so the effective limit of every node can be read without load-testing anyone. - Bug fix: a 429 with
Retry-Afterno longer advances the escalation streak. - Several processes behind one IP share each node's limit. Additive increase with multiplicative decrease converges to a fair share without coordination, so no shared state is needed.
Acceptance tests
In EcencyApi.Tests (alongside HiveRpcFailoverTests.cs), with a fake clock and fake nodes:
- A node that allows N calls per second, faced with demand of 3N/s, settles at a learned rate between 0.7N and N, and the share of 429s after warm-up is under 5%. Today's routing gets well over 30% on the same scenario.
- Two nodes, the faster one limited: calls spill to the slower node once the faster one's rate is used, instead of the faster one being overrun and parked. The faster node serves continuously, never in burst-then-park cycles.
- A 429 halves that node's learned rate. Successes raise it back.
- A 429 with
Retry-After: 3parks for 3s and does not advance the escalation streak: a later header-less 429 parks for 10s, not 20s or more. (Fails today.) - When every node's rate is used, a call waits at most the cap and then still goes out.
- A
Heavycall uses more of the rate than aCheapone. /ssr/statsexposes the learned rate per node.
Out of scope
- Persisting learned rates across restarts (could follow if warm-up turns out to cost much).
- The SDK's own node routing, filed separately in ecency/vision-web.
- Adding or removing nodes from the pool.
Metadata
Metadata
Assignees
Labels
No labels
Activity
feruzm commentedon Nov 20, 2026
Two items in this issue are superseded by #129, on purpose:
limit_req, Caddy) count requests, not their cost. Weighting heavy calls would make the pool hold back below what a node actually allows.Retry-Afterstill advances the park ladder when it repeats with no answer in between. The first such 429 is honoured exactly. A node that keeps refusing every call while naming a short wait is refusing us, header or not. Without the ladder it was retried every second; with it, the park grows as for any other refusal.The acceptance test about the wait was also dropped: waiting for rate to come back made concurrent calls wake together, and most still found none, so the PR sends over the rate at once instead.