文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Load balancing

Load balancing

时间:2006-06-23  来源:softiger

Load balancing

From ResinWiki


Resin documentation is at http://www.caucho.com/resin-3.0/config/balance.xtp

Load balancing spreads the load among multiple backend Resin servers in a Cluster. A frontend Resin server proxies requests to the backend servers and sends the results to the clients.

We'll use 192.168.0.10 as the frontend machine and 192.168.0.20 through 192.168.0.28 as the backend machines.

The frontend server and the backend cluster have different configurations since they perform different roles.

Contents

  • 1 The Frontend Server
  • 2 Frontend Configuration
    • 2.1 frontend.conf
  • 3 Sharing Cluster configuration: cluster.xml and <>
    • 3.1 cluster.xml
    • 3.2 frontend.xml
[edit]

The Frontend Server

  1. dispatches requests to the backend servers, generally using sticky sessions
  2. acts as a Proxy Cache for the backend cluster
  3. pools the proxy sockets for efficiency

== The Backend Cluster

  1. does the actual work: the database querying and form processing
  2. manages persistent sessions
[edit]

Frontend Configuration

The frontend needs to configure:

  1. The external HTTP and HTTPS ports its listening to
  2. The cluster-definition of the backend cluster
  3. A LoadBalanceServlet to dispatch requests to the backend
[edit]

frontend.conf

<resin xmlns="http://caucho.com/ns/resin" xmlns:resin="http://caucho.com/ns/resin/core"> <server> <http host="*" port="80"/> <cluster-definition id="backend"> <client-live-time>15s</client-live-time> <srun id="a" host="192.168.0.20" port="6802"/> <srun id="b" host="192.168.0.21" port="6802"/> </cluster-definition> <cache memory-size="32M"/> <host id=""> <web-app id=""> <servlet servlet-name="balance" servlet-class="com.caucho.servlets.LoadBalanceServlet"> <init> <cluster>backend</cluster> </init> </servlet> <servlet-mapping url-pattern="/*" servlet-name="balance"/> </web-app> </host> </server> </resin> 
[edit]

Sharing Cluster configuration: cluster.xml and <resin:import>

Many sites will create a separate cluster.xml using resin's resin:import directive to share information between the frontend and backend:

[edit]

cluster.xml

<cluster> <client-live-time>30s</client-live-time> <srun id="a" host="192.168.0.20" port="6802"/> <srun id="b" host="192.168.0.21" port="6802"/> </cluster> 

In the frontend.conf, you'll replace the <cluster-definition> content with a <resin:import>

[edit]

frontend.xml

<server> ... <cluster-definition id="backend"> <resin:import path="${resin.rootDir}/conf/cluster.xml"/> </cluster-definition> ... </server> 
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载