perf(deploy): 边缘 nginx 承压调优与连接池/PG 参数(P0-2/P0-3)

- 主配置 nginx.conf 进镜像(worker_connections 16384 + rlimit 65536 + gzip
  + 带上游耗时的访问日志):官方默认 1024×4=4096 连接硬顶是 1w 并发第一道墙
- admin.conf:upstream keepalive 64(proxy_http 1.1 + Connection "")、
  /public/ /v2-api/ 限流 50r/s burst 200(429)、代理超时 5s/30s、
  /uploads/ /assets/ 30d 缓存头;admin.v2.conf 的 /v2/h5/ 哈希产物长缓存
- compose:PG 显式参数(statement_timeout=10s/max_connections=200/
  shared_buffers=512MB)、DATABASE_URL connection_limit=50&pool_timeout=3
  (单位秒,勿写毫秒;勿加 statement_cache_size=0)、admin ulimits nofile 65536
- 部署注意:主配置走镜像须 rebuild;PG 参数重启前按全局约束 pg_dump+快照存档
This commit is contained in:
yeuimu
2026-09-03 03:40:28 +08:00
parent ab79325ab0
commit 9f856858e2
5 changed files with 114 additions and 7 deletions
+6
View File
@@ -25,8 +25,14 @@ server {
add_header Cache-Control "no-cache";
}
# v2 版 H5(构建时 router.base 必须为 /v2/h5/,产物放 /usr/share/nginx/html/v2/h5
# 性能整改 P0-2:哈希文件名的构建产物长缓存,index.html 永远 no-cache(上面精确匹配优先)
location /v2/h5/ {
try_files $uri $uri/ /v2/h5/index.html;
location ~* ^/v2/h5/(static|assets|img|fonts?)/ {
expires 30d;
add_header Cache-Control "public";
}
}
location / {