feat: add reserved_concurrency for sticky session slot reservation#607
Open
wangxiaobo775 wants to merge 1 commit intoWei-Shaw:mainfrom
Open
feat: add reserved_concurrency for sticky session slot reservation#607wangxiaobo775 wants to merge 1 commit intoWei-Shaw:mainfrom
wangxiaobo775 wants to merge 1 commit intoWei-Shaw:mainfrom
Conversation
为已绑定 sticky session 的请求预留专属并发槽位,防止高并发下 被新 session 请求挤占,保障会话连续性。 核心机制: - 已绑定 session 请求可使用全部 concurrency 个槽位 - 新 session 请求只能使用 concurrency - reserved_concurrency 个 - 默认值 0,完全向后兼容
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
Add a
reserved_concurrencyfield to Account, allowing operators to reserve dedicated concurrency slots for bound (sticky) sessions. This prevents new session requests from crowding out existing sessions under high concurrency, preserving session continuity.Core Mechanism
concurrencyslotsconcurrency - reserved_concurrencyslots0: fully backward compatible — no behavioral change unless explicitly configuredChanges
Database
058_add_account_reserved_concurrency.sqlBackend
reserved_concurrencyinteger field (default 0)Account.EffectiveConcurrency(isBound bool) intmethod on service modeltryAcquireAccountSlotcall sites ingateway_service.goandopenai_gateway_service.gonow useEffectiveConcurrency(isBound)instead of rawConcurrencyWaitPlan.MaxConcurrencyandAccountWithConcurrency.MaxConcurrencyupdated accordinglyEffectiveConcurrency(false) == 0, new session requests skip the account entirelymaxConcurrency == 0short-circuit intryAcquireAccountSlotto avoid unnecessary Redis callsFrontend
Edge Cases
reserved_concurrency = 0reserved_concurrency >= concurrencyreserved_concurrency < 0concurrency <= 0Test Plan
concurrency=5, reserved_concurrency=2→ verify new sessions limited to 3 concurrentreserved_concurrency=0has no behavioral changereserved_concurrency >= concurrencyblocks new sessions entirely