perf(cmpp): add durable inbound fast path

This commit is contained in:
hectorzhao
2026-08-20 17:34:45 +08:00
parent 26ef67fb6a
commit 0b63bcd74e
29 changed files with 1136 additions and 87 deletions
+43 -3
View File
@@ -29,6 +29,16 @@ if [[ ! "${API_SEND_WORKER_CONCURRENCY:-}" =~ ^[1-9][0-9]*$ ]]; then
exit 1
fi
if [[ "${CMPP_INBOUND_FAST_PATH_ENABLED:-}" != "true" || "${CMPP_INBOUND_WORKFLOW_WORKER_ENABLED:-}" != "true" ]]; then
echo "CMPP_INBOUND_FAST_PATH_ENABLED=true and CMPP_INBOUND_WORKFLOW_WORKER_ENABLED=true are required in $ENV_FILE." >&2
exit 1
fi
if [[ ! "${API_INBOUND_WORKFLOW_CONCURRENCY:-}" =~ ^[1-9][0-9]*$ ]]; then
echo "API_INBOUND_WORKFLOW_CONCURRENCY must be a positive integer in $ENV_FILE." >&2
exit 1
fi
if [[ -z "${CMPP_PUBLIC_HOST:-}" || ! "${CMPP_PUBLIC_PORT:-}" =~ ^[1-9][0-9]*$ ]]; then
echo "CMPP_PUBLIC_HOST and a positive CMPP_PUBLIC_PORT are required in $ENV_FILE; these are the customer-facing CMPP endpoint." >&2
exit 1
@@ -64,7 +74,35 @@ PROD_ADMIN_CREDENTIAL_FILE="$ADMIN_CREDENTIAL_FILE" node tools/deploy/ensure-pro
chmod 600 "$ADMIN_CREDENTIAL_FILE" || true
echo "[deploy] Ensuring runtime log directories"
install -d -m 0755 "$APP_DIR/logs/api" "$APP_DIR/logs/gateway"
install -d -m 0755 "$APP_DIR/logs/api" "$APP_DIR/logs/send-worker" "$APP_DIR/logs/gateway"
echo "[deploy] Installing split API and send-worker services"
node_bin="$(command -v node)"
install -d -m 0755 /etc/systemd/system/cmpp-api.service.d
cat >/etc/systemd/system/cmpp-api.service.d/process-role.conf <<'EOF'
[Service]
Environment=CMPP_PROCESS_ROLE=api
EOF
cat >/etc/systemd/system/cmpp-send-worker.service <<EOF
[Unit]
Description=CMPP durable send workflow worker
After=network.target postgresql.service redis.service cmpp-minio.service
[Service]
User=cmpp-api
Group=cmpp-security
WorkingDirectory=$APP_DIR/api
EnvironmentFile=$ENV_FILE
Environment=CMPP_PROCESS_ROLE=worker
ExecStart=$node_bin dist/send-worker.js
Restart=always
RestartSec=5
StandardOutput=append:$APP_DIR/logs/send-worker/stdout.log
StandardError=append:$APP_DIR/logs/send-worker/stderr.log
[Install]
WantedBy=multi-user.target
EOF
echo "[deploy] Installing restricted security boundary"
bash "$APP_DIR/tools/security/install-security-agent.sh"
@@ -90,15 +128,16 @@ echo "[deploy] Restarting services"
systemctl daemon-reload
if [[ "${OBJECT_STORAGE_DRIVER:-minio}" == "local" ]]; then
systemctl disable --now cmpp-minio 2>/dev/null || true
systemctl enable --now cmpp-api cmpp-gateway nginx
systemctl enable --now cmpp-api cmpp-send-worker cmpp-gateway nginx
else
systemctl enable --now cmpp-minio
systemctl restart cmpp-minio
systemctl enable --now cmpp-api cmpp-gateway nginx
systemctl enable --now cmpp-api cmpp-send-worker cmpp-gateway nginx
fi
systemctl restart cmpp-gateway
systemctl restart cmpp-security-agent
systemctl restart cmpp-api
systemctl restart cmpp-send-worker
systemctl restart nginx
echo "[deploy] Health checks"
@@ -117,6 +156,7 @@ wait_for_http() {
return 1
}
wait_for_http "API" "http://127.0.0.1:${API_PORT:-3000}/api/health"
wait_for_http "Send worker metrics" "http://127.0.0.1:${API_WORKER_METRICS_PORT:-9465}/metrics"
wait_for_http "Gateway" "http://127.0.0.1:8090/health"
redis-cli -h "${REDIS_HOST:-127.0.0.1}" -p "${REDIS_PORT:-6379}" ping >/dev/null
pg_isready -d "${DATABASE_URL%%\?*}" >/dev/null