perf: improve worker and storage throughput
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
237899745
2026-07-26 00:57:29 +08:00
parent da9b273253
commit de5f451cd1
14 changed files with 611 additions and 101 deletions

View File

@@ -276,7 +276,8 @@ dotenvy = "0.15"
### 1. 并发处理
- 使用 Tokio 异步运行时
- 图片压缩使用 `spawn_blocking` 避免阻塞异步线程
- 可配置 Worker 线程数
- `WORKER_TASK_CONCURRENCY` 控制任务级并发,避免大批量任务独占 Worker
- `WORKER_CONCURRENCY` 控制单任务内文件并发,`IMAGE_PROCESSING_CONCURRENCY` 作为进程级 CPU 闸门
```rust
// 在独立线程池中执行 CPU 密集型压缩
@@ -292,6 +293,7 @@ let result = tokio::task::spawn_blocking(move || {
### 3. 缓存策略
- Redis 缓存用户会话
- S3 活动端点与历史端点缓存 5 秒AWS SDK Client 按端点和内外网地址复用连接池
- 可选:相同图片哈希缓存结果(去重)
## 安全考虑