Skip to content

Commit 4628b2a

Browse files
committed
feat(config): introduce new parameters for uWSGI worker recyling (reanahub#642)
Upgrade `uwsgi` version and add new parameters for worker recycling. - `idle`: Restarts the worker after it has been idle for the specified number of seconds. - `max-requests`: Restarts the worker after serving the specified number of requests. - `max-worker-lifetime`: Restarts the worker after running for the specified number of seconds. - `reload-on-rss`: Restarts the worker when its resident memory exceeds the specified threshold. Closes reanahub#641
1 parent 050b4e6 commit 4628b2a

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

Dockerfile

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This file is part of REANA.
2-
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 CERN.
2+
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 CERN.
33
#
44
# REANA is free software; you can redistribute it and/or modify it
55
# under the terms of the MIT License; see LICENSE file for more details.
@@ -73,13 +73,23 @@ ARG UWSGI_BUFFER_SIZE=8192
7373
ARG UWSGI_MAX_FD=1048576
7474
ARG UWSGI_PROCESSES=2
7575
ARG UWSGI_THREADS=2
76+
ARG UWSGI_IDLE=60
77+
ARG UWSGI_MAX_REQUESTS=1999
78+
ARG UWSGI_MAX_REQUESTS_DELTA=149
79+
ARG UWSGI_MAX_WORKER_LIFETIME=3600
80+
ARG UWSGI_RELOAD_ON_RSS=1024
7681
ENV FLASK_APP=reana_workflow_controller/app.py \
7782
PYTHONPATH=/workdir \
7883
TERM=xterm \
7984
UWSGI_BUFFER_SIZE=${UWSGI_BUFFER_SIZE:-8192} \
8085
UWSGI_MAX_FD=${UWSGI_MAX_FD:-1048576} \
8186
UWSGI_PROCESSES=${UWSGI_PROCESSES:-2} \
82-
UWSGI_THREADS=${UWSGI_THREADS:-2}
87+
UWSGI_THREADS=${UWSGI_THREADS:-2} \
88+
UWSGI_IDLE=${UWSGI_IDLE:-60} \
89+
UWSGI_MAX_REQUESTS=${UWSGI_MAX_REQUESTS:-1999} \
90+
UWSGI_MAX_REQUESTS_DELTA=149 \
91+
UWSGI_MAX_WORKER_LIFETIME=${UWSGI_MAX_WORKER_LIFETIME:-3600} \
92+
UWSGI_RELOAD_ON_RSS=${UWSGI_RELOAD_ON_RSS:-1024}
8393

8494
# Expose ports to clients
8595
EXPOSE 5000
@@ -104,11 +114,16 @@ CMD exec uwsgi \
104114
--stats /tmp/stats.socket \
105115
--threads ${UWSGI_THREADS} \
106116
--vacuum \
107-
--wsgi-disable-file-wrapper
117+
--wsgi-disable-file-wrapper \
118+
--idle ${UWSGI_IDLE} \
119+
--max-requests ${UWSGI_MAX_REQUESTS} \
120+
--max-requests-delta ${UWSGI_MAX_REQUESTS_DELTA} \
121+
--max-worker-lifetime ${UWSGI_MAX_WORKER_LIFETIME} \
122+
--reload-on-rss ${UWSGI_RELOAD_ON_RSS}
108123

109124
# Set image labels
110125
LABEL org.opencontainers.image.authors="[email protected]"
111-
LABEL org.opencontainers.image.created="2024-11-29"
126+
LABEL org.opencontainers.image.created="2025-03-26"
112127
LABEL org.opencontainers.image.description="REANA reproducible analysis platform - workflow controller component"
113128
LABEL org.opencontainers.image.documentation="https://reana-workflow-controller.readthedocs.io/"
114129
LABEL org.opencontainers.image.licenses="MIT"

requirements.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ alembic==1.13.1 # via reana-db
88
amqp==5.2.0 # via kombu
99
appdirs==1.4.4 # via fs
1010
attrs==23.2.0 # via jsonschema
11-
backports-zoneinfo[tzdata]==0.2.1 # via backports-zoneinfo, kombu
11+
backports-zoneinfo[tzdata]==0.2.1 # via kombu
1212
bracex==2.4 # via wcmatch
1313
bravado==10.3.2 # via reana-commons
1414
bravado-core==6.1.0 # via bravado, reana-commons
@@ -25,8 +25,8 @@ gitdb==4.0.11 # via gitpython
2525
gitpython==3.1.42 # via reana-workflow-controller (setup.py)
2626
google-auth==2.28.1 # via kubernetes
2727
idna==2.10 # via jsonschema, requests
28-
importlib-metadata==7.0.1 # via alembic, flask
29-
importlib-resources==6.1.2 # via alembic
28+
importlib-metadata==8.5.0 # via alembic, flask
29+
importlib-resources==6.4.5 # via alembic
3030
itsdangerous==2.1.2 # via flask
3131
jinja2==3.1.3 # via flask
3232
jsonpickle==3.0.3 # via reana-workflow-controller (setup.py)
@@ -52,8 +52,8 @@ pyrsistent==0.20.0 # via jsonschema
5252
python-dateutil==2.9.0 # via bravado, bravado-core, kubernetes
5353
pytz==2024.1 # via bravado-core
5454
pyyaml==6.0.1 # via bravado, bravado-core, kubernetes, reana-commons, swagger-spec-validator
55-
reana-commons[kubernetes]==0.9.9 # via reana-db, reana-workflow-controller (setup.py)
56-
reana-db==0.9.5 # via reana-workflow-controller (setup.py)
55+
reana-commons[kubernetes]==0.9.9 # via reana-db, reana-workflow-controller (setup.py)
56+
reana-db==0.9.5 # via reana-workflow-controller (setup.py)
5757
requests==2.25.0 # via bravado, bravado-core, kubernetes, reana-workflow-controller (setup.py), requests-oauthlib
5858
requests-oauthlib==1.3.1 # via kubernetes
5959
rfc3987==1.3.8 # via jsonschema
@@ -66,18 +66,18 @@ sqlalchemy-utils[encrypted]==0.41.1 # via reana-db, reana-workflow-controller (
6666
strict-rfc3339==0.7 # via jsonschema
6767
swagger-spec-validator==3.0.3 # via bravado-core
6868
typing-extensions==4.10.0 # via alembic, bravado, kombu, swagger-spec-validator
69-
tzdata==2024.1 # via backports-zoneinfo
69+
tzdata==2025.2 # via backports-zoneinfo
7070
urllib3==1.26.18 # via kubernetes, requests
71-
uwsgi==2.0.24 # via reana-workflow-controller (setup.py)
71+
uwsgi==2.0.28 # via reana-workflow-controller (setup.py)
7272
uwsgi-tools==1.1.1 # via reana-workflow-controller (setup.py)
73-
uwsgitop==0.11 # via reana-workflow-controller (setup.py)
73+
uwsgitop==0.12 # via reana-workflow-controller (setup.py)
7474
vine==5.1.0 # via amqp, kombu
7575
wcmatch==8.4.1 # via reana-commons
7676
webargs==6.1.1 # via reana-workflow-controller (setup.py)
7777
webcolors==1.13 # via jsonschema
7878
websocket-client==1.7.0 # via kubernetes
7979
werkzeug==2.3.8 # via flask, reana-commons, reana-workflow-controller (setup.py)
80-
zipp==3.17.0 # via importlib-metadata, importlib-resources
80+
zipp==3.20.2 # via importlib-metadata, importlib-resources
8181

8282
# The following packages are considered to be unsafe in a requirements file:
8383
# setuptools

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
#
33
# This file is part of REANA.
4-
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023 CERN.
4+
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2025 CERN.
55
#
66
# REANA is free software; you can redistribute it and/or modify it
77
# under the terms of the MIT License; see LICENSE file for more details.
@@ -61,8 +61,8 @@
6161
"requests==2.25.0",
6262
"sqlalchemy-utils>=0.31.0",
6363
"uwsgi-tools>=1.1.1",
64-
"uWSGI>=2.0.17",
65-
"uwsgitop>=0.10",
64+
"uWSGI>=2.0.28",
65+
"uwsgitop>=0.12",
6666
"webargs>=6.1.0,<7.0.0",
6767
]
6868

0 commit comments

Comments
 (0)