虽然mod_jk 和mod_proxy_ajp(或mod_proxy_http)都没有针对高负载重新调整大小的任何特定功能(据我所知),但我绝对知道mod_jk 可以配置为后端实例(Tomcat 节点),它们不必一直运行。
以如下配置为例:
worker.list=T1lb, T2lb, T3lb, T4lb
worker.T1lb.type-lb
worker.T1lb.balance_workers=h1t1, h2t1, h3t1, h4t1
worker.T2lb.type-lb
worker.T2lb.balance_workers=h1t2, h2t2, h3t2, h4t2
[etc for other combinations of TXlb]
worker.h1t1.host=host1.internal
worker.h1t1.port=1111
worker.h1t1.ping_mode=A
worker.h1t2.host=host1.internal
worker.h1t2.port=2222
worker.h1t2.ping_mode=A
worker.h1t3.host=host1.internal
worker.h1t3.port=3333
worker.h1t3.ping_mode=A
worker.h1t4.host=host1.internal
worker.h1t4.port=4444
worker.h1t4.ping_mode=A
[etc for other combinations of hXtY]
如果您只是关闭(或不启动)h1t3 和 h1t4 的 Tomcat 节点,那么 mod_jk 将知道它们不可用并且不会向它们发送请求。当您启动它们时,它们将开始接受请求。
此配置还有另一个选项。它有点干净,但需要更多的工作。
你有和上面一样的配置,但是你将你通常不在线的节点的activation状态显式设置为disabled,像这样:
worker.h1t3.host=host1.internal
worker.h1t3.port=3333
worker.h1t3.ping_mode=A
worker.h1t3.activation=S
worker.h1t4.host=host1.internal
worker.h1t4.port=4444
worker.h1t4.ping_mode=A
worker.h1t4.activation=S
如果您想启动节点 h1t3 和 h1t4,则将这些节点联机,然后将这些工作人员的激活状态从 S(停止)更改为 A(活动) .然后,mod_jk 将开始向这些可用节点发送请求。当您想使它们脱机时,再次将节点置于S 状态(停止),然后停止那些 Tomcat 实例。
Apache Tomcat 连接器load balancing howto 中记录了很多内容,Apache Tomcat 连接器worker reference 中有完整参考。