I’m going briefly explain how to load balance Learning Locker. Load balancing distributes requests across multiple servers to increase capacity, reduce response times, and improve reliability through redundancy. At Learning Pool (formerly HT2 Labs) we have previously utilised Rackspace and AWS to achieve load balanced solutions. You should feel comfortable with setting up and maintaining servers before proceeding.
For the purpose of this blog, I’m going to assume that you have three servers, two of which run LL (the LL servers) and the final one hosts Mongo (the data server). In order to load balance LL you will need your two LL servers to have access to the same xAPI documents, xAPI attachments, and Laravel sessions. Therefore, I’m also going to assume that you will store all of this on the data server.
To do this, you need to setup an NFS mount on all of your servers and then configure LL to use the mounted directories. You also need to configure LL to use the Mongo DB on your data server if you haven’t already.
Setup NFS Mount
Whilst I could explain how to do this, I’ve actually used Etel Sverdlov’s blog post to set this up on CentOS so please complete the steps listed there first (there is a similar guide for Ubuntu). I should point out that the NFS server will be your data server and you will have two NFS clients which will be your LL servers.
If you have followed the instructions for setting up an NFS mount exactly, your LL servers should now be sharing files in the “/mnt/nfs/home” directory. You now need to configure LL to use this directory, so I’ll leave you to do that… just kidding. You need to go “.env.local.php” in your LL installation (or “.env.php” depending on your configuration), set `LOCAL_FILESTORE` to “/mnt/nfs/home/uploads” and `SESSION_FILESTORE` to “/mnt/nfs/home/sessions”.
If you haven’t already, you also need to change the “app/config/local/database.php” file in your LL installation (or “app/config/database.php” file depending on your configuration). In particular check that your host and port is correct for connecting to Mongo DB on your data server.
Note: You need to do this for both of your LL servers.
Now add your two LL servers to your load balancer and that’s it. As long as you’ve installed and setup LL correctly and have everything running you should be good to go!
There are few “gotchas” that you need to look out for. For example, you need to make sure that your LL servers can communicate with your data server over port 27017 for DB access. You’ll also need to open some ports for the NFS mount. You also need to make sure that “uploads” and “sessions” directories exist inside “/mnt/nfs/home” and that the “user” running your server has access to read and write to the “/mnt/nfs/home” directory (if you’re using Apache this is likely to be the “apache” user). You can find out more about permissions from fideloper.
You could now go add more LL servers, or separate your xAPI documents, xAPI attachments, and Laravel sessions from your data server if you wish.
I hope you’ve found this helpful. As always, you can give us feedback via Gitter. If you come across an issue please see our documentation for troubleshooting. Now stop reading and go enjoy your load balancers!
Starting as a placement student in 2014, Ryan re-joined the Learning Locker team after graduating from Oxford Brookes University where he won the John Birch prize for the highest grade average in the University.
From his minimalist desk, Ryan leads the Learning Locker team and consults with people on all things xAPI to conscientiously craft products and services that sustain and evolve training and performance.
When he’s not swimming or injuring himself on the cricket field, Ryan enjoys playing funny (and usually inappropriate) games with his family.