When we moved our PowerSchool instance to a local install, we had to decide on how to do load balancing. One option is to buy an appliance.
I usually try to find ways to save the district money without taking on technical debt. I thought there must be a better, cheaper option. I decided on taking a decommissioned server and building our own load balancer.
Here were my requirements:
- Handles SSL/TLS connections
- Auto-redirect http:// to https://
- Do at least some caching
- Load balance using ‘sticky’ sessions
I decided on Nginx to handle the majority of the work. It’s a fast, reliable web server. SSL was easy enough, redirecting from http to https was also trivial. Caching was tricker, I had to be deliberate on what url patterns nginx caches.
There were a few options out there for load balancing, but haproxy seemed to be the quickest and easiest. On first page load, it gives the client a cookie that ties them to one of our app servers. On the next request, haproxy knows where to send them.
Sticking it all together⌗
Nginx is the first application a client talks to. The first layer stripped back is SSL. Then nginx handles the redirect and caching. It then passes the request off to haproxy. Haproxy points the request in the right direction.