apache负载均衡中的异常行为

时间:2015-05-20 12:58:58

标签: apache load-balancing

我有一个apache mod代理负载均衡器,具有以下配置 NameVirtualHost *:5555 <VirtualHost *:5555> ServerName localhost ProxyPass / balancer://dgraphs/ ProxyPassReverse / balancer://dgraphs/ <Proxy balancer://dgraphs> BalancerMember http://172.16.23.232:15000 loadfactor=1 BalancerMember http://172.16.27.87:15011 loadfactor=1 </Proxy> </VirtualHost> <Location /balancer-manager> SetHandler balancer-manager </Location> 我在apache负载均衡器如何将查询请求转发给balancer-members时遇到异常行为。每次我向apache发送请求时,它向平衡器成员,一对一服务器和另一个服务器发送3个请求。在连续的请求中,这反过来,我的意思是它然后向第一个服务器发送两个请求,向第二个服务器发送一个请求。继承人&#39;平衡器成员处理程序的快照。

Request 1

Request 2

并且这种行为重复(+ 2 + 1,+ 1 + 2)

我是否在配置中出错了或者是否存在某种延迟,因为apache failsover并且每次都向第二台服务器发送请求并再次向第一台服务器发送请求? 请HElP!

1 个答案:

答案 0 :(得分:1)

似乎您可能缺少使用Load Balancer设置的虚拟主机的一些配置详细信息,下面是一个有效的示例配置:

<VirtualHost *:80>
ProxyRequests off

ServerName servername.local

<Proxy balancer://mycluster>
        # TomcatA
        BalancerMember http://172.20.20.101:8080 route=tomcatA
        # TomcatB
        BalancerMember http://172.20.20.102:8080 route=tomcatB
        # TomcatC
        BalancerMember http://172.20.20.103:8080 route=tomcatC


        # Security – to determine who is allowed to access
        # Currently all are allowed to access
        Order Deny,Allow
        Deny from none
        Allow from all

        # Load Balancer Settings
        # We will be configuring a simple Round
        # Robin style load balancer.  This means
        # that all nodes take an equal share of
        # of the load.
        ProxySet lbmethod=byrequests

</Proxy>

# balancer-manager
# This tool is built into the mod_proxy_balancer
# module and will allow you to do some simple
# modifications to the balanced group via a gui
# web interface.
<Location /balancer-manager>
        SetHandler balancer-manager

        # I recommend locking this one down to your
        # administering location
        Order deny,allow
        Allow from all
</Location>

# Point of Balance
# This setting will allow to explicitly name the
# location in the site that we want to be
# balanced, in this example we will balance "/"
# or everything in the site.
ProxyPass /balancer-manager !
ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=Off scolonpathdelim=On

如果您需要在App Server实例之间共享会话,则需要在Apache上进行进一步配置以使用AJP端口而不是HTTP以及配置应用服务器以共享会话。您可以在此处获得更多详细信息:

Load Balancing: Apache versus Physical Appliance