Hi Zhi Chang,
Le 18/07/2016 à 13:30, zhi a écrit :
hi all.
I have some questions about "max_conn" in HAProxy.
First of all, a question about performance in HAProxy. How many
connections can the HAProxy taken, in other words, what the max
connections in HAProxy?
It depends on so much variables : system tuning, available memory, what
you are doing with those connections (compression, ssl offloading,
regexes, ...).
Second question, I have a haproxy configuration file like this:
global
....
maxconn 2000
....
listen http_proxy localhost:81
server server1 myip:80 maxconn 3000 check inter 10000
server server2 myip:80 maxconn 4000 check inter 10000
Max connections (3000 + 4000) > 2000, what will happen? I think that
the above connections (3000 + 4000 - 2000 = 5000)will be queued by Linux
kernel and wait for another connection to completed being accepted.
To be complete, there are more maxconn variables :
- a "global" maxconn : this is the max number of connections for all the
proxies (listen and frontend sections).
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#maxconn%20(Performance%20tuning)
- a "proxy" maxconn : the max number of connections for this specific
listen/frontend section (can be inherited from a "defaults" section)
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#maxconn%20(Alphabetically%20sorted%20keywords%20reference)
- a "bind" maxconn : in cas you provide several bind keywords for a
proxy but you want to limit them.
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#maxconn%20(Bind%20options)
- a "server" maxconn : which effectively limit the number of concurrent
connections to the specified server.
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#maxconn%20(Server%20and%20default-server%20options)
Once a "proxy" maxconn limit is reached, haproxy will stop accepting new
connections for that proxy, which will remain in the system backlog.
In the same manner, if the "global" maxconn limit is reached, haproxy
will stop accepting new connections for everyone.
It is a good practice to have a larger "global" maxconn if you have
several proxies, so that one proxy won't permit a deny of service on the
others.
If you expect to have 3000 + 4000 connections on the servers, you surely
want a "proxy" maxconn greater than 7000 (will queue them in the
frontend), and a "global" maxconn greater than 7000 too.
My thought is this: params "maxconn" in the global should less than
the total of every members in every listeners.
Does my thought was right?
Greater, except if you wan't to artificially provide some contention
(there are valid use cases).
For example, you may want something like :
global
....
maxconn 10000
....
listen http_proxy localhost:81
maxconn 8000
server server1 myip:80 maxconn 3000 check inter 10000
server server2 myip:80 maxconn 4000 check inter 10000
Btw, consider using the new syntax to declare the listeing address/port
(the older syntax is deprecated and won't work if you upgrade from 1.5
to 1.6):
listen http_proxy
bind localhost:81
--
Cyril Bonté