定义了一个名为balaweb54_1的worker,使用ajp13协议来通讯,apache连接tomcat的端口
是2009,host=localhost表示监听2009端口的主机是本机,lbfactor定义负载平衡的权
值,socket_keepalive这个值在web服务器和tomcat之间装有防火墙的时候需要用到,因为防火墙会丢掉处于
inactive状态的连接,如果设置了这个值为true(默认为false)的话,操作系统会不断的发KEEP_LIVE信息给这个连接,这
样的话,防火墙就不会丢掉这种处于inactive状态的连接,貌似这个属性对我们网站而言也用不上,用默认值就Ok了。
socket_timeout:就不介绍了。
上面还定义了一个type为lb的worker,表示有多个tomcat的时候,在多个tomcat之间均衡负载,这里只配置一个
tomcat,这负载全给这个tomcat , sticky_session官网的解释:Specifies whether requests with
SESSION ID's should be routed back to the same Tomcat worker. If sticky_session is
set to True or 1 sessions are sticky, otherwise sticky_session is set to False. Set
sticky_session to False when Tomcat is using a Session Manager which can persist
session data across multiple instances of Tomcat.
sticky_session_force 的解释:Specifies whether requests with SESSION ID's for
workers that are in error state should be rejected. If sticky_session_force is set
to True or 1 and the worker that matches that SESSION ID is in error state, client will
receive 500 (Server Error). If set to False or 0 failover on another worker will be
issued with loosing client session. This directive is used only when you
set sticky_session=True.
“If set to False or 0 failover on another worker will be issued with loosing client session. This directive is used only when you set sticky_session=True.”
这句话不是很明白。貌似这两个值在只有一台tomcat服务器的时候,用默认值就Ok了。
我觉得在只有一个tomcat的时候,这两个sticky的配置完全可以删掉。
uriworkermap.properties文件的内容如下:
/*.do=loadbalancer
/*.jsp=loadbalancer
/dwr/*=loadbalancer
/servlet/*=loadbalancer
!/*.shtml=loadbalancer
!/*.html=loadbalancer
!/*.js=loadbalancer
!/*.css=loadbalancer
!/*.jpg=loadbalancer
!/*.gif=loadbalancer
loadbalancer即workers文件里面定义的loadbalancer,/*.do ,/*.jsp , /dwr/* ,
/servlet/* 这几个表示这样的动态
请求交给loadbalancer处理,而shtml ,html ......这些不交给loadbalancer处理,即由
apache处理,这就验证了开始
说的,静态请求有apache处理,动态请求由tomcat处理,!/*.shtml=loadbalancer ,感
叹号!表示 "非"的意思。