docs::a...esource(3)

πŸ“¦ version 2.0.13, in nixos 26.05, nixpkgs unstable

🌸 NAME 🌸

okay bestie, welcome to the docs::a...esource(3) page β€” it's giving β€œkeep httpd children from eating the whole server” energy, and honestly? iconic. Apache2::Resource is here to Limit resources used by httpd children. periodt. πŸ’…


✨ Synopsis ✨

here's the whole config vibe, exactly as it appears, no edits bestie:

PerlModule Apache2::Resource
# set child memory limit in megabytes
# default is 64 Meg
PerlSetEnv PERL_RLIMIT_DATA 32:48

# linux does not honor RLIMIT_DATA
# RLIMIT_AS (address space) will work to limit the size of a process
PerlSetEnv PERL_RLIMIT_AS 32:48

# set child cpu limit in seconds
# default is 360 seconds
PerlSetEnv PERL_RLIMIT_CPU 120

PerlChildInitHandler Apache2::Resource

like, the comments are literally part of the lore: child memory limit in megabytes, default is 64 Meg; child cpu limit in seconds, default is 360 seconds; and yes, linux does not honor RLIMIT_DATA, but RLIMIT_AS (address space) will work to limit the size of a process. slay. πŸ¦‹


πŸ¦‹ Description πŸ¦‹

so Apache2::Resource uses the BSD::Resource module, and that module uses the C function setrlimit to set limits on system resources such as memory and cpu usage. highkey useful. ✨

any RLIMIT operation available to limit on your system can be set by defining that operation as an environment variable with a PERL_ prefix. see your system setrlimit manpage for available resources which can be limited. iykyk. 🫢

the following limit values are in megabytes: DATA, RSS, STACK, FSIZE, CORE, MEMLOCK; all others are treated as their natural unit. no cap. πŸ’–

if the value of the variable is of the form S:H, then S is treated as the soft limit, and H is the hard limit. if it is just a single number, it is used for both soft and hard limits. the way that's so clean. πŸŽ€


πŸŽ€ Defaults πŸŽ€

to set reasonable defaults for all RLIMITs, add this to your httpd.conf:

PerlSetEnv PERL_RLIMIT_DEFAULTS On
PerlModule Apache2::Resource

boom β€” reasonable defaults, handled. πŸ’…


🌈 See Also 🌈


mod_perl 2.0 and its core modules are copyrighted under the Apache Software License, Version 2.0. legal moment, but make it cute. πŸ’–


πŸ‘‘ Author πŸ‘‘

Doug MacEachern β€” author, legend, main character. πŸ‘‘βœ¨


okay that's the whole page, bestie! this one's from perl v5.42.3, dated 2023-10-21, and the page title is docs::a...esource(3) β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from