Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rlimit infinity #1824

Open
matthieumarrast opened this issue Mar 15, 2024 · 1 comment
Open

rlimit infinity #1824

matthieumarrast opened this issue Mar 15, 2024 · 1 comment
Assignees

Comments

@matthieumarrast
Copy link
Contributor

matthieumarrast commented Mar 15, 2024

Problem

In plugin's config.ini file we have:

# resource limit for each app worker
# rlimit_as => maximum area (in bytes) of address space which may be taken
#              by the worker.
# rlimit_nofile => maximum number of open file descriptors for the current
#                  worker.
# rlimit_stack => maximum size (in bytes) of the call stack for the current
#                 worker. This only affects the stack of the main thread
#                 in a multi-threaded worker.
# rlimit_fsize =>  maximum size of a file which the worker may create.
#   (empty value means no limit)
rlimit_as = 1000000000
rlimit_nofile = 1000
rlimit_stack = 10000000
rlimit_fsize = 100000000

So it results to the below circus configuration in tghe circus conf gile (~/tmp/config_auto/circus.ini`):

[watcher:app.<plugin>.main]
...
rlimit_as = 1000000000
rlimit_nofile = 1000
rlimit_stack = 10000000
rlimit_fsize = 100000000

But if we want to disable the limits by seizing empty values in the plugin's config.ini (as written in the comment)

#   (empty value means no limit)
rlimit_as = 
rlimit_nofile =  
rlimit_stack = 
rlimit_fsize = 

it results to missing rlimit options in ~/tmp/config_auto/circus.ini !!

In its documentation, circus indicates that To set a limit value to RLIM_INFINITY, do not set a value, like this config line: ‘rlimit_nofile = ‘.

IMPORTANT: this is applied in https://github.com/metwork-framework/circus/blob/master/circus/process.py, preexec function, check here if indeed infinity rlimits are not taken into accounts

Solution

We should have:

rlimit_as = 
rlimit_nofile =  
rlimit_stack = 
rlimit_fsize = 

in the circus.ini config file.

Update

{% if APP.rlimit_as > 0 %}rlimit_as = {{APP.rlimit_as}}{% endif %}
{% if APP.rlimit_nofile > 0 %}rlimit_nofile = {{APP.rlimit_nofile}}{% endif %}
{% if APP.rlimit_stack > 0 %}rlimit_stack = {{APP.rlimit_stack}}{% endif %}
{% if APP.rlimit_fsize > 0 %}rlimit_fsize = {{APP.rlimit_fsize}}{% endif %}

in file https://github.com/metwork-framework/mfext/blob/master/adm/templates/circus.ini

@matthieumarrast matthieumarrast self-assigned this Mar 15, 2024
@matthieumarrast
Copy link
Contributor Author

matthieumarrast commented Mar 15, 2024

If I try to get the rlimits for my process:
mfserv 1503310 1503228 1 14:04 ? 00:00:00 python /opt/metwork-mfserv-2.2/bin/signal_wrapper.py --timeout=60 --signal=15 --timeout-after-signal=3 --socket-up-after=3 /home/mfserv/var/app_foo_main_1.socket -- uvicorn --uds /home/mfserv/var/app_foo_main_1.socket --workers 1 main.application:app

prlimit -p 1503310
RESOURCE   DESCRIPTION                               SOFT        HARD UNITS
AS         address space limit                sans limite sans limite octets
CORE       max core file size                           0           0 octets
CPU        CPU time                           sans limite sans limite secondes
DATA       max data size                      sans limite sans limite octets
FSIZE      max file size                      sans limite sans limite octets
LOCKS      max number of file locks held      sans limite sans limite verrous
MEMLOCK    max locked-in-memory address space       65536       65536 octets
MSGQUEUE   max bytes in POSIX mqueues              819200      819200 octets
NICE       max nice prio allowed to raise               0           0
NOFILE     max number of open files                 65536       65536 fichiers
NPROC      max number of processes                 100000      100000 processus
RSS        max resident set size              sans limite sans limite octets
RTPRIO     max real-time priority                       0           0
RTTIME     timeout for real-time tasks        sans limite sans limite microsecondes
SIGPENDING max number of pending signals            31612       31612 signaux
STACK      max stack size                         8388608 sans limite octets

resources as, nofile, stack and fsize doesn't have hard limits. So probably by default the limit is "no limit"... no need of code modification.

(stack has a soft limit, I don't know why)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant