简体   繁体   English

Apache mod_cluster禁用到节点的连接

[英]Apache mod_cluster disabling connection to nodes

My setup is an Apache Httpd 2.4 server in front of 4 Wildfly 10.1 server nodes. 我的设置是在4个Wildfly 10.1服务器节点前面的Apache Httpd 2.4服务器。 I'm using mod_cluster for load balancing and everything is running fine most of the time. 我正在使用mod_cluster进行负载平衡,并且大多数情况下一切运行正常。 But several times each day, this appears in Apache's error log: 但是每天几次,这会出现在Apache的错误日志中:

[Wed Mar 15 09:15:18.736665 2017] [proxy:error] [pid 18936:tid 1784] AH00940: http: disabled connection for (10.10.87.53)
[Wed Mar 15 09:15:59.955515 2017] [proxy:error] [pid 18936:tid 1784] AH00940: http: disabled connection for (10.10.87.52)

When those errors appear, users complain that they are logged out of the system. 当出现这些错误时,用户会抱怨他们已退出系统。 This happens because I'm using sticky session and when the errors appear, everyone seem to be moved from one node to another, which mean their sessions are lost. 发生这种情况是因为我正在使用粘性会话,并且当出现错误时,每个人似乎都从一个节点移到了另一个节点,这意味着他们的会话丢失了。

However, even though those errors are in the log, the nodes are still active and working when I test them a minute later. 但是,即使这些错误已记录在日志中,当我在一分钟后对其进行测试时,这些节点仍处于活动状态并正常工作。 So whatever disconnect that happened, it only happens momentarily. 因此,无论发生什么断开连接,它都只会暂时发生。

Here is my Apache mod_cluster config: 这是我的Apache mod_cluster配置:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_ajp_module modules/mod_proxy_http.so
LoadModule cluster_slotmem_module modules/mod_cluster_slotmem.so
LoadModule manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_module modules/mod_advertise.so

<IfModule manager_module>
    Listen 10.10.87.50:16666
    ManagerBalancerName nmcluster

    <VirtualHost 10.10.87.50:16666>

        <Location />
            Require ip 10.10.87
        </Location>

        KeepAliveTimeout 300
        MaxKeepAliveRequests 0
        AdvertiseFrequency 5
        AllowDisplay On
        AdvertiseGroup 224.0.1.105:23364
        EnableMCPMReceive

        <Location /mod_cluster_manager>
            SetHandler mod_cluster-manager
            Require ip 10.10.87
        </Location>

    </VirtualHost>
</IfModule>

And here is the config in Wildfly: 这是Wildfly中的配置:

<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
    <mod-cluster-config advertise-socket="modcluster" proxies="proxy" balancer="nmcluster" connector="default">
        <dynamic-load-provider>
            <load-metric type="cpu"/>
        </dynamic-load-provider>
    </mod-cluster-config>
</subsystem>
...
<http-listener name="default" socket-binding="http" redirect-socket="https" proxy-address-forwarding="true" enable-http2="true"/>
...
<socket-binding name="modcluster" port="0" multicast-address="224.0.1.105" multicast-port="23364"/>

How can I make sticky session more sticky? 如何使粘性会话更加粘性? Or even better, how can I stop the error from happening? 甚至更好,如何阻止错误发生?

I still want users to move to another node, if a node is down, but I don't want it to happen just because a node is a little slow for a few seconds, because then it ends up doing more harm than good. 我仍然希望用户移动到另一个节点(如果一个节点发生故障),但是我不希望它仅仅因为一个节点慢了几秒钟而发生,因为那样做最终弊大于利。

I also don't understand why these disconnects happen. 我也不明白为什么会发生这些断开连接。 Any theories would be appreciated. 任何理论将不胜感激。

It appears that when someone upload a large file that takes more than 10 seconds for the Apache server and Wildfly server to handle between them, the above "disabled connection" error occur and everyone lose their session and are logged out. 看来,当某人上载一个较大的文件时,Apache服务器和Wildfly服务器之间需要花费10秒钟以上的时间来处理它们,从而发生上述“禁用连接”错误,并且每个人都丢失了会话并注销了。

The solution is to set ping to something higher than 10 seconds in Wildfly. 解决方法是在Wildfly中将ping设置为高于10秒。 For example ping="60" , like this: 例如ping="60" ,如下所示:

<subsystem xmlns="urn:jboss:domain:modcluster:2.0">
    <mod-cluster-config advertise-socket="modcluster" proxies="proxy" balancer="nmcluster" connector="default" ping="60">
        <dynamic-load-provider>
            <load-metric type="cpu"/>
        </dynamic-load-provider>
    </mod-cluster-config>
</subsystem>

Furthermore, after Wildfly has been restarted with the change, it is very important to restart Apache as well. 此外,在通过更改重新启动Wildfly之后,重新启动Apache同样非常重要。 If you don't restart Apache, mod_cluster-manager will tell you the new setting, but Apache won't be using it. 如果不重新启动Apache,则mod_cluster-manager会告诉您新设置,但Apache不会使用它。

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

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