Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there any utility which helps modify backend server weights based on backend server utilization ? ( e.g feedbackd used to do this for LVS loadbalancer)

share|improve this question

2 Answers 2

You could try to use a different load-balancing algorithm. leastconn seems to be what you are looking for :

balance leastconn

According to the official HaProxy v1.4 documentation

  leastconn   The server with the lowest number of connections receives the
              connection. Round-robin is performed within groups of servers
              of the same load to ensure that all servers will be used. Use
              of this algorithm is recommended where very long sessions are
              expected, such as LDAP, SQL, TSE, etc... but is not very well
              suited for protocols using short sessions such as HTTP. This
              algorithm is dynamic, which means that server weights may be
              adjusted on the fly for slow starts for instance.

To be compared against the traditional roundrobin:

  roundrobin  Each server is used in turns, according to their weights.
              This is the smoothest and fairest algorithm when the server's
              processing time remains equally distributed. This algorithm
              is dynamic, which means that server weights may be adjusted
              on the fly for slow starts for instance. It is limited by
              design to 4128 active servers per backend. Note that in some
              large farms, when a server becomes up after having been down
              for a very short time, it may sometimes take a few hundreds
              requests for it to be re-integrated into the farm and start
              receiving traffic. This is normal, though very rare. It is
              indicated here in case you would have the chance to observe
              it, so that you don't worry.
share|improve this answer
    
but isnt there some utility which has daemons on all backends reporting their cpu utilization periodically to the loadbalancer? The loadbalancer would then use these values to modify individual server weights? This would be very helpful in a scenario where different HTTP requests take different amounts of processing time. –  aab Nov 29 '12 at 18:35
    
@aab You may refer to this post. –  LoveRight Dec 12 '12 at 9:36
    
Can anyone explain _This algorithm is dynamic, which means that server weights may be adjusted on the fly for slow starts for instance. _ How do I or does HaProxy dynamically change the weights? –  LoveRight Dec 12 '12 at 9:38
    
This is what you're looking for, it's supposed to be sent to HAProxys stats socket. –  sr_ Jun 9 '13 at 14:59

I wrote a utility to do just this, you can download it at GitHub: haproxy-dynamic-weight. It provides a way to dynamically and automatically allocate haproxy traffic across servers in proportion to their load.

If this python & memcached solution isn't for you, you'll see the script's documentation refers and links to two alternatives.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.