Hi Andreas,

On Thu, Dec 09, 2010 at 02:00:30PM +0100, Andreas Kohn wrote:
> Ok,
> 
> attached a set of patches that allows an admin user to add and remove a
> server from an existing backend using the stats interface.
> 
> The use-case we have for this is that we have a lot of servers that come
> and go (amazon cloud environment with automatic scaling), and to add
> them to a haproxy we want to avoid restarts of the haproxy.
> 
> A simple example:
> 
> Adding a serverA ipA:portA to the 'query_backend':
> echo "add server query_backend/serverA ipA:portA check inter 3000 rise 2 fall 
> 3 maxconn 50" | socat stdio unix-connect:/var/haproxy.socket
> 
> Removing serverA again:
> echo "remove server query_backend/serverA" | socat stdio 
> unix-connect:/var/haproxy.socket
> 
> 
> The commands do not modify the configuration file, so a restart of haproxy 
> will
> "forget" about the added servers. In our use case we'll modify the 
> configuration
> using some scripts, so this was not a problem, and changing the configuration 
> files
> would be quite a bit of work.
> 
> 
> I've tested the actual commands by repeatedly adding/removing a web server 
> and verifying that haproxy returns the proper answer (200 if the server is 
> there, 503 
> if it was removed)
> 
> 
> Patch index:
> 
> 0001-Move-the-Wall-from-COPTS-into-a-separate-variable-WA.patch
> 0002-Do-not-return-a-value-from-a-void-function.patch
>      Two patches I initially did because I tried compiling with Sun cc
>      first. Unfortunately there is a lot more issues with this
>      compiler, so I stopped there and used gcc again.
> 
> 0003-Set-the-session-previous-server-to-the-current-serve.patch
>      Patch for the issue in assign_server() I reported in the
>      previous mail.
> 
> 0004-Fix-typos-in-comments.patch
>      Some comment typos fixed.
> 
> The actual dynamic adding/removing:
> 0005-Pull-out-the-checks-for-a-single-server-configuratio.patch
>      Factor out the server configuration validation from 
> cfgparse:check_config_validity()
> 
> 0006-Factor-out-allocation-and-configuration-of-a-new-ser.patch
>      Factor out the server creation and application of configuration options
>      from cfgparse:cfg_parse_listen()
> 
> 0007-Add-support-for-adding-removing-servers-from-an-exis.patch
>      The new 'add server'/'remove server' commands for 
> dumpstats:stats_sock_parse_request()
>      This also adds two SRV_ flags: SRV_REMOVED is used to remove the
>      server when bringing it down, SRV_ADDED is currently unused.
> 
> 
> I currently have open "issues" with this:
> 1) is the adding doing the right things in terms of putting it in
>    in the struct proxy and setting it up? 
> 2) I still need to check what other structures need to be free()'d
>    when removing a server
> 3) is there any kind of locking requirements if requests come in while
>    a server is added/removed?
> 
> 
> What do you think? 

I still have a problem with doing that because I don't see how you can
easily fix some parameters that are determined at config time :

  - the size of the LB map for hash/static-rr is determined as the sum of
    the servers' weights divided by their GCD. Adding a server or changing
    even one weight will result in a change of the map size. This must be
    reallocated and recomputed.

  - the number of file descriptors is set to the total amount of required
    sockets (listeners, client, server, pipes, checks). If you add servers,
    you will need more sockets to run the checks, but you don't have the
    required privileges anymore to change the ulimit. That means that
    connections or health checks may randomly fail when working close to
    connection limit if some servers are added.

  - what happens when you remove a server that is being tracked or referenced
    by an ACL ?

Thanks,
Willy

Reply via email to