Bug 5554: Cap raw RLIMIT_NOFILE in max_filedescriptors default (#2483) - #2486
Bug 5554: Cap raw RLIMIT_NOFILE in max_filedescriptors default (#2483)#2486squidadm wants to merge 1 commit into
Conversation
…-cache#2483) setMaxFD() updates Squid_MaxFD. Squid_MaxFD is then used to allocate various FD-indexed tables, including Comm's `fd_table`. When Config.max_filedescriptors is not set, Squid has to guess the maximum number of descriptors this instance can handle. Prior to these changes, that guess was based on OS-provided ulimits (RLIMIT_NOFILE). Using raw RLIMIT_NOFILE values to set Squid_MaxFD results in huge fd_table allocations that kill or incapacitate Squid when OS uses very large limits (e.g., Kubernets soft limit of 1073741816=2^30-8 effectively means "unlimited" and results in ~432 MB fd_table). We now cap such raw values at 100K which yields ~42 MB fd_table. Several other old problems were discovered and marked during this work. Those out-of-scope problems deserve dedicated fixes. N.B. setMaxFD() calls setrlimit(2) in some cases, but the primary/final setrlimit(2) call is in setSystemLimits(). That primary call sets the soft limit to Squid_MaxFD.
|
Cannot create a git commit message from PR title and description. Error while parsing future commit message title: Problematic parser input: Please see PR title and description formatting requirements for more details. This message was added by Anubis bot. Anubis will add a new message if the error text changes. Anubis will remove M-failed-description label when there are no corresponding failures to report. |
|
@kinkie: not sure we want to accept this into v7 as-is. The documentation text has a lot of text that is only relevant to developers (not users). I am thinking there are also a much better long-term fix for the lack of a Squid hard limit, and for misconfigurations. |
Fair point. The text can be changed.
In my opinion, divergence from trunk is a problem because it increases the risk of conflicts. |
A proposal for the amended text is in the first section of the PR description. |
FWIW, I disagree. Also, the description in master (that this PR is backporting) is overall better than the current description in v7 IMHO.
In a dedicated PR targeting master/v8, please. Preferably, such polishing non-emergency PRs should come after the backlog issue is dealt with. Revising how Squid determines the maximum number of descriptors (instead of polishing the description of the current problematic algorithm) may be the best way forward.
Agreed. A lot of improvements are possible in this area, but they should not be happening in a backport-a-bug-fix-to-v7 PR, and they should not be happening now. |
|
Two PRs coming up that do the cleanup. First to use the I am proposing that we hold this PR until we can have all three changes merge together. |
Fix a problem where some environments (e.g. Kubernetes) set
very high hard file descriptor limit. Unless the
max_filedescriptors configuration option is set,
in these cases Squid will match these limits
for some internal data strctures, wasting core memory.
setMaxFD() updates Squid_MaxFD. Squid_MaxFD is then used to allocate
various FD-indexed tables, including Comm's
fd_table. WhenConfig.max_filedescriptors is not set, Squid has to guess the maximum
number of descriptors this instance can handle. Prior to these changes,
that guess was based on OS-provided ulimits (RLIMIT_NOFILE).
Using raw RLIMIT_NOFILE values to set Squid_MaxFD results in huge
fd_table allocations that kill or incapacitate Squid when OS uses very
large limits (e.g., Kubernets soft limit of 1073741816=2^30-8
effectively means "unlimited" and results in ~432 MB fd_table). We now
cap such raw values at 100K which yields ~42 MB fd_table.
Several other old problems were discovered and marked during this work.
Those out-of-scope problems deserve dedicated fixes.
N.B. setMaxFD() calls setrlimit(2) in some cases, but the primary/final
setrlimit(2) call is in setSystemLimits(). That primary call sets the
soft limit to Squid_MaxFD.