Skip to content

Instantly share code, notes, and snippets.

@rizkyabdilah
Created July 27, 2012 17:39
Show Gist options
  • Save rizkyabdilah/3189291 to your computer and use it in GitHub Desktop.
Save rizkyabdilah/3189291 to your computer and use it in GitHub Desktop.
Use backup server on HAProxy when connection is too much or one service is going down
frontend frontend_service 127.0.0.1:9200
mode tcp
balance roundrobin
acl max_conn_reached fe_conn gt 20
acl production_almost_death nbsrv(production) lt 2
default_backend production
use_backend production_and_backup if max_conn_reached OR production_almost_death
backend production
mode tcp
balance roundrobin
server production01 127.0.0.1:8001 check maxconn 10
server production02 127.0.0.1:8002 check maxconn 10
backend production_and_backup
mode tcp
balance roundrobin
server production01 127.0.0.1:8001 check maxconn 10
server production02 127.0.0.1:8002 check maxconn 10
server backup01 127.0.0.1:8003 check maxconn 10
server backup02 127.0.0.1:8004 check maxconn 10
@rizkyabdilah
Copy link
Author

I assume low maxconn, change it to suit with your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment