Skip to content

Instantly share code, notes, and snippets.

@jnewland
Created November 16, 2008 13:44
Show Gist options
  • Save jnewland/25482 to your computer and use it in GitHub Desktop.
Save jnewland/25482 to your computer and use it in GitHub Desktop.
global
# maximum number of simultaneous active connections from an upstream web server
maxconn 500
# Logging to syslog facility local0
# log 127.0.0.1 local0
# Distribute the health checks with a bit of randomness
spread-checks 5
# Uncomment the statement below to turn on verbose logging
#debug
# Settings in the defaults section apply to all services (unless you change it,
# this configuration defines one service, called rails).
defaults
# apply log settings from the global section above to services
log global
# Proxy incoming traffic as HTTP requests
mode http
# Distribute incoming requests between Mongrels by round robin algorythm.
# Note that because of 'maxconn 1' settings in the listen section, Mongrels
# that are busy processing some other request will actually be skipped.
# So, the actual load-balancing behavior is smarter than simple round robin.
balance roundrobin
# Maximum number of simultaneous active connections from an upstream web server
# per service
maxconn 500
# Log details about HTTP requests
option httplog
# Abort request if client closes its output channel while waiting for the
# request. HAProxy documentation has a long explanation for this option.
option abortonclose
# Check if a "Connection: close" header is already set in each direction,
# and will add one if missing.
option httpclose
# If sending a request to one Mongrel fails, try to send it to another, 3 times
# before aborting the request
retries 3
# Do not enforce session affinity (i.e., an HTTP session can be served by
# any Mongrel, not just the one that started the session
option redispatch
# Timeout a request if the client did not read any data for 120 seconds
timeout client 120000
# Timeout a request if Mongrel does not accept a connection for 120 seconds
timeout connect 120000
# Timeout a request if Mongrel does not accept the data on the connection,
# or does not send a response back in 120 seconds
timeout server 120000
# Remove the server from the farm gracefully if the health check URI returns
# a 404. This is useful for rolling restarts.
http-check disable-on-404
# Enable the statistics page
stats enable
stats uri /haproxy?stats
stats realm Haproxy\ Statistics
stats auth haproxy:stats
# Create a monitorable URI which returns a 200 if haproxy is up
monitor-uri /haproxy?monitor
# Specify the HTTP method and URI to check to ensure the server is alive.
# see http://github.com/jnewland/pulse
#option httpchk GET /pulse
# Amount of time after which a health check is considered to have timed out
timeout check 2000
# Rails service section.
listen rails :8000
server rails-1 localhost:8001 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-2 localhost:8002 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-3 localhost:8003 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-4 localhost:8004 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-5 localhost:8005 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-6 localhost:8006 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-7 localhost:8007 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-8 localhost:8008 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-9 localhost:8009 maxconn 1 check inter 20000 fastinter 1000 fall 1
server rails-10 localhost:8010 maxconn 1 check inter 20000 fastinter 1000 fall 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment