diff --git a/software/slapos-master/buildout.hash.cfg b/software/slapos-master/buildout.hash.cfg index b36e067287abbe9514c9d1aeaf0b77ba81175827..05e01b5d6ff1aa8c9155a256825ed0b0393cd529 100644 --- a/software/slapos-master/buildout.hash.cfg +++ b/software/slapos-master/buildout.hash.cfg @@ -23,3 +23,7 @@ md5sum = 4998e62351f54700ee23a2ca8cd89329 [template-apache-backend-conf] filename = apache-backend.conf.in md5sum = 9d7104ce18f79a7a84988efc11f5ed23 + +[template-haproxy-cfg] +filename = haproxy.cfg.in +md5sum = fec6a312e4ef84b02837742992aaf495 diff --git a/software/slapos-master/haproxy.cfg.in b/software/slapos-master/haproxy.cfg.in new file mode 100644 index 0000000000000000000000000000000000000000..87dbc9123f96123d5b43ac52578ece9ad7192b31 --- /dev/null +++ b/software/slapos-master/haproxy.cfg.in @@ -0,0 +1,48 @@ +{% set server_check_path = parameter_dict['server-check-path'] -%} +global + maxconn 4096 + stats socket {{ parameter_dict['socket-path'] }} level admin + +defaults + mode http + retries 1 + option redispatch + maxconn 2000 + cookie SERVERID rewrite + balance roundrobin + stats uri /haproxy + stats realm Global\ statistics + # it is useless to have timeout much bigger than the one of apache. + # By default apache use 300s, so we set slightly more in order to + # make sure that apache will first stop the connection. + timeout server 305s + # Stop waiting in queue for a zope to become available. + # If no zope can be reached after one minute, consider the request will + # never succeed. + timeout queue 60s + # The connection should be immediate on LAN, + # so we should not set more than 5 seconds, and it could be already too much + timeout connect 5s + # As requested in haproxy doc, make this "at least equal to timeout server". + timeout client 305s + # Use "option httpclose" to not preserve client & server persistent connections + # while handling every incoming request individually, dispatching them one after + # another to servers, in HTTP close mode. This is really needed when haproxy + # is configured with maxconn to 1, without this option browsers are unable + # to render a page + option httpclose + +{% for name, (port, backend_list) in sorted(parameter_dict['backend-dict'].iteritems()) -%} +listen {{ name }} + bind {{ parameter_dict['ip'] }}:{{ port }} + http-request set-header X-Balancer-Current-Cookie SERVERID +{% set has_webdav = [] -%} +{% for address, connection_count, webdav in backend_list -%} +{% if webdav %}{% do has_webdav.append(None) %}{% endif -%} +{% set server_name = name ~ '-' ~ loop.index0 -%} + server {{ server_name }} {{ address }} cookie {{ server_name }} check inter 3s rise 1 fall 2 maxqueue 5 maxconn {{ connection_count }} +{% endfor -%} +{%- if not has_webdav and server_check_path %} + option httpchk GET {{ server_check_path }} +{% endif -%} +{% endfor %} diff --git a/software/slapos-master/software.cfg b/software/slapos-master/software.cfg index 93e83c4bfb5d59b978516e00aed7b9192ad32f56..e13975c2ab9b94fb3da8fc54719268f6e597d4cc 100644 --- a/software/slapos-master/software.cfg +++ b/software/slapos-master/software.cfg @@ -63,7 +63,9 @@ filename = instance-balancer.cfg.in [template-apache-backend-conf] url = ${:_profile_base_location_}/${:filename} -filename = apache-backend.conf.in + +[template-haproxy-cfg] +url = ${:_profile_base_location_}/${:filename} [versions] python-memcached = 1.47