1

I currently have one server with an Apache-Django app running on it along with postgresDB.

  1. I would like to add another server with the Apache-Django app that is connected to the same postgresDB instance. I would like both the apps to be synchronized and running.

  2. Both of the apps would run, but only one will be in the requested, active passive state - should I use a proxy server for this?

How should I do this?

Ariel Livshits
  • 591
  • 1
  • 7
  • 23

1 Answers1

2

Hi @Ariel Livshits if you have under control all the underlying issues of being in this architecture like handling static files or sessions (to mention a few), you could accomplish this using HAProxy as load balancer. It's very simple actually:

Automatic failover without failback

Sample server configuration:


 |  HAProxy  |
 -------------
  |         `
  |active    ` backup
  |           `
------       ------
| s1 |       | s2 |

The configuration below makes HAProxy to use s1 when available, otherwise fail over to s2 if available. When a failover has occured, no failback will be processed automatically, thanks to the stick table:

peers LB
 peer LB1 10.0.0.98:1234
 peer LB2 10.0.0.99:1234

defaults
 mode http
 option http-server-close
 timeout client 20s
 timeout server 20s
 timeout connect 4s

frontend ft_app
 bind 10.0.0.100:80 name app
 default_backend bk_app

backend bk_app
 stick-table type ip size 1 nopurge peers LB
 stick on dst
 server s1 10.0.0.1:80 check
 server s2 10.0.0.2:80 check backup

Source

Rafael Aguilar
  • 3,084
  • 1
  • 25
  • 31