perf: Redis 操作优化,移除号池 key 列表的 Usage 聚合查询

- 号池 key 列表移除 Usage 表聚合查询(total_tokens/total_cost_usd),消除慢 SQL
- cooldown 计数从 SCAN 改为 SCARD (O(1)),通过 cooldown_idx SET 维护索引
- 读路径 Lua 脚本移除 ZREMRANGEBYSCORE,清理移至写路径减少开销
- affinity 清理从 KEYS 改为 SCAN 分批删除,invalidate_all_for_provider 改用 pipeline 批量 MGET+UNLINK
- 缓存监控页添加清除按钮 loading 状态,Redis SCAN 并发限制为 4
- 提取 redis_utils 模块统一 SCAN+批量删除逻辑
- 调度热路径跳过 cooldown TTL 查询,account_state 预计算移出循环
This commit is contained in:
fawney19
2026-03-09 14:54:45 +08:00
parent 9516619b92
commit afbb1b9a5d
11 changed files with 352 additions and 187 deletions

View File

@@ -125,8 +125,6 @@ export interface PoolKeyDetail {
cost_window_usage: number
cost_limit: number | null
request_count: number
total_tokens: number
total_cost_usd: number
sticky_sessions: number
lru_score: number | null
created_at: string | null