Score:0

How to configure an Apache load balancing proxy with a hot standby BalancerMember

vn flag

I have two docker containers each with a running application on port 8080. This application has a REST endpoint "/status" that can signal if the application still has the resources to accept another request by a user. A user request will be forwarded and balanced to the two containers by an load balancing Apache proxy.

What I want to achieve:

  1. If the application in a container signals it doesn't want to receive more requests the balancer will not forward requests to this container
  2. If every running application server signals to not receive any requests one of those servers should receive the requests anyway.

What I've configured:

<VirtualHost *:80>
    ProxyRequests off
    ProxyPreserveHost On
    
    ProxyHCExpr status_ok {hc('body') ~ /Status: ok/}
    
    <Proxy balancer://application-cluster>
            BalancerMember http://application1:8080 route=worker1 hcexpr=status_ok hcmethod=get hcuri=/status
            BalancerMember http://application2:8080 route=worker2 hcexpr=status_ok hcmethod=get hcuri=/status
            BalancerMember http://application1:8080 route=standby status=+H
            ProxySet lbmethod=byrequests 
    </Proxy>
    
    <Location /balancer-manager>
            SetHandler balancer-manager
    </Location>

    ProxyPass /balancer-manager !

    ProxyPass / balancer://application-cluster/
    ProxyPassReverse / balancer://application-cluster/
</VirtualHost>

As you can see here, application1 is definded as a hot standby and should be the "victim" to handle requests if all other BalanceMembers are "offline" for new requests

What works:

  • The requests are load balanced to both BalancerMembers.
  • application1 and application2 can signal to not receive any requests. In this case both BalancerMembers show the expected status "Init HcFl" on the the Balancer Manager page.

What doesn't work:

  • application1 doesn't show up as hot standby on the Balance Manager page
  • Therefore requests will not be forwarded to application1

What's possible but I don't want to do:

  • If I configure the hot standby to forward to another port on application1 it will show up and forward requests to this port.

It seems like Apache just removes a BalancerMember if host and port are equal to another BalancerMember. Do I miss something or is there another way to achieve what I want?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.