Hello! I am running Moodle on Elbrus platform (OS Elbrus Linux 6.0, Moodle 3.10.4, PostgreSQL 11.9, Apache 2.4.41, Nginx 1.12.0). Now I'm trying to run a cluster, but I don't quite understand how to do it properly. I have two machines with Moodle and Apache installed , /moodledata is shared on NFS partition. I want to use Nginx on the third machine as a load balancer.I have configured the load balancer on the third machine, but when I open the page in the browser only html is visible, no styles or js. If I open the page on the first or second machine locally,everything is displayed normally. Do I understand correctly that I need to run another instance of Moodle on the third machine to handle the frontend? If yes, how to configure Nginx correctly in this case?
NGINX on the 3rd load balancing server doesn't need to have Moodle installed or access to any of the data roots. You configure a new site in NGINX with the exact same hostname and then when configuring your proxy_pass directive, set it against an upstream group that contains your two app servers. Also configure the "host" header to be passed to the upstream servers.
You should also have SSL configured on the NGINX server but then you can disable it on the app servers and let the NGINX server do SSL offloading. In this scenario, your traffic to the upstream servers would be over port 80 not 443.
On the app servers, have Apache or NGINX configured to listed on port 80 for the exact same hostname as configured in NGINX.
In the config.php of both Moodle instances, set the "$CFG->wwwroot" value to "https://[server name]" as you have configured it in NGINX/Apache. Also set "$CFG->sslproxy = true;" so that Moodle knows to take a port 80 (http) request but return a port 443 (https) response.
If you are still having issues, take a look at the source of the page in your browser to see if there are any issues in the console or what the address is trying to return for the css/js assets. It might show you it configured on a different port, or host/IP.
Could you tell us more about your application? What is the purpose of clustering? What kind of loads are expected? What are the nodes, dedicated machines or VPS? What are their specifications? What about the DBMS?
Quizzes are very resource intensive on both the app and DB servers and if you don't have the speed, it's going to be slow.
The absolute fastest you would get is a single host running both Web and DB, properly configured, and with minimal users. If in that scenario you are still seeing poor performance than there is no way to load balance your way out of it.
Once you exhaust the capabilities of your single host, (either due to concurrency, RAM, CPU, etc), then you start to look at scaling vertical/horizontal.
If it's purely for a hypothetical, testing, or learning, then none of that matters compared to if it was for a production instance.
So https://en.wikipedia.org/wiki/MCST is a SPARC but not Sun Microsystems https://en.wikipedia.org/wiki/SPARC ? Didn't find it in the https://en.wikipedia.org/wiki/List_of_Linux-supported_computer_architectures. So MCST has an own team of Linux kernel developers porting the OS to Elbrus?
On the number of simultaneous users, two measurements come up in this forum. The first one is the number of "users for whom the server is actively doing something" at any instant: https://docs.moodle.org/en/Performance_FAQ#How_do_you_define_.22concurrent_users.22.3F, which is a bit too theoretical for the typical system administrator. The more common one is, how many candidates can enter a schedules MC exam at the same time - the "time" is nowhere specified, but depending on the examination setup could be anything between a couple of seconds to couple of minutes.
On clustering, I saw that you've discussed the topic in the Russian forum Установка и настройка Moodle в кластере на платформе Эльбрус and was aware of the documentation https://docs.moodle.org/en/Server_cluster. And your settings are documented in Настройка балансировщика нагрузки в кластере.
Whatever the measurement you used "100 simultaneous users" sound disappointing for a three machine cluster. As Alex has already suggested, have you tried a single machine setup for comparison? What is the https://moodle.org/plugins/report_benchmark result of a single machine configuration? Did you go through the https://docs.moodle.org/en/Performance_recommendations ?
The benchmark results are indeed disappointing. (I assume that you did both on single, hardware servers running LEMP natively.) Compare the numbers others have reported in https://moodle.org/mod/forum/discuss.php?d=335357. (The benchmark was revised in between, I don't know its implications.) You may be interested in the results I've got on various Raspberry Pis, http://www.syndrega.ch/blog/#benchmarking-moodlebox-on-different-raspberry-pi-models.
I too don't think "tuning" will improve much since the CPU is the weak point. Whether those machines are suitable depends on the assignment you have: Have you been given a certain load which you must reach or is this an academic exercise on how to build a Moodle cluster?
My point in mentioning the Raspberry Pi was to point to MoodleBox https://moodlebox.net/ as an example of how to get the maximum out of a tiny computer. Please note that MoodleBox is a separate project from Moodle, with its own community at https://discuss.moodlebox.net/.
I'm surprised that the network becomes the bottleneck in a Raspberry Pi cluster running Moodle. Comparing the models Pi 2 Model B, Pi 3 Model B, Pi 3 Model B+ and Pi 4 Model B and not talking about the raw power rather which component will peak first in a Beowulf type cluster of load balancing Pis, I expected it to be either the processor or the SD card. I could be wrong, perhaps the network mounted moodledata/filedir makes a difference (in addition to the database and session files, which have to travel the network).
Could be a geeky experiment.
You are right, it is the network mounted moodledata/filedir and DB server responsible for the apparent slowness. I used haproxy on one Pi for the load balancer, 2 or 3 Pi's as web servers running Moodle, one Pi running the database, and one more Pi running ntfs. The slow down compared to running everything on a single Pi, comes from all the data having to travel over the 100Mbps Ethernet port. Using the same basic system layout, my Odroid cluster is noticeably faster simply due to each SBC having a ten times faster 1 GB Ethernet connection.
Due to the newer CPU and faster 1 GB Ethernet port of the Pi4's I would imagine a cluster comprised of just Pi4's would work as well as the Odroid cluster. In fact, a Pi4 performs well enough that I am using one as my current development server. I will also probably use a Pi4 to replace my current home server, if and when, it dies and needs to be replaced. It's pure economics. The old server at the time I built it, was almost $3000.00 whereas an eight GB Pi 4 only cost me about $80.00.
Replacing a $ 3000.- machine with a $ 80.- micro? Madness!
@all, Back to Moodle, the overhead in clustering is quite heavy. In addition to the moodledata/filedir there are all sorts of caches, temporary data, session files in subdirectories under moodledata - well documented in https://docs.moodle.org/dev/Server_clustering_improvements_proposal for the benefit. I think to practice and compare results, Raspberry Pi is a good standard node. (Hint to OP ;) )