Use OpenLiteSpeed as Load Balancer
This wiki will show you how to set up OpenLiteSpeed as a load balancer.
This example uses three servers:
backend1.litespeedtech.com
backend2.litespeedtech.com
balancer.litespeedtech.com
backend1
and backend2
will act as back-end nodes, and balancer
will act as a front-end load balancer.
Verify Two Back-End Nodes are Working
Each node displays different text in order to distinguish them from each other.
Create an External App
Access the WebAdmin console of the OpenLiteSpeed instance that will be used as the load balancer.
Set Type to Web Server
Set up Back-end Address
For this example, set Address’ to backend1.litespeedtech.com
Create and Set Up a Second External App
Set up another back-end by repeating the previous two steps.
Now there should be two back-end nodes.
Set up Load Balancer
Create a new External App.
Set Type to Load Balancer
.
Configure Load Balancer App
Set Worker to proxy::backend1,proxy::backend2
(Multiple workers should be seperated by ,
)
You should see the following listed in External App:
Set Context
Set Type to Load Balancer
.
Set URI to /
Add Balancer to Back-End Listeners
Add balancer.litespeedtech.com
to both back-end nodes’ listeners as a reverse proxy will pass the hostname.
Restart and Verify
This is served by backend2
.
Note: The load balancer primarily uses the first back-end as much as possible when traffic is low. Only with higher traffic will the second back-end be used. This is because stateless round robin may break session data.