集群环境配置Tomcat的bindOnInit参数控制在完全启动后才接受Request请求


在Tomcat+Nginx集群部署运行的过程发现个问题,假如集群配置两个Tomcat_A和Tomcat_B并且Tomcat_B作为backup模式运行, 假如Tomcat_B重启更新完版本,做完AB测试验证后。

此时关闭重新启动Tomcat_A,在关闭Tomcat的瞬间正在访问的用户请求会自然切换到Tomcat_B上面,但是继续启动如果是新用户访问请求,还是优先访问Tomcat_A,但是此时Tomcat_A还没有完全启动,用户的请求就一直挂起一直等到Tomcat_A启动完毕。

期望是:在Tomcat_A还没有启动完毕之前,不要请求Tomcat_A,而是持续访问集群的Tomcat_B

解决方案:

通过查阅Tomcat的官方文档,找到如下参数:

bindOnInit

Controls when the socket used by the connector is bound. By default it is bound when the connector is initiated and unbound when the connector is destroyed. If set to false, the socket will be bound when the connector is started and unbound when it is stopped.

据此修改tomcat的server.xml:

    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"  URIEncoding="UTF-8" bindOnInit="false"/>

启动验证通过,在启动完毕之前用户请求直接返回找不到页面,而不再一直傻傻等待Tomcat启动到完毕。

以上配置以HTTP Connector为参考,如果是以AJP Connector作为请求分发,对应修改ajp connetor参数即可。

转载于:https://my.oschina.net/s2jh/blog/265477

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值