Direkt zum Inhalt | Direkt zur Navigation

Benutzerspezifische Werkzeuge
Anmelden
Sektionen
Sie sind hier: Startseite Produktivserver Performance Lastverteilung mit HAProxy

Lastverteilung mit HAProxy

Mit Varnish lässt sich zwar eine einfache Lastverteilung im Round-Robin-Verfahren realisieren, für zuverlässige Hochverfügbarkeit sind jedoch aufwendigere Verfahren notwendig.

Dies kann mit HAProxy realisiert werden. Dabei lässt sich HAProxy einfach mit Buildout installieren:

[haproxy-build]
recipe = plone.recipe.haproxy
url = http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.15.tar.gz

[haproxy-config]
recipe = collective.recipe.template
input = ${buildout:directory}/templates/haproxy.conf.in
output = ${buildout:directory}/etc/haproxy.conf
user = ${env:USER}
group = ${grp:GROUP}
frontend-host = 127.0.0.1
frontend-port = 8001

Die haproxy.conf.in-Datei in templates sieht dann z.B. so aus:

global
  maxconn  1024
  user ${haproxy-config:user}
  group ${haproxy-config:group}
  daemon
  nbproc 1
  spread-checks 3
  ulimit-n 65536

defaults
  mode http

  # The zope instances have maxconn 1, and it is important that
  # unused/idle connections are closed as soon as possible.
  option httpclose

  # Remove requests from the queue if people press stop button
  option abortonclose

  retries 3
  option redispatch
  monitor-uri /haproxy-ping

  timeout connect 7s
  timeout queue   15s
  timeout client  300s
  timeout server  300s

  stats enable
  stats uri /haproxy-status
  stats refresh 60s
  stats realm Haproxy\ statistics

frontend zeocluster
  bind ${haproxy-config:frontend-host}:${haproxy-config:frontend-port}
  default_backend zope

  option httplog
  log 127.0.0.1:1514 local6


# Load balancing over the zope instances
backend zope
  appsession __ac len 32 timeout 1d
  balance leastconn
  cookie sid insert nocache indirect
  option httpchk GET /

  server instance 127.0.0.1:8010 cookie p1 check maxconn 1 rise 1
  server instance2 127.0.0.1:8020 cookie p2 check maxconn 1 rise 1
Artikelaktionen