Commit 22a021b7 authored by Romain Courteaud's avatar Romain Courteaud

Import haproxy optimization.

Cherry-pick was not used due to conflict in default haroxy conf.
parent d9058bbf
...@@ -426,14 +426,24 @@ class Recipe(BaseSlapRecipe): ...@@ -426,14 +426,24 @@ class Recipe(BaseSlapRecipe):
} }
def installHaproxy(self, ip, port, name, server_check_path, url_list): def installHaproxy(self, ip, port, name, server_check_path, url_list):
server_template = """ server %(name)s %(address)s cookie %(name)s check inter 3s rise 2 fall 4""" # inter must be quite short in order to detect quickly an unresponsive node
# and to detect quickly a node which is back
# rise must be minimal possible : 1, indeed, a node which is back don't need
# to sleep more time and we can give him work immediately
# fall should be quite sort. with inter at 3, and fall at 2, a node will be
# considered as dead after 6 seconds.
# maxconn should be set as the maximum thread we have per zope, like this
# haproxy will manage the queue of request with the possibility to
# move a request to another node if the initially selected one is dead
server_template = """ server %(name)s %(address)s cookie %(name)s check inter 3s rise 1 fall 2 maxconn %(cluster_zope_thread_amount)s"""
config = dict(name=name, ip=ip, port=port, config = dict(name=name, ip=ip, port=port,
server_check_path=server_check_path,) server_check_path=server_check_path,)
i = 1 i = 1
server_list = [] server_list = []
cluster_zope_thread_amount = self.options.get('cluster_zope_thread_amount', 1)
for url in url_list: for url in url_list:
server_list.append(server_template % dict(name='%s_%s' % (name, i), server_list.append(server_template % dict(name='%s_%s' % (name, i),
address=url)) address=url, cluster_zope_thread_amount=cluster_zope_thread_amount))
i += 1 i += 1
config['server_text'] = '\n'.join(server_list) config['server_text'] = '\n'.join(server_list)
haproxy_conf_path = self.createConfigurationFile('haproxy_%s.cfg' % name, haproxy_conf_path = self.createConfigurationFile('haproxy_%s.cfg' % name,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment