Hi Andreas,

On Mon, Sep 02, 2013 at 09:15:14AM +0000, Andreas Mock wrote:
> Hi all,
> 
> I'm not sure if the following is doable:
> 
> I have several servers (processes providing services) on
> one physical server. Is there a way to limit the count
> of connections for the physical server?
> 
> backend num1
>     server1 IP:Port1
>     server2 IP:Port1
> backend num2
>     server1 IP:Port2
>     server2 IP:Port2
> 
> And I want to limit resources based on
> the entities server1, server2 while sharing
> their resources among the backends.

This was an old request we had in the past, even before the split into
frontend+backend. The question came from hosting providers relying on
virtual hosting on the same server component (eg: apache configured with
virtual hosts). But this mechanism was impossible to implement by then.
Then the request has almost disappeared and nobody has been working on
this. 1.6 should make this possible along with many other things with
the ability to wait on a resource (server's connection count being one
of these).

At the moment I don't have any simple solution to propose. One method
could be to chain two haproxy instances but I find this a bit ugly :

   frontend front
      use_backend num1 if { hdr(host) num1 }
      use_backend num2 if { hdr(host) num2 }

   backend num1
      server1 127.0.0.1:Port1 check
      server2 127.0.0.2:Port1 check

   backend num2
      server1 127.0.0.1:Port2 check
      server2 127.0.0.2:Port2 check

   listen server1
      bind 127.0.0.1:port1
      bind 127.0.0.1:port2
      server server1 $IP maxconn 1000 # no port, no check

   listen server2
      bind 127.0.0.2:port1
      bind 127.0.0.2:port2
      server server2 $IP maxconn 1000 # no port, no check

etc...
As you can see this will concentrate all connections for physical
server "server1" into a single proxy with a common maxconn setting
for all ports. It can do exactly what you want, but I tend to find
this a bit ugly!

Willy


Reply via email to