]> git.kaiwu.me - haproxy.git/commit
MEDIUM: init: make the global maxconn default to what rlim_fd_cur permits
authorWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 14:43:14 +0000 (15:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2019 14:54:16 +0000 (15:54 +0100)
commitac35093a194a3e1869a937ea88d1177f468b45dd
tree4e963d5439a9db1c769bf9f386b3cfdf9d6ac6ef
parent8d687d846485e41afc359f0006d08dd559adddda
MEDIUM: init: make the global maxconn default to what rlim_fd_cur permits

The global maxconn value is often a pain to configure :
  - in development the user never has the permissions to increase the
    rlim_cur value too high and gets warnings all the time ;

  - in some production environments, users may have limited actions on
    it or may only be able to act on rlim_fd_cur using ulimit -n. This
    is sometimes particularly true in containers or whatever environment
    where the user has no privilege to upgrade the limits.

  - keeping config homogenous between machines is even less easy.

We already had the ability to automatically compute maxconn from the
memory limits when they were set. This patch goes a bit further by also
computing the limit permitted by the configured limit on the number of
FDs. For this it simply reverses the rlim_fd_cur calculation to determine
maxconn based on the number of reserved sockets for listeners & checks,
the number of SSL engines and the number of pipes (absolute or relative).

This way it becomes possible to make maxconn always be the highest possible
value resulting in maxsock matching what was set using "ulimit -n", without
ever setting it. Note that we adjust to the soft limit, not the hard one,
since it's what is configured with ulimit -n. This allows users to also
limit to low values if needed.

Just like before, the calculated value is reported in verbose mode.
src/haproxy.c