Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7050897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:11:58+00:00 2026-05-28T03:11:58+00:00

I have a question about my haproxy config: #——————————————————————— # Global settings #——————————————————————— global

  • 0

I have a question about my haproxy config:

#---------------------------------------------------------------------
# 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

As you can see it is straight forward, but I am a bit confused about how the maxconn properties work.

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.

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.

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.

So questions are:

  1. What happens if the global connections get above 4000? Do they die? Or pool in Linux somehow?
  2. 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?
  3. 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?

Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:11:59+00:00Added an answer on May 28, 2026 at 3:11 am

    Willy got me an answer by email. I thought I would share it. His answers are in bold.

    I have a question about my haproxy config:

       #---------------------------------------------------------------------
       # 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
    

    As you can see it is straight forward, but I am a bit confused about how the
    maxconn properties work.

    There is the global one and the maxconn on the server, in the listen block.

    And there is also another one in the listen block which defaults to something
    like 2000.

    My thinking is this: the global one manages the total number of connections
    that haproxy, as a service, will que or process at one time.

    Correct. It’s the per-process max number of concurrent connections.

    If the number
    gets above that, it either kills the connection, or pools in some linux
    socket?

    The later, it simply stops accepting new connections and they remain in the
    socket queue in the kernel. The number of queuable sockets is determined
    by the min of (net.core.somaxconn, net.ipv4.tcp_max_syn_backlog, and the
    listen block’s maxconn).

    I have no idea what happens if the number gets higher than 4000.

    The excess connections wait for another one to complete before being
    accepted. However, as long as the kernel’s queue is not saturated, the
    client does not even notice this, as the connection is accepted at the
    TCP level but is not processed. So the client only notices some delay
    to process the request.
    But in practice, the listen block’s maxconn is much more important,
    since by default it’s smaller than the global one. The listen’s maxconn
    limits the number of connections per listener. In general it’s wise to
    configure it for the number of connections you want for the service,
    and to configure the global maxconn to the max number of connections
    you let the haproxy process handle. When you have only one service,
    both can be set to the same value. But when you have many services,
    you can easily understand it makes a huge difference, as you don’t
    want a single service to take all the connections and prevent the
    other ones from working.

    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.

    Yes, not only it should be faster, but it allows haproxy to find another
    available server whenever possible, and also it allows it to kill the
    request in the queue if the client hits “stop” before the connection is
    forwarded to the server.

    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.

    That’s exactly the principle. There is a per-proxy queue and a per-server
    queue. Connections with a persistence cookie go to the server queue and
    other connections go to the proxy queue. However since in your case no
    cookie is configured, all connections go to the proxy queue. You can look
    at the diagram doc/queuing.fig in haproxy sources if you want, it explains
    how/where decisions are taken.

    So questions are:

    1. What happens if the global connections get above 4000? Do they die? Or
      pool in Linux somehow?

      They’re queued in linux. Once you overwhelm the kernel’s queue, then they’re
      dropped in the kernel.

    2. 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?

      No, global and server connection settings are independant.

    3. 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?

      You got it right. If your server’s response time is short, there is nothing
      wrong with queueing thousands of connections to serve only a few at a time,
      because it substantially reduces the request processing time. Practically,
      establishing a connection nowadays takes about 5 microseconds on a gigabit
      LAN. So it makes a lot of sense to let haproxy distribute the connections
      as fast as possible from its queue to a server with a very small maxconn.
      I remember one gaming site queuing more than 30000 concurrent connections
      and running with a queue of 30 per server ! It was an apache server, and
      apache is much faster with small numbers of connections than with large
      numbers. But for this you really need a fast server, because you don’t
      want to have all your clients queued waiting for a connection slot because
      the server is waiting for a database for instance.
      Also something which works very well is to dedicate servers. If your site
      has many statics, you can direct the static requests to a pool of servers
      (or caches) so that you don’t queue static requests on them and that the
      static requests don’t eat expensive connection slots.
      Hoping this helps,
      Willy

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about global variable in Objective-C. I have two .m files :
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and
I have question about normalization. Suppose I have an applications dealing with songs. First
I have a question about using streams in .NET to load files from disk.
I have a question about best practices regarding how one should approach storing complex
I have a question about locking. This doesn't have to be only about record
I have a question about how to deploy WPF application into a PC without
I have a question about using os.execvp in Python. I have the following bit
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I have a question about this question . I posted a reply there but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.