What did option maxconn mean in keyword server? will it cause 503 status?

2014-07-01 Thread Jie Jin
Hi, all

Here is the partial of the haproxy.cfg

backend receivers
  mode http
  balance roundrobin
  server s0 172.16.0.202:7700 check maxconn 180
  server s1 172.16.0.202:7711 check maxconn 180

I add an option maxconn after keyword server. When haproxy face
high volume of requests (about 2 concurrent requests), it return many
503 page:

503 Service Unavailable
No server is available to handle this request.

Above message is sent by haproxy ( I found this message in
./src/proto_http.c) .

why did haproxy send 503 page?
I also did not understand the meaning of optioin maxconn. If I remove this
option, haproxy will return only very few 503 page.

Do option maxconn in above configration mean: if concurrent requests come
from frontend is bigger than 180, haproxy will reject these requests and
return 503?
If the concurrent requests come from frontend is bigger than 180, will
haproxy put these requests into a queue? If yes, can I configure the size
of the queue?

*Additional info*
[jj@p2p3 tmp]$ echo show errors | sudo socat stdio /tmp/haproxysock
Total events captured on [01/Jul/2014:18:49:29.713] : 0

*Full configuration (haproxy-1.5-dev24)*

global
  log 127.0.0.1 local0  err
  ulimit-n 50
  maxconn 24
  nbproc 1
  stats socket /tmp/haproxysock

defaults
  log global
  option log-separate-errors
  mode  http
  option  httplog
  option  dontlognull
  retries 3
  option redispatch
  contimeout  3000
  clitimeout  5
  srvtimeout  5
  stats uri /haproxy
  stats enable

frontend http_frontend
  maxconn 24
  bind *:80
  mode http
  option forceclose
  option forwardfor
  reqrep ^([^\ :]*)\ /(.*) \1\ /receiver/\2
  reqadd X-Forwarded-Proto:\ http
  default_backend receivers

backend receivers
  mode http
  balance roundrobin
  server s0 172.16.0.202:7700 check maxconn 180
  server s1 172.16.0.202:7711 check maxconn 180
  server s2 172.16.0.202:7722 check maxconn 180
  server s3 172.16.0.202:7733 check maxconn 180
  server s4 172.16.0.202:7744 check maxconn 180
  server s5 172.16.0.202:7755 check maxconn 180


谢谢
金杰 (Jie Jin)


RE: What did option maxconn mean in keyword server? will it cause 503 status?

2014-07-01 Thread Lukas Tribus
Hi,




 I add an option maxconn after keyword server. When haproxy face 
 high volume of requests (about 2 concurrent requests), it return 
 many 503 page

Of course it will.

You would like to serve 2 concurrent requests, but your 6 servers
only support 180 concurrent connections each. Do the math:

6 x 180 = 1080 concurrent request can be served in your configuration,
of course you will see a lot of 503 errors.



 why did haproxy send 503 page?

Because all backend servers are busy serving 180 concurrent requests,
as per your configuration. You have instructed HAProxy not the send
more than 180 request per server, and that is exactly what HAProxy
is doing (queueing the request until timeout queue [2] expires and
then sending 503 errors).



 I also did not understand the meaning of optioin maxconn. If I remove 
 this option, haproxy will return only very few 503 page.

Please read the documentation about maxconn fully [1] then.



 Do option maxconn in above configration mean: if concurrent requests 
 come from frontend is bigger than 180, haproxy will reject these 
 requests and return 503?

It means: each server can handle up to 180 concurrent requests and HAproxy
will not send more request to the server, but either use a different server
(if there are), or queue it until timeout queue [2] expires, or
contimeout as it is in your case (3 seconds).



 If yes, can I configure the size of the queue?

180 *is* your per server queue size, and its exactly the limitation
you are hitting.



 Additional info 
 [jj@p2p3 tmp]$ echo show errors | sudo socat stdio /tmp/haproxysock 
 Total events captured on [01/Jul/2014:18:49:29.713] : 0 

You gonna need to configure the stats socket properly, show errors
requires operator or admin privileges on the socket [2] (level admin).





Regards,

Lukas



[1] 
http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#maxconn%20%28Server%20and%20default-server%20options%29
[2] http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#timeout%20queue
[3] 
http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#9.2-show%20errors  
  


Re: What did option maxconn mean in keyword server? will it cause 503 status?

2014-07-01 Thread Jie Jin
Hi, Lukas

Many thanks , you are awesome. It's my fault that did not read the
documentation carefully.

I enlarged the timeout queue. No 503 page returned, but the total
sessions in frontend accumulated quickly, which means most of the requests
are queued by haproxy.

I will try to add more servers to run backend server.


谢谢
金杰 (Jie Jin)


On Tue, Jul 1, 2014 at 9:50 PM, Lukas Tribus luky...@hotmail.com wrote:

 Hi,




  I add an option maxconn after keyword server. When haproxy face
  high volume of requests (about 2 concurrent requests), it return
  many 503 page

 Of course it will.

 You would like to serve 2 concurrent requests, but your 6 servers
 only support 180 concurrent connections each. Do the math:

 6 x 180 = 1080 concurrent request can be served in your configuration,
 of course you will see a lot of 503 errors.



  why did haproxy send 503 page?

 Because all backend servers are busy serving 180 concurrent requests,
 as per your configuration. You have instructed HAProxy not the send
 more than 180 request per server, and that is exactly what HAProxy
 is doing (queueing the request until timeout queue [2] expires and
 then sending 503 errors).



  I also did not understand the meaning of optioin maxconn. If I remove
  this option, haproxy will return only very few 503 page.

 Please read the documentation about maxconn fully [1] then.



  Do option maxconn in above configration mean: if concurrent requests
  come from frontend is bigger than 180, haproxy will reject these
  requests and return 503?

 It means: each server can handle up to 180 concurrent requests and HAproxy
 will not send more request to the server, but either use a different server
 (if there are), or queue it until timeout queue [2] expires, or
 contimeout as it is in your case (3 seconds).



  If yes, can I configure the size of the queue?

 180 *is* your per server queue size, and its exactly the limitation
 you are hitting.



  Additional info
  [jj@p2p3 tmp]$ echo show errors | sudo socat stdio /tmp/haproxysock
  Total events captured on [01/Jul/2014:18:49:29.713] : 0

 You gonna need to configure the stats socket properly, show errors
 requires operator or admin privileges on the socket [2] (level admin).





 Regards,

 Lukas



 [1]
 http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#maxconn%20%28Server%20and%20default-server%20options%29
 [2]
 http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#timeout%20queue
 [3]
 http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#9.2-show%20errors