chore(compose): parameterize replicas and resource limits for track-1 experiments
This commit is contained in:
@@ -9,3 +9,32 @@ DATABASE_URL_FILE=/run/secrets/database_url
|
|||||||
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
|
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
|
||||||
SESSION_STORE=postgres
|
SESSION_STORE=postgres
|
||||||
CACHE_URL_FILE=/run/secrets/cache_url
|
CACHE_URL_FILE=/run/secrets/cache_url
|
||||||
|
|
||||||
|
API_REPLICAS=2
|
||||||
|
|
||||||
|
# --- Ресурсы API-реплики (на одну реплику) ---
|
||||||
|
# Серия A трека 1 (фиксированный total): 1×1.0/512M, 2×0.5/256M, 4×0.25/128M
|
||||||
|
API_CPUS=0.5
|
||||||
|
API_MEMORY=256M
|
||||||
|
API_CPU_RESERVATION=0.1
|
||||||
|
API_MEMORY_RESERVATION=64M
|
||||||
|
|
||||||
|
# --- Ресурсы Postgres ---
|
||||||
|
POSTGRES_CPUS=1.0
|
||||||
|
POSTGRES_MEMORY=1G
|
||||||
|
POSTGRES_CPU_RESERVATION=0.25
|
||||||
|
POSTGRES_MEMORY_RESERVATION=256M
|
||||||
|
|
||||||
|
# --- Ресурсы Redis ---
|
||||||
|
REDIS_CPUS=0.5
|
||||||
|
REDIS_MEMORY=256M
|
||||||
|
|
||||||
|
# --- Публичный порт LB на хосте ---
|
||||||
|
LB_PORT=8080
|
||||||
|
|
||||||
|
# --- TTL сессий и идемпотентности ---
|
||||||
|
SESSION_TTL_SECONDS=3600
|
||||||
|
IDEMPOTENCY_TTL_SECONDS=86400
|
||||||
|
|
||||||
|
# --- Graceful drain при SIGTERM ---
|
||||||
|
SHUTDOWN_DRAIN_SECONDS=3
|
||||||
+20
-18
@@ -1,5 +1,13 @@
|
|||||||
name: mtusi-messenger-lab3
|
name: mtusi-messenger-lab3
|
||||||
|
|
||||||
|
x-api-resources: &api-resources
|
||||||
|
limits:
|
||||||
|
cpus: "${API_CPUS:-0.5}"
|
||||||
|
memory: "${API_MEMORY:-256M}"
|
||||||
|
reservations:
|
||||||
|
cpus: "${API_CPU_RESERVATION:-0.1}"
|
||||||
|
memory: "${API_MEMORY_RESERVATION:-64M}"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:16.4-alpine
|
image: postgres:16.4-alpine
|
||||||
@@ -21,11 +29,11 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "1.0"
|
cpus: "${POSTGRES_CPUS:-1.0}"
|
||||||
memory: 1G
|
memory: ${POSTGRES_MEMORY:-1G}
|
||||||
reservations:
|
reservations:
|
||||||
cpus: "0.25"
|
cpus: "${POSTGRES_CPU_RESERVATION:-0.25}"
|
||||||
memory: 256M
|
memory: ${POSTGRES_MEMORY_RESERVATION:-256M}
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
|
||||||
@@ -51,8 +59,8 @@ services:
|
|||||||
deploy:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpus: "0.5"
|
cpus: "${REDIS_CPUS:-0.5}"
|
||||||
memory: 256M
|
memory: ${REDIS_MEMORY:-256M}
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
|
||||||
@@ -87,9 +95,9 @@ services:
|
|||||||
DATABASE_URL_FILE: /run/secrets/database_url
|
DATABASE_URL_FILE: /run/secrets/database_url
|
||||||
CACHE_URL_FILE: /run/secrets/cache_url
|
CACHE_URL_FILE: /run/secrets/cache_url
|
||||||
SESSION_STORE: "redis"
|
SESSION_STORE: "redis"
|
||||||
SESSION_TTL_SECONDS: "3600"
|
SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}"
|
||||||
IDEMPOTENCY_TTL_SECONDS: "86400"
|
IDEMPOTENCY_TTL_SECONDS: "${IDEMPOTENCY_TTL_SECONDS:-86400}"
|
||||||
SHUTDOWN_DRAIN_SECONDS: "3"
|
SHUTDOWN_DRAIN_SECONDS: "${SHUTDOWN_DRAIN_SECONDS:-3}"
|
||||||
GIN_MODE: "release"
|
GIN_MODE: "release"
|
||||||
secrets:
|
secrets:
|
||||||
- database_url
|
- database_url
|
||||||
@@ -111,14 +119,8 @@ services:
|
|||||||
retries: 5
|
retries: 5
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 2
|
replicas: ${API_REPLICAS:-2}
|
||||||
resources:
|
resources: *api-resources
|
||||||
limits:
|
|
||||||
cpus: "0.5"
|
|
||||||
memory: 256M
|
|
||||||
reservations:
|
|
||||||
cpus: "0.1"
|
|
||||||
memory: 64M
|
|
||||||
networks:
|
networks:
|
||||||
- internal
|
- internal
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ services:
|
|||||||
image: nginx:1.27.4-alpine
|
image: nginx:1.27.4-alpine
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "8080:8080"
|
- "${LB_PORT:-8080}:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
Reference in New Issue
Block a user