Skip to content

Commit

Permalink
PHRAS-3403 set docker containers resource limits (#4456)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
moctardiouf authored Jan 12, 2024
1 parent 460a42d commit f96a88e
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
203 changes: 203 additions & 0 deletions docker-compose.limits.yml
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit f96a88e

Please sign in to comment.