title: Difference between global maxconn and server maxconn haproxy
body: <p>I have a question about my haproxy config:</p>
  
  <pre><code>#---------------------------------------------------------------------
  # Global settings
  #---------------------------------------------------------------------
  global
      log         127.0.0.1 syslog emerg
      maxconn     4000
      quiet
      user        haproxy
      group       haproxy
      daemon
  #---------------------------------------------------------------------
  # common defaults that all the 'listen' and 'backend' sections will 
  # use if not designated in their block
  #---------------------------------------------------------------------
  defaults
      mode        http
      log         global
      option      abortonclose
      option      dontlognull
      option      httpclose
      option      httplog
      option      forwardfor
      option      redispatch
      timeout connect 10000 # default 10 second time out if a backend is not found
      timeout client 300000 # 5 min timeout for client
      timeout server 300000 # 5 min timeout for server
      stats       enable
  
  listen  http_proxy  localhost:81
  
      balance     roundrobin
      option      httpchk GET /empty.html
      server      server1 myip:80 maxconn 15 check inter 10000
      server      server2 myip:80 maxconn 15 check inter 10000
  </code></pre>
  
  <p>As you can see it is straight forward, but I am a bit confused about how the maxconn properties work. </p>
  
  <p>There is the global one and the maxconn on the server, in the listen block. My thinking is this: the global one manages the total number of connections that haproxy, as a service, will queue or process at one time. If the number gets above that, it either kills the connection, or pools in some linux socket? I have no idea what happens if the number gets higher than 4000.</p>
  
  <p>Then you have the server maxconn property set at 15. First off, I set that at 15 because my php-fpm, this is forwarding to on a separate server, only has so many child processes it can use, so I make sure I am pooling the requests here, instead of in php-fpm. Which I think is faster. </p>
  
  <p>But back on the subject, my theory about this number is each server in this block will only be sent 15 connections at a time. And then the connections will wait for an open server. If I had cookies on, the connections would wait for the CORRECT open server. But I don't.</p>
  
  <p>So questions are:</p>
  
  <ol>
  <li>What happens if the global connections get above 4000? Do they die? Or pool in Linux somehow?</li>
  <li>Are the global connection related to the server connections, other than the fact you can't have a total number of server connections greater than global?</li>
  <li>When figuring out the global connections, shouldn't it be the amount of connections added up in the server section, plus a certain percentage for pooling? And obviously you have other restrains on the connections, but really it is how many you want to send to the proxies?</li>
  </ol>
  
  <p>Thank you in advance.</p>