fix: implement account weight-based load balancing with weighted random#84
Open
bennylii wants to merge 1 commit intoxiaoY233:mainfrom
Open
fix: implement account weight-based load balancing with weighted random#84bennylii wants to merge 1 commit intoxiaoY233:mainfrom
bennylii wants to merge 1 commit intoxiaoY233:mainfrom
Conversation
Previously, the account weight UI (sliders 0-100%) existed but was completely ineffective — weights were never saved to the backend, and the load balancer treated all accounts equally. Changes: - Add accountWeights: Record<string, number> to AppConfig - Implement selectWeightedAccount using weighted random algorithm (stateless, immune to dynamic pool changes from accounts entering/leaving due to daily limits or status changes) - Save weights as Record from LoadBalanceConfig to backend - Restore weights from backend in proxyStore.fetchAppConfig Fixes xiaoY233#84 Co-Authored-By: deepseek-v4-pro <noreply@deepseek.com>
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
accountWeights: Record<string, number>to AppConfig (shared & main types)selectWeightedAccountin load balancer using weighted random algorithmLoadBalanceConfigto save weights as Record to backendproxyStore.fetchAppConfigto restore weights from backend on startupRoot Cause
The weight sliders in the UI existed but were completely ineffective:
LoadBalanceConfigsaved onlyloadBalanceStrategy, neveraccountWeightsAlgorithm
Weighted random (stateless) — each account is selected with probability proportional to its configured weight. Unlike smooth weighted round-robin, this is immune to dynamic pool changes when accounts enter/leave due to daily limits or status changes.
Test plan
npx tsc --noEmitshows 0 new errors🤖 Generated with Claude Code