From ebfef7289a11d69a47e63533f26662c6be696832 Mon Sep 17 00:00:00 2001 From: kk10 Date: Sun, 18 Oct 2026 11:37:52 +0300 Subject: [PATCH] feat(infra): add cpu and memory limits to all services --- .env.example | 3 +++ compose.yaml | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.env.example b/.env.example index 9d43d046..7a5d1aec 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,6 @@ CACHE_URL_FILE=/run/secrets/cache_url API_REPLICAS=2 IDEMPOTENCY_TTL_SECONDS=86400 + +API_CPUS=0.5 +API_MEM=256M diff --git a/compose.yaml b/compose.yaml index 5096169e..45590342 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,6 +11,10 @@ services: - cache_url deploy: replicas: ${API_REPLICAS:-2} + resources: + limits: + cpus: "${API_CPUS:-0.5}" + memory: ${API_MEM:-256M} depends_on: migrate: condition: service_completed_successfully @@ -33,6 +37,11 @@ services: interval: 5s timeout: 3s retries: 10 + deploy: + resources: + limits: + cpus: "1.0" + memory: 512M restart: unless-stopped migrate: @@ -54,6 +63,11 @@ services: interval: 5s timeout: 3s retries: 10 + deploy: + resources: + limits: + cpus: "0.25" + memory: 128M restart: unless-stopped load_balancer: @@ -62,6 +76,11 @@ services: - "127.0.0.1:8080:8080" volumes: - ./deploy/nginx.conf:/etc/nginx/nginx.conf:ro + deploy: + resources: + limits: + cpus: "0.5" + memory: 128M depends_on: api: condition: service_healthy