From f96a88e9709901cf5f00d5b8cbbd9e2febc29be0 Mon Sep 17 00:00:00 2001 From: moctardiouf Date: Fri, 12 Jan 2024 09:02:20 +0100 Subject: [PATCH] PHRAS-3403 set docker containers resource limits (#4456) * PHRAS-3403 set docker containers resource limits * PHRAS-3403 fix .env comments * PHRAS-3403 extend limits to all phraseanet containers * PHRAS-3403 extend limits to all containers and create a dedicated composer file * Update documentation in .env --- .env | 19 +++- docker-compose.limits.yml | 203 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 docker-compose.limits.yml diff --git a/.env b/.env index 06d06bc8f3..85d41251e3 100644 --- a/.env +++ b/.env @@ -30,6 +30,7 @@ # datastores # - "docker-compose.phrasea.yml" : For integrate this stack in the "traefik" of Phrasea stack # +# - "docker-compose.limits.yml" : defines containers cpu and memory limits for all Phraseanet and gateway containers only. # # # 2/ "COMPOSE_PROFILES" value define which profiles you want to use @@ -96,6 +97,10 @@ # - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml # - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,rabbitmq,redis,redis-session,workers,cmd,mailhog,gateway-classic # +# # To test with tools and apply resources throttling on Phraseanet containers : +# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml:docker-compose.limits.yml +# - COMPOSE_PROFILES=app,setup,db,pma,elasticsearch,rabbitmq,redis,redis-session,workers,cmd,mailhog,gateway-classic +# # For testing with debug and SSL (the traekik is provide by Phrasea stack): # - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml:docker-compose.under-phrasea.yml # - COMPOSE_PROFILES=app,setup,gateway-traefik,db,pma,elasticsearch,rabbitmq,redis,redis-session,worker,workers,mailhog @@ -105,7 +110,7 @@ # - COMPOSE_PROFILES=app,setup,workers,gateway-traefik # # Example with all profiles: -# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml +# - COMPOSE_FILE=docker-compose.yml:docker-compose.datastores.yml:docker-compose.tools.yml:docker-compose.limits.yml # - COMPOSE_PROFILES=app,setup,gateway-classic,db,elasticsearch,redis,redis-session,rabbitmq,pma,mailhog,assetsInjest,createRecord,deleteRecord,editRecord, # exportMail,downloadAsync,exposeUpload,exportFtp,mainQueue,populateIndex,pullAssets,recordsActions,subdefCreation, # validationReminder,webhook,writeMetadatas,shareBasket,scheduler,cmd,elk,db-backup,phraseanet-saml-sp @@ -142,6 +147,18 @@ PHRASEANET_DOCKER_TAG=4.1.8-rc7 # @run STACK_NAME= +# --- Phraseanet containers resources limit settings ------------------------------------------------------------------------------------ + +WORKER_CPU=2 +GATEWAY_CPU=2 +FPM_CPU=2 +WORKER_MEMORY_LIMIT=2048M +GATEWAY_MEMORY_LIMIT=2048M +FPM_MEMORY_LIMIT=2048M +WORKER_MEMORY_RESERVATION=256M +GATEWAY_MEMORY_RESERVATION=256M +FPM_MEMORY_RESERVATION=256M + # --- Phraseanet container network settings ------------------------------------------------------------------------------------ # Phrasea network Name, the name of Phrasea network and see by traefik diff --git a/docker-compose.limits.yml b/docker-compose.limits.yml new file mode 100644 index 0000000000..98b3265c41 --- /dev/null +++ b/docker-compose.limits.yml @@ -0,0 +1,203 @@ +version: "3.9" + +services: + gateway: + deploy: + resources: + limits: + cpus: ${GATEWAY_CPU} + memory: ${GATEWAY_MEMORY_LIMIT} + reservations: + memory: ${GATEWAY_MEMORY_RESERVATION} + gateway-traefik: + deploy: + resources: + limits: + cpus: ${GATEWAY_CPU} + memory: ${GATEWAY_MEMORY_LIMIT} + reservations: + memory: ${GATEWAY_MEMORY_RESERVATION} + setup: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + phraseanet: + deploy: + resources: + limits: + cpus: ${FPM_CPU} + memory: ${FPM_MEMORY_LIMIT} + reservations: + memory: ${FPM_MEMORY_RESERVATION} + worker: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-mainQueue: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-assetsIngest: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-createRecord: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-deleteRecord: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-editRecord: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-exportMail: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-downloadAsync: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-exposeUpload: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-exportftp: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-populateIndex: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-pullAssets: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-recordsActions: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-shareBasket: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-subdefCreation: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-subtitle: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-validationReminder: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-webhook: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + w-writeMetadatas: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + scheduler: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION} + cmd: + deploy: + resources: + limits: + cpus: ${WORKER_CPU} + memory: ${WORKER_MEMORY_LIMIT} + reservations: + memory: ${WORKER_MEMORY_RESERVATION}