Cloud Use Cases: How to build a scalable nonprofit website part 6

Configuring Scalability

Now that the basic site is ready, we’re going to add a second web server to share the load and make it possible to easily add future web servers to the architecture.

Create a second web server

First you’ll need to take a snapshot of your server to build a clone. The server should be the same size as the original server.

Once the new server is ready and you’re logged in, we’ll need to remove certbot in order to not have this server try and renew the TLS certificate when the time comes. Run this command carefully as it can cause a lot of damage if done wrong.

sudo rm -fr /etc/letsencrypt/renewal


sudo rm -fr /etc/letsencrypt/renewal-hooks


sudo apt remove certbot


Lsyncd is the service we will use to make sure the TLS certificate and the document root of your site stays in sync on all web nodes. It’ll only duplicate from the original server so any changes you make needs to happen there.

These next commands will be run on the original server.

Install lsyncd.

sudo apt install lsyncd

For this next part, it’ll be a bit easier as the root user so go ahead and switch to the root user using your sudo password.

sudo -i

We’ll be creating an ssh key pair for the root user. When doing this make sure you do not set a passphrase as lsyncd will use this key to access the second server.


Copy the public key to your second server.

ssh-copy-id root@

You can test that this key worked by trying to log in to the second server from the original. The key should be used automatically and you should not need to enter a password.

ssh root@



Still on the original server, create a log directory for lsyncd.

mkdir /var/log/lsyncd

Create log file.

touch /var/log/lsyncd/lsyncd.log

Create status file.

touch /var/log/lsyncd/lsyncd.status

Create configuration directory.

mkdir /etc/lsyncd

Now with nano, we’ll create a configuration file for lsyncd.

sudo nano /etc/lsyncd/lsyncd.conf.lua

Paste the below text into the file. Make sure you input the second servers internal IP address in the host field.

settings = {
        logfile = "/var/log/lsyncd/lsyncd.log",
        statusFile = "/var/log/lsyncd/lsyncd.status"

sync {
        source = "/etc/letsencrypt",
        host = "",
        targetdir = "/etc/letsencrypt",
        exclude={ 'renewal','renewal-hooks' }

sync {
        source = "/var/www/vhosts",
        host = "",
        targetdir = "/var/www/vhosts"

Restart lsyncd and ensure it is enabled to start on boot.

systemctl restart lsyncd && systemctl enable lsyncd

Now any changes you make to your sites document root should be reflected on the second server.

Add the server to your database and load balancer

Next you’ll need to add the server to your Databases access control list as well as to the load balancer.

Create a Golden snapshot

We’ll want to create a snapshot of the second server now that it is fully configured. This will allow you to more easily add new nodes to your architecture in the future.

Database backups

You’ll also want to take frequent backups of your Database. 

At this point your nonprofit site is load balanced across two web nodes with a High Availability master and slave database pair. You’ve configured lsyncd replication on the web nodes as well as scheduled snapshots. All you have left to do is customize your site and get to business! You may also consider using a monitoring service such as Splunk for easy remote monitoring of your site. This will help you keep an eye on your site and scale up when needed.

Leave a Reply

Your email address will not be published. Required fields are marked *