Files
iotlcm/deploy/compose.memlimit.yml
MiFaZhan e98f8561f7
mirror-to-gitee / mirror (push) Successful in 9s
fix(deploy): nginx 上游运行期重新解析 + 就绪探针;内存上限按 8C/32G 重新分配
问题:容器重建换 IP 后,网关与 admin-ui 仍往旧 IP 打,/openapi 与 /api
整片 502,必须手动重启 nginx 容器才恢复(2026-11-03 实机踩到)。

编排
- admin-svr / openapi / admin-ui / docs 增加 healthcheck
- admin-ui、gateway、nginx 改 depends_on: condition: service_healthy,
  保证 nginx 启动时后端已就绪
- 新增 deploy/compose.memlimit.yml(原来只存在于某台演示机上):
  全套上限 8.5G、实测常驻 2G,留给同机其它服务 20G+;
  MySQL buffer pool 128M→768M、max_connections 151→300

nginx
- gateway / admin-ui / iotlcm.conf 示例 统一改 resolver 127.0.0.11 valid=10s
  + upstream zone/resolve:运行期跟随 IP 变化,不必重启(实测 6s 内自愈)
2026-11-03 10:40:48 +08:00

176 lines
3.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# iotlcm 内存上限 override —— 8 vCPU / 32 GB 宿主机,与其他服务共用
#
# 定位:这台机器是「一机多环境」,iotlcm 只是其中一个占用方。
# 所以只给全套 20 个服务留 **约 8.5 GB 上限**(实测常驻约 2 GB),
# 剩余 20+ GB 留给宿主机上要新增的其它服务。
#
# 没有本文件会怎样:编排里没有内存限制,任何一个服务泄漏/跑批都会
# 把整机内存吃到 OOM Killer 随机杀进程(表现为容器反复 Restarting
# 且日志里看不到业务异常,只能 dmesg 里看到 oom-kill)。
#
# 用法(顺序不能反):
# docker compose -f docker-compose.yml -f compose.memlimit.yml up -d
#
# 只调 resources(+ MySQL 自身缓存参数),不动镜像、端口、卷、依赖。
# 换成更小的机器(4 GB)时按比例下调:mysql 1024M / tdengine 512M /
# worker-svr 768M / 其余 320M;8 GB 机器可用 1024M / 768M / 512M。
# ============================================================
services:
# ---------- 基础组件 ----------
mysql:
# buffer pool 由 128M(默认)提到 768M,连接数 151 → 300
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_general_ci
- --default-time-zone=+08:00
- --innodb-buffer-pool-size=768M
- --max-connections=300
deploy:
resources:
limits:
memory: 2048M
reservations:
memory: 768M
redis:
deploy:
resources:
limits:
memory: 384M
reservations:
memory: 96M
rabbitmq:
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 192M
tdengine:
deploy:
resources:
limits:
memory: 1024M
reservations:
memory: 256M
# 一次性建表任务,跑完即退出
tdengine-init:
deploy:
resources:
limits:
memory: 128M
# 单节点 consul 常驻约 110~120 MB,给足余量避免贴边
consul:
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 96M
# ---------- 业务服务 ----------
admin-svr:
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
admin-ui:
deploy:
resources:
limits:
memory: 64M
openapi:
deploy:
resources:
limits:
memory: 384M
reservations:
memory: 128M
upstream-chan:
deploy:
resources:
limits:
memory: 384M
reservations:
memory: 128M
upstream-proxy:
deploy:
resources:
limits:
memory: 384M
reservations:
memory: 128M
# 全量同步(流量/状态/IMEI)时内存抬升最明显,按文档「500 MB ~ 1 GB」给 1 GB
worker-svr:
deploy:
resources:
limits:
memory: 1024M
reservations:
memory: 256M
app-server:
deploy:
resources:
limits:
memory: 512M
reservations:
memory: 128M
app-web:
deploy:
resources:
limits:
memory: 64M
sms:
deploy:
resources:
limits:
memory: 192M
docs:
deploy:
resources:
limits:
memory: 64M
# ---------- profile 可选服务 ----------
bot:
deploy:
resources:
limits:
memory: 192M
onelink-mock:
deploy:
resources:
limits:
memory: 192M
nginx:
deploy:
resources:
limits:
memory: 128M
# 单端口入口(with-gateway);之前没有任何上限
gateway:
deploy:
resources:
limits:
memory: 256M