Hello,

I'm currently testing a quite simple setup. Haproxy in front of 1 nginx
and 3 backends running a node.js application. Nginx serves static files
only and I have no issue with it.

There are 2 frontends, one for http and one for https.

In a standard configuration the browser will ask for a http dynamic page
then once the page loaded the browser will establish a https websocket
connection for a long time. It also works fine.

However to avoid any overload on node.js backend servers I would like to
limit the number of simultaneous connections on these. It's possible to
define maxconn in backends and that's fine but if the backend server is
overloaded the connecting user is not warned as it may happen while
establishing the websocket connection. The user cannot see the 503 error
in this case.

So I would like to warn the user connecting that there is any kind of
overload on the server if the backends limits are (nearly) reached.
Right now it cannot be done inside the application so I wonder if there
is a way to do that in the frontends before any request is sent to the
backends. A kind of dynamic 503 page may be a solution here. It should
be triggered only if there is a threshold reached on backends.

There is an extract of the current test setup :

frontend www
        bind 0.0.0.0:80
        mode http

        acl is_static_dev       path_beg /application
        acl is_dynamic_dev      path_beg /nodejs/application

        use_backend websocket_backend_dev if is_dynamic_dev
        use_backend www_backend_dev if is_static_dev

        default_backend www_backend

frontend wwws
        bind 0.0.0.0:443 ssl crt /etc/haproxy/ssl/server.pem
        mode http

        acl is_static_dev       path_beg /application
        acl is_dynamic_dev      path_beg /nodejs/application

        use_backend websocket_backend_dev if is_dynamic_dev
        use_backend www_backend_dev if is_static_dev

        default_backend www_backend

backend www_backend_dev
        mode http
        option forwardfor
        server web1 127.0.0.1:81 weight 1 maxconn 8192

backend www_backend
        mode http
        option forwardfor
        server web1 127.0.0.1:81 weight 1 maxconn 8192

backend websocket_backend_dev
        mode http
        option forwardfor
        option http-server-close
        option forceclose
        no option httpclose
        option persist
        option redispatch
        fullconn 20000

        cookie rd insert indirect nocache
        balance roundrobin
        server s1 127.0.0.1:3026 weight  95 maxconn 100 cookie s1
        server s2 127.0.0.1:3030 weight 100 maxconn 100 cookie s2
        server s3 127.0.0.1:3031 weight 100 maxconn 100 cookie s3

BTW: Thank's a lot for HAProxy, it's a very good software.

-- 
Best regards,
Artur

Reply via email to