Actions

Use OpenLiteSpeed as Load Balancer

From OpenLiteSpeed Wiki

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

Backend1.PNG

Backend2.PNG

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.

Navigate to the Virtual Host, and create an External App. Balancer1.PNG

Set Type to Web Server

Balancer2.PNG

Set up Back-end Address

Balancer3.PNG

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.

Balancer4.PNG

Now there should be two back-end nodes.

Set up Load Balancer

Create a new External App.

Balancer5.PNG

Set Type to Load Balancer.

Configure Load Balancer App

Balancer6.PNG

Set Worker to proxy::backend1,proxy::backend2 (Multiple workers should be seperated by ,)

You should see the following listed in External App:

Balancer7.PNG

Set Context

Balancer8.PNG

Set Type to Load Balancer.

Balancer9.PNG

Set URI to /

Balancer10.PNG

Add Balancer to Back-End Listeners

Add balancer.litespeedtech.com to both back-end nodes' listeners as a reverse proxy will pass the hostname.

Balancer11.PNG

Balancer12.PNG

Restart and Verify

Restart OpenLiteSpeed on all of these three servers so changes can take effect. Then, access your front-end balancer address to verify that everything is working as expected.

Balancer13.PNG

This is served by back-end 1

Balancer14.PNG

This is served by back-end 2

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.