Skip to content

Use OpenLiteSpeed as Load Balancer

This guide 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.

Tip

Use your own domain, not litespeedtech.com when configuring your load balancing scenario.

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 and create a new External App.

Set Type to Web Server

Set Name to backend1 and  Address to backend1.litespeedtech.com.

Create and Set Up a Second External App

Set up another back-end by repeating the previous step, and replacing backend1 with backend2 where necessary.

Now there should be two back-end nodes.

Set up Load Balancer

Create another External App. Set Type to Load Balancer.

Set Name to load-balancer and Worker to proxy::backend1,proxy::backend2 . Multiple workers should be separated by a comma (,).

You should now see your two backend servers and one load balancer listed in External App.

Set Context

Create a new 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

You should see that the backend server varies when you visit balancer.litespeedtech.com multiple times.

Note

The load balancer 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.