Part 9: Load Balancing with Argo Tunnel

January 8, 2020 - Reading time: 6 minutes

Our project shows us that a lot is possible with a single Raspberry Pi and Cloudflare.  However, we can use Argo Tunnel to easily scale up multiple origin servers as needed.  This can be done by adding a single line in the Argo Tunnel config file we created earlier!  You can read more about this here: https://developers.cloudflare.com/argo-tunnel/reference/load-balancing/

 

In our case, we’ve configured 3x identical Raspberry Pi with Nginx, SSL, Argo Tunnel, and Bludit.  We then added the lb-pool parameter in our config.yml file as follows:

 

hostname: makerflare.com

url: http://localhost:80

lb-pool: makerflare_lb_pool

logfile: /var/log/cloudflared.log

 

Our Argo Tunnel Dashboard shows we have 12 tunnels (3x Raspberry Pi, each with 4 persistent tunnels) available in our load balancing pool.  This means Cloudflare’s load balancer will intelligently distribute visitor requests across all three Raspberry Pi web servers.  This allows our site to handle more simultaneous visitors.  

 

Additionally, we can set “Session Affinity”, which places a cookie on visitor machines allowing them to access the same cluster node for a defined period of time.  This ensures their requests in any one session don’t bounce around between cluster nodes.  

 

Furthermore, Argo Tunnel also allows us to easily deploy more web servers in different geographical locations, and on different networks without any further connection.  This makes our site scalable and also highly available.  It’s so easy to spin up new instances of Argo Tunnel with hardly any additional configuration!  For example, we can have Raspberry Pi web servers hosting the same content in both Singapore and San Francisco.  The content remains accessible if either office is unavailable. 

 

Recap:

We’ve learnt how Cloudflare load balancing and Argo Tunnel can easily allow us to scale our site to handle additional visitor traffic while also being highly-available.  

About

A playground of creativity that combines Cloudflare technology with hobbyists.