乘以 Django Apache 服务器

Multiply Django Apache servers

我目前有一台服务器,上面装有 Apache-Django 应用程序 运行ning 以及 postgresDB。

  1. 我想添加另一台连接到同一个 postgresDB 实例的带有 Apache-Django 应用程序的服务器。我希望这两个应用程序都同步并且 运行ning.

  2. 两个应用程序都会 运行,但只有一个应用程序处于请求的主动被动状态 - 我应该为此使用代理服务器吗?

我应该怎么做?

你好@Ariel Livshits,如果你已经控制了这个架构中的所有潜在问题,比如处理静态文件或会话(仅举几例),你可以使用 HAProxy 作为负载平衡器来完成这个。其实很简单:

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