BUG/MINOR: init: make the automatic maxconn consider the max of soft/hard limits
James Stroehmann reported something working as documented but that can be considered as a regression in the way the automatic maxconn is calculated from the process' limits : https://www.mail-archive.com/haproxy@formilux.org/msg36523.html The purpose of the changes in 2.0 was to have maxconn default to the highest possible value permitted to the user based on the ulimit -n setting, however the calculation starts from the soft limit, which can be lower than what users were allowed to with previous versions where the default value of 2000 would force a higher ulimit -n as long as it fitted in the hard limit. Usually this is not noticeable if the user changes the limits, because quite commonly setting a new value restricts both the soft and hard values. Let's instead always use the max between the hard and soft limits, as we know these values are permitted. This was tried on the following setup: $ cat ulimit-n.cfg global stats socket /tmp/sock1 level admin $ ulimit -n 1024 Before the change the limits would show like this: $ socat - /tmp/sock1 <<< "show info" | grep -im2 ^Max Maxsock: 1023 Maxconn: 489 After the change the limits are now much better and more in line with the default settings in earlier versions: $ socat - /tmp/sock1 <<< "show info" | grep -im2 ^Max Maxsock: 4095 Maxconn: 2025 The difference becomes even more obvious when running moderately large configs with hundreds of checked servers and hundreds of listeners: $ cat ulimit-n.cfg global stats socket /tmp/sock1 level admin listen l bind :10000-10300 server-template srv- 300 0.0.0.0 check disabled Before After Maxsock 1024 4096 Maxconn 189 1725 This issue is tagged as minor since a trivial config change fixes it, but it would help new users to have it backported as far as 2.0.
This commit is contained in:
parent
2a950d02a9
commit
b1beaa302c
@ -1417,7 +1417,7 @@ static int compute_ideal_maxconn()
|
||||
int ssl_sides = !!global.ssl_used_frontend + !!global.ssl_used_backend;
|
||||
int engine_fds = global.ssl_used_async_engines * ssl_sides;
|
||||
int pipes = compute_ideal_maxpipes();
|
||||
int remain = rlim_fd_cur_at_boot;
|
||||
int remain = MAX(rlim_fd_cur_at_boot, rlim_fd_max_at_boot);
|
||||
int maxconn;
|
||||
|
||||
/* we have to take into account these elements :
|
||||
|
Loading…
x
Reference in New Issue
Block a user