A Lightsail load balancer distributes incoming application traffic among multiple Lightsail instances, in multiple Availability Zones. Load balancing can increase the fault tolerance of your applications and helps makes them more highly available.

The load balancer serves as a single point of contact for clients, which increases the availability of your application. You can add and remove instances from your load balancer as your needs change, without disrupting the overall flow of requests to your application.

With Lightsail load balancing, we create a DNS host name and route any requests sent to this host name to a pool of target Lightsail instances. You can add as many target instances to your load balancer as you like, as long as you stay within your Lightsail account limits for total number of instances.

By default, your load balancer handles unencrypted traffic requests (HTTP) through port 80. You can set up HTTPS using a validated SSL/TLS certificate so that your load balancer can also handle encrypted traffic. To set up HTTPS, see Create an SSL/TLS certificate.

By default, Lightsail performs health checks on your instances at the root of your web application. The health checks are used to monitor the health of the registered instances so that the load balancer can send requests only to the healthy instances. To customize where your health checks are performed, see Configure health checks on your instances.

You can also enable session persistence for your users. This is helpful if you’re storing session information locally in the user’s browser. For example, you might be running a Magento e-commerce application with a shopping cart on Lightsail. If your users add items to their shopping cart and then end their session, when they come back the shopping cart items will still be there if you turn on session persistence. Learn more about session persistence

When to use load balancers

You should use a load balancer when you have a website that has occasional spikes in traffic or hosts content that can create a lot of load on an instance when many visitors are using it at once. For example, if you have an image-heavy website, you can load balance the image requests with the other page requests. That way, your pages load faster and your users are happier.

You can use a load balancer to create a highly available website. High availability refers to how long your website or application stays up over a given time period. If you have ever experienced a site outage, then a load balancer might help you have more uptime. You can use a Lightsail load balancer to make your application highly available by adding target instances that are distributed across multiple Availability Zones.

Fault tolerance is a related concept. If your site continues to function even after one of your instances or your database fails, it is considered tolerant. A load balancer can help you create a fault tolerant application or website.

Recommended Lightsail applications for load balancing

Not all Lightsail applications need load balancers. If you decide to create a load-balanced application, you must configure your application first. For example, to prepare a LAMP stack application for load balancing, you should first create a centralized, dedicated database on a separate Lightsail instance for all the target instances to read/write from. You might also consider sharing the file system, depending on the type of application you want to deploy.

We have blueprint-specific instructions in the following topic: Configure your instances for load balancing.

Get started using load balancers

You can create a load balancer using the Lightsail console, the AWS Command Line Interface, or the Lightsail API.

You must also configure your instances for load balancing.

Once you create your load balancer and attach your configured instances, you can enable HTTPS using the following topic. Set up HTTPS for your Lightsail load balancer