Fix cascading 503 on cold-cache tile loading#210
Merged
Conversation
Two-part fix for tiles graying out instead of progressively loading: 1. Client-side: Add concurrency pool (6 slots) to retryTileLayer.js. Prevents thundering herd where ~35 tiles blast the server simultaneously, overwhelming both per-IP and global outbound budgets. 2. Server-side: Two-phase per-IP outbound budget in SendTileRequestCoreAsync. Previously, IsRateLimitExceeded incremented the per-IP counter on every request, even those rejected by the global budget. This caused retries to find the counter already past the limit and fail immediately (cascading 503). Now uses WouldExceedRateLimit (peek, no increment) for fast-fail, then RecordRateLimitHit only after global budget is acquired.
Two-part fix for tiles graying out instead of progressively loading: 1. Client-side (retryTileLayer.js): Add concurrency pool (6 slots). Prevents thundering herd where ~35 tiles blast the server simultaneously, overwhelming both per-IP and global outbound budgets. 2. Server-side (TileCacheService/RateLimitHelper): Two-phase per-IP budget. Previously, IsRateLimitExceeded incremented the per-IP counter on every request, even those rejected by the global budget. This caused retries to find the counter already past the limit and fail immediately (cascading 503). Now uses WouldExceedRateLimit (peek without increment) for fast-fail, then RecordRateLimitHit only after global budget is acquired — so only actual upstream fetches count against the per-IP limit. Closes #206
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
retryTileLayer.js— tiles queue and stream in progressively instead of blasting ~35 simultaneous requests that overwhelm server budgetsIsRateLimitExceededincremented on every request (including rejected ones), causing retries to snowball past the limit → cascading 503 → all tiles gray out permanentlyWouldExceedRateLimit(peek),RecordRateLimitHit(increment), andPeekCounttoRateLimitHelperfor the check-then-record patternCloses #206
Test plan
dotnet buildpasses (0 errors)dotnet testpasses (1407 tests)code-reviewersubagent (passed)