Performance and reliability are two key factors that contribute to a user being happy when using a website/app. They tend to not be forgiving when a website fails to load especially when it comes to browser extensions. If it doesn’t work the first time, they often uninstall.
I’ve written about how I’ve improved performance of my Weather Extension by making code changes but as the extension has grown, I’ve also had to scale the backend infrastructure to handle the additional load.
I was excited when DigitalOcean released load balancers for $20 a month. I was impressed with how simple it was to configure.
Load Balancer Key Features
- Simple to setup (Took me less than 10 minutes to setup)
- Improve availability (If a server goes down, the traffic will be routed to the other servers)
- Scalable traffic capacity
When setting up the load balancer to work with my Laravel Forge servers, I did run into one issue. The default health checks failed and my server immediately went down. After some help from Alex Bowers, who suggested switching the health checks from HTTP to TCP. This change fixed my issue (Thanks Alex!). He also suggested to run sudo ufw allow ‘Nginx HTTP’ , but my servers worked without running this command.
My current setup for my Weather Extension is a DigitalOcean load balancer with two droplets ($20/m and $10/m). The $20/m server acts as the database and cache server. As the number of users for Weather grows, I can now scale my servers horizontally with zero downtime!
Please leave a comment below if you have any feedback or questions!
Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LY, Weather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.
5 thoughts to “DigitalOcean Load Balancers”
Switching health checks to TCP did the trick for me. Thanks!! By the way, I think you mean ufw allow ‘Nginx HTTP’
Glad it helped! Good catch. I’ll update the post.
Just to elaborate on this problem a little bit. The DO load balancer is sending the HTTP “Host” header with a value of “cloud.digitalocean.com”. For us, this caused our Laravel application to fail routing the request, because we are using domain routing (Route::domain), and this domain was not in our list. Once we added a route for this domain, the problem was resolved. There are many configurations of HTTP server and web application that might cause a 404 error, 5xx error, or 30x redirect for an unknown domain name, which will cause the DO load balancer to mark the server as dead. You simply need to ensure your server can respond to a request for that domain.
Thanks for the information!