简体   繁体   English

使用Apache和mod_proxy_balancer进行轻微的粘性负载平衡

[英]Slightly sticky load-balancing with Apache and mod_proxy_balancer

We have a setup where we want sessions to be sticky most of the time, but where we want to be able to rebalance the traffic. 我们有一个设置,我们希望会话在大多数时间都是粘性的,但我们希望能够重新平衡流量。 For example, assume that only one back-end server is up. 例如,假设只有一个后端服务器启动。 100% of the users are routed to that server. 100%的用户被路由到该服务器。 When another server comes up we would like to rebalance the load 50%-50%. 当另一台服务器出现时,我们希望将负载重新平衡50%-50%。 We are using Apache 2.4 with mod_proxy_balancer. 我们正在使用带有mod_proxy_balancer的Apache 2.4。

Sticky sessions are easy to setup using the JSESSIONID cookie, but they are too sticky - once a session has been assigned a route it keeps that route unless the route becomes invalid. 粘性会话很容易使用JSESSIONID cookie进行设置,但是它们太粘了 - 一旦为会话分配了路由,它就会保留该路由,除非路由变得无效。 It is also easy to configure round robin or other balancing schemes without stickiness and control the load for the different back-end servers dynamically, but if we change the load factor that has no effect for sessions configured as sticky except for new sessions and our users are typically logged in all day. 在没有粘性的情况下配置循环或其他平衡方案也很容易,并动态控制不同后端服务器的负载,但是如果我们更改负载因子,除了新会话和用户之外,对配置为粘性的会话没有影响通常是全天登录。

Is it possible to configure "slightly sticky" sessions with mod_proxy_balancer where a session is assigned the same route if nothing has changed, but where existing sessions can be rerouted as a result of a modified load factor or added server or using a command? 是否可以使用mod_proxy_balancer配置“略微粘滞”的会话,如果没有任何更改,会话被分配相同的路由,但是现有的会话可以通过修改的加载因子或添加的服务器或使用命令重新路由?

NGINX seems to support this with the ip-hash and hash balancing methods. NGINX似乎通过ip-hash和hash balancing方法支持这一点。 Is there a solution for Apache? Apache有解决方案吗?

You must configure tomcat instances with same route id as you did in BalancerMember. 您必须使用与BalancerMember中相同的路由ID配置tomcat实例。

Add a jvmRoute parameter in server.xml of Tomcat. 在Tomcat的server.xml中添加jvmRoute参数。 This must be added in Engine name tag. 必须在引擎名称标记中添加。 Tomcat instance configured with 8080 port Tomcat实例配置了8080端口

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM