At present, there are 4 load balancer scheduler algorithms available for use: Request Counting (mod_lbmethod_byrequests), Weighted Traffic Counting (mod_lbmethod_bytraffic), Pending Request Counting (mod_lbmethod_bybusyness) and Heartbeat Traffic Counting (mod_lbmethod_heartbeat). These are controlled via the lbmethod value of the Balancer definition. See the ProxyPass directive for more information, especially regarding how to configure the Balancer and BalancerMembers.
The balancer supports stickyness. When a request is proxied to some back-end, then all following requests from the same user should be proxied to the same back-end. Many load balancers implement this feature via a table that maps client IP addresses to back-ends. This approach is transparent to clients and back-ends, but suffers from some problems: unequal load distribution if clients are themselves hidden behind proxies, stickyness errors when a client uses a dynamic IP address that changes during a session and loss of stickyness, if the mapping table overflows.
The module mod_proxy_balancer implements stickyness on top of two alternative means: cookies and URL encoding. Providing the cookie can be either done by the back-end or by the Apache web server itself. The URL encoding is usually done on the back-end.
This is set to 1 if the session route does not match the worker route (BALANCER_SESSION_ROUTE != BALANCER_WORKER_ROUTE) or the session does not yet have an established route. This can be used to determine when/if the client needs to be sent an updated route when sticky sessions are used.
This module requires the service of mod_status. Balancer manager enables dynamic update of balancer members. You can use balancer manager to change the balance factor of a particular member, or put it in the off line mode.
You can now access load balancer manager by using a Web browser to access the page -manager. Please note that only Balancers defined outside of containers can be dynamically controlled by the Manager.
When using cookie based stickyness, you need to configure the name of the cookie that contains the information about which back-end to use. This is done via the stickysession attribute added to either ProxyPass or ProxySet. The name of the cookie is case-sensitive. The balancer extracts the value of the cookie and looks for a member worker with route equal to that value. The route must also be set in either ProxyPass or ProxySet. The cookie can either be set by the back-end, or as shown in the above example by the Apache web server itself.
Some back-ends use a slightly different form of stickyness cookie, for instance Apache Tomcat. Tomcat adds the name of the Tomcat instance to the end of its session id cookie, separated with a dot (.) from the session id. Thus if the Apache web server finds a dot in the value of the stickyness cookie, it only uses the part behind the dot to search for the route. In order to let Tomcat know about its instance name, you need to set the attribute jvmRoute inside the Tomcat configuration file conf/server.xml to the value of the route of the worker that connects to the respective Tomcat. The name of the session cookie used by Tomcat (and more generally by Java web applications based on servlets) is JSESSIONID (upper case) but can be configured to something else.
The second way of implementing stickyness is URL encoding. The web server searches for a query parameter in the URL of the request. The name of the parameter is specified again using stickysession. The value of the parameter is used to lookup a member worker with route equal to that value. Since it is not easy to extract and manipulate all URL links contained in responses, generally the work of adding the parameters to each link is done by the back-end generating the content. In some cases it might be feasible doing this via the web server using mod_substitute or mod_sed. This can have negative impact on performance though.
The Java standards implement URL encoding slightly different. They use a path info appended to the URL using a semicolon (;) as the separator and add the session id behind. As in the cookie case, Apache Tomcat can include the configured jvmRoute in this path info. To let Apache find this sort of path info, you need to set scolonpathdelim to On in ProxyPass or ProxySet.
If you experience stickyness errors, e.g. users lose their application sessions and need to login again, you first want to check whether this is because the back-ends are sometimes unavailable or whether your configuration is wrong. To find out about possible stability problems with the back-ends, check your Apache error log for proxy error messages.
To verify your configuration, first check, whether the stickyness is based on a cookie or on URL encoding. Next step would be logging the appropriate data in the access log by using an enhanced LogFormat. The following fields are useful:
The balancer also logs detailed information about handling stickyness to the error log, if the log level is set to debug or higher. This is an easy way to troubleshoot stickyness problems, but the log volume might be too high for production servers under high load.
If everything was successfully configured you should see the welcome page. Now to check from which web server is serving your requests you need to create a CGI script which displays the hostname of the server. On the NFS server create a file in the /docroot/cgi-bin directory and add the content
Go to the browser and refresh it it will take a few seconds then it will display the hostname of only the server whose network interface is up. All this while did you notice that we keep seeing the hostnames of the web servers and not the load balancer or the storage server. This is because the load balancer is merely a proxy forwarding requests to the web servers and the storage server just hosts the CGI script so the actual execution of the secript takes place on the web servers.
If you plan to use a server side scripting language such as PHP the session variables are stored in the web server itself so this poses a problem as a session variable might not be same on all pages. To prevent this you can place the session save path on the storage server it self and mount it on /var/lib/php/sessions/
Another problem you might face is with the upload temp dir. The default is usually the /tmp directory. By editing the /etc/php.ini file you can change it to something else and mount that directory to the storage server.
The Apache load balancer has three algorithms, to know more about these refer to the Apache documentation at _proxy_balancer.html. To use a specific algorithm open the /etc/httpd/conf/httpd.conf file in the Load Balancer and add the following line in between directive
Apache web server load balancing systems work by positioning a hub server between the client and the server pool, also known as a server cluster. The hub server acts as a load balancer by evaluating incoming server requests, which are then distributed across multiple servers in the server pool. This evaluation process is guided by a predetermined load balancing algorithm. The algorithm dictates what attributes are examined and how the incoming server request is handled by the load balancer.
Countless IT architectures use Windows operating systems and a wide array of Microsoft Windows applications. This has led many to wonder if there is an Apache load balancer for Windows and, in fact, there is. Since you can utilize Apache HTTP web servers with Windows, IT admins can simply deploy a load balancer for Apache while they are using this configuration.
Apache operates in several different modes which are configured using Multi-Processing Modules or MPMs. As part of the Apache load balancer configuration process, IT admins will need to install the Apache mod proxy module and the mod proxy balancer.
It is important to note that setup and deployment of an Apache load balancer does require a fair amount of programming skill. For this reason, some may opt to go with another alternative third-third party solution for Apache load balancing.
There are many advantages of using Apache load balancing for Windows-based technologies. Not only is the Apache load balancer free and open source, but it also brings many benefits in terms of performance.
Apache load balancing is known for being very efficient and suitable for high-performance applications. Performance is improved in a few ways. Firstly, incoming client requests are distributed in a way that ensures the website user receives a prompt server response. This translates into the type of snappy performance that aligns with a positive user experience.
Server health checks are a key load balancer capability; one that improves performance and user experience in some dramatic ways. The load balancer has the ability to perform health checks on the servers in the cluster, resulting in the prompt identification of any malfunctioning servers. If a server response indicates a problem, then that particular server is flagged for maintenance and removed from the pool until it can be fixed. This avoids a scenario where users receive the frustrating server error messages that are typical of a downed website. This is also ideal for those who are using a web platform as mission-critical technology. If a web platform is essential for getting the job done, you need to be confident that it will be online and highly accessible when the need arises. A load balancer will improve both availability and overall reliability.
In cases where the utmost reliability and accessibility is required, you may want to go with a geographic load balancer that uses server pools that are situated in different regions of the world. This load balancing option is ideal for those with a globally-distributed user base, backup and recovery systems or mission-critical technologies.
Geographic load balancing works by distributing to the closest data center with highly available and well-functioning servers. The ability to send incoming server requests to servers that are situated worldwide allows you to avoid a scenario where the system goes down due to a local event such as inclement weather, a power outage, a social conflict or any other issue that may interfere with data center functionality. It is unlikely that any one event such as this would impact multiple data centers and this makes geographic load balancing a great option for superior reliability.
7fc3f7cf58