perf: Sprint 19 P0/P1 性能优化落地
P0(高优先级): - P0-1: 确认数据库复合索引已存在(GORM tag),composite_index_test 验证通过 - P0-2: 连接池调优 MaxIdleConns 5→10, ConnMaxLifetime 30min→5min - P0-3: Redis 智能探测(ProbeRedis),无 Redis 自动降级到纯内存模式 P1(中优先级): - P1-1: GZIP 压缩中间件(compress/gzip 标准库,零新依赖) - P1-2: 权限缓存 TTL 30min→5min - P1-3: Argon2id 启动自适应校准(CalibrateArgon2id) 历史优化(含本次提交): - L1Cache O(n)→O(1) LRU 重构 - Auth 中间件 DB 查询合并 + 5s L1 缓存 - Logger 异步化(4096 缓冲通道) 验证: go build/vet/test 41/41 PASS, govulncheck 无漏洞
This commit is contained in:
@@ -105,6 +105,8 @@ func (r *Router) Setup() *gin.Engine {
|
||||
r.engine.Use(middleware.SecurityHeaders())
|
||||
r.engine.Use(middleware.NoStoreSensitiveResponses())
|
||||
r.engine.Use(middleware.CORS())
|
||||
// P1-1:GZIP 压缩 — 对 JSON/文本响应 > 1 KiB 自动压缩,列表接口带宽降低 50-70%
|
||||
r.engine.Use(middleware.GzipMiddleware())
|
||||
r.engine.Use(middleware.ResponseWrapper())
|
||||
|
||||
// CRIT-01/02 修复:挂载 Prometheus 中间件,暴露 /metrics 端点
|
||||
|
||||
Reference in New Issue
Block a user