Apache Lounge


About Forum Index Downloads Search Register Log in RSS X

Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.



A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Heartbeat load balancer method

Joined: 03 Jun 2022
Posts: 3

PostPosted: Fri 03 Jun '22 15:31    Post subject: Heartbeat load balancer method Reply with quote

Hello, I'm investigating load balancing algorithms implemented in Apache server. For bybusyness,
bytraffic and byrequests methods the Apache server works properly. But I have a problem with configuration of heartbeat method. When I try to access the proxy server from a browser I'm getting 503 Service Unavailable and there is a following error in logs file:
AH01170: balancer://mycluster: All workers are in error state

If i understand correctly the documentation ( https://httpd.apache.org/docs/2.4/mod/mod_heartbeat.html ) in order to use heartbeat data I need to set HeartbeatAddress in configuration files of all workers (balancer members) and HeartbeatListen in configuration file of the proxy server. Here is a fragment of my configuration of proxy server:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule status_module modules/mod_status.so
LoadModule watchdog_module modules/mod_watchdog.so
LoadModule heartbeat_module modules/mod_heartbeat.so
LoadModule heartmonitor_module modules/mod_heartmonitor.so
LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so

Listen *:8888
ServerName http://localhost:8888

HeartbeatListen localhost:8089
HeartbeatMaxServers 20

<VirtualHost *:8888>

<Proxy balancer://mycluster>
    BalancerMember http://localhost:8081 route=1
    BalancerMember http://localhost:8082 route=2
    ProxySet lbmethod=heartbeat

ProxyPass        /test balancer://mycluster
ProxyPassReverse /test balancer://mycluster


According to documentation all necessary modules for heartbeat method are loaded. Also the slotmem module is set correctly which is confirmed by a log:

AH02283: Using slotmem from mod_heartmonitor

In the worker servers' configuration files I defined HeartbeatAddress directive with url value which correspond to HeartbeatListen url value set in proxy server's configuration.
I'm not sure if it's properly configured and I haven't found any examples in the Internet showing proper configuration for balancer with heartbeat method. What is more, the documentation says that this method has status "Experimental" so I'm not sure if it fully works.
If anyone have an experience in Apache load balancing topic or know something about heartbeat configuration I will be very grateful for any tips.
Back to top

Joined: 27 Jun 2016
Posts: 152
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Mon 06 Jun '22 15:56    Post subject: Reply with quote


according to the documentation you have to use multicast-addresses ( IPv4 bis, in IPv6 every address starting with FF00::/8 ).

The localhost used in your example is not a multicast-address and it seems that you are running three separate apache-instances one the same host (which seems at least unusual)?

Have tested with two Raspberries and one Notebook and IP-address:port for both HeartbeatAddress on the nodes and HeartbeatListen on the Loadbalancer - with success. So at least the documentation seems to be fine. Smile
Back to top

Joined: 03 Jun 2022
Posts: 3

PostPosted: Mon 06 Jun '22 16:12    Post subject: Reply with quote

Thanks for the answer.
I'm executing load tests for different load balancing methods. Worker servers are running in seperate docker containers on my computer and load balancer server is running directly on my computer, that's why all of them have localhost address with different ports Smile
So according to your answer I think I need to deploy docker containers somewhere or run them on different machines to be able to use multicast-addresses.
And thanks for the confirmation that heartbeat method is working properly despite the "experimental" status in the documentation Smile
Back to top

Joined: 27 Jun 2016
Posts: 152
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Mon 06 Jun '22 16:31    Post subject: Reply with quote

Usually a container's localhost is not the same as another container's localhost and not the same as the Docker-host's lcoalhost. At least unless you put all containers within Docker's host-network.

Haven't checked with Docker - but I guess it might work if you use the same multicast-ip-address:port-combination within Apache's config on the Docker-node-containers and the Docker-loadbalancer-container and ensure that all containers are within the same (Docker-)network.
Back to top

Joined: 03 Jun 2022
Posts: 3

PostPosted: Mon 06 Jun '22 22:31    Post subject: Reply with quote

Now, it works Smile As you said, I put docker-node-containers and docker-loadbalancer-container within the same docker network and I specified the same multicast address for HeartbeatListen (in load-balancer configuration) and HeartbeatAddress (in nodes configuration). And it's working correctly.

Thank you very much for help, I appreciate it Smile
Back to top

Reply to topic   Topic: Heartbeat load balancer method View previous topic :: View next topic
Post new topic   Forum Index -> Apache