Energy efficient Moodle servers: Ideas, examples, ..

Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
回帖数:38
Particularly helpful Moodlers的头像 Translators的头像
Hi all

We know the old design principle of building a high-power server: "Buy the biggest server your budget allows!" Servers build accordingly get accumulated over the years and, as to be expected, melt the ice caps.
伤心

Has anybody put any thought on building energy efficient Moodle servers or have experience in the subject. Your ideas, examples, etc. are welcome!

平均分:Useful (3)
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Le Minh Tuan -
I think we can collect the old server, serperate moodle and put it in the server. In my case.
- I have 3 old servers IBM 3550 M4 model 2013 with 2 CPU/server, 192 GB RAM DDR3 / server, HDD sas 10K
- Install EXSI and create VMs on these servers: 6 web server (4CPUs, 16GB RAM), 3 mariadb database (4CPUs, 16GB), 3 MoodleData (4CPUs, 16 GB RAM), 2 maxscale (4CPUs, 16 GB RAM), 1 redis cache (4CPUs, 16 GB RAM), 2 Nginx loadbalance (4CPUs, 16 GB RAM).
回复Le Minh Tuan

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi

Yes, reusing old servers is one possibility. But it is not that simple. The old server might consume more energy than the new server. Even then, one has to take the "gray energy" or the https://en.wikipedia.org/wiki/Embodied_energy in to account. The only clear case is, if the old server is running any way, add more site to the old server rather than buying a new server.

I was thinking along some figure like "number of Moodle users per Watt". I know, there is no standardized "Moodle user". But even for the super computers there is the benchmark "Mega FLOP per Watt" https://www.computerworld.com/article/2535438/how-power-hungry-are-the-top500-supercomputers-.html. Why can't Moodle find a something comparable?
回复Visvanath Ratnaweera

Ri: Re: Energy efficient Moodle servers: Ideas, examples, ..

Sergio Rabellino -
Particularly helpful Moodlers的头像 Plugin developers的头像
For HPC it's simpler to think a benchmark, you run the most compute-hungry algorithm (e.g. distributed linpack) on a bunch of nodes for a while, then put a watt-meter on top of your PDUs then the count is straightforward.
With moodle, you should push up user requests to the max, but which user pattern is the right one ? which is the acceptable response time of your moodle ?
Then stay at max-ops for a while and then with a watt-meter on moodle's systems PDU you can evaluate.
But,but... how you push your moodle to the max-ops has a relevant impact and probably we'll go into a hell-of-posts on this. 微笑
回复Sergio Rabellino

Re: Ri: Re: Energy efficient Moodle servers: Ideas, examples, ..

AL Rachels -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
Another point is that you need someone who cares about this enough to spend the time to develop something. I can remember using an old "load test" by Sam Marshall that has seemed to "disappear." It indicated my salvaged 66MHz CPU server could support a "whopping" 4.99 concurrent users.  😁 That's what convinced me to let only four students at a time start a quiz. 🤨
回复AL Rachels

Re: Ri: Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Sergio

Agree. It is easier to design a benchmark for HPC, there is no need even. Everybody seems to be focused on the LINPACK benchmarks. The Moodle crowd is very diverse, and they care only about their particular scenario(s). The teacher wants to know, "Will Moodle stand my exam tomorrow?". The school administration wants to know, "Will Moodle throw 'Connection refused' again during the peak hour?"

On which "user pattern is the right one?": If our friends in the economy department came up with the consumer price index, why we the benchmark obsessed Moodlers can't?
;)

On "how you push your moodle to the max-ops": There are already many tools in the Moodle ecosystem:
- https://docs.moodle.org/dev/Load_testing_Moodle_with_JMeter
- https://docs.moodle.org/en/Test_course_generator
- https://github.com/moodlehq/moodle-performance-comparison
and many more.

In fact there is the plug-in https://moodle.org/plugins/report_benchmark. Very easy to use. The problem is, it gives you 10 numbers on system performance without ramping up Moodle. And the results are in seconds, not in "Max. number of users" or such thing in the sense of cut-offs.

Hi AL

Yes, Sam Marshall's "Perspective" https://moodle.org/mod/forum/discuss.php?d=57028 was the measure in the old days. Surprisingly it gave the result in "max. number of simultaneous users". But how that formula was derived is anybody's guess. Same with the Howard's index. (Was it 20-50 users per GB?)

About developing something, I don't think that is even necessary. One just have to define a procedure making use of the many tools that are already available, finally giving a cut-off number of users for a specific (market basket) scenario. And that number will be divided by the Wattage to get the equivalent of "megaflops per Watt"

回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brendan Heywood -
Core developers的头像 Peer reviewers的头像 Plugin developers的头像
This is close to my heart and to many people in this day and age. Some thoughts:

1) If you are still thinking in terms of a big box or a little box then you are asking the wrong questions. At times you will be over specc'ed and at other time you wan't handle load. You need to move to a more dynamic stack which scales on demand so you can walk the knife edge of never using more than you need but always having enough for your needs.
2) Roughly speaking if it is cheaper then it consumes less power. For example AWS and every other cloud provider wants you to actively game the system to use their services differently in a way which is cheaper, and you should play that game. But playing this game can be very complex so see below.
3) Make this a business problem not a technical one. For example if you are self hosting then you need a lot expertise to do so, and do so efficiently. If you outsource that to a Moodle partner (I'm with Catalyst IT) and lets say you have a fixed price per year, then this creates a very strong financial incentive for us to run our hosting as efficiently as we can across our fleet, and we are very aggressive on this front. Most performance / efficiently improvements are not financially viable for a single organisation to tackle themselves until they get to a very large scale, so join forces with someone aligned the same way.

As an aside, I really like the idea of report_benchmark, but in practice it needs a big rethink to give some better and more fine grained metrics in more useful units.
回复Brendan Heywood

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Brenden

Thanks for the response. Yes, I know that you are busy in this field.
眨眼

To you points:
> 1) If you are still thinking in terms of a big box or a little box then you are asking the wrong questions.
I get your point. If the Moodle instances are packages one per "box", it'll never be energy-efficient. Because the "box" is decided on the _peak_ load (at best), at normal load it is still burning the same power.

> 2) Roughly speaking if it is cheaper then it consumes less power.
> 3) Make this a business problem not a technical one.
Agree. A (Moodle) hosting business, i.e. running many Moodle instances, will automatically utilize the unused power of some customers to feed the others. As you say, they have the know how, and above all, have the interest not to waste hardware thereby automatically conserving energy. I can't deny that. In fact, I imagine Moodle Cloud to be a strong example of this effect. Imagine, every Moodle Cloud customer running his own box. Then Moodle will challenge the crypto miners in global warming.
伤心

But still there is a large segment of Moodle servers running in DIY mode. My OP is addressed to them. As many discussions in this forum would show, and discussions I'm having outside the forums, many institutions starting Moodle have exaggerated ideas of their usage. The irony is, for many institutions (in the West) the energy (and infrastructure) bill is still very small compared to the salaries. So they go for the "best server you can buy". The intention of the OP is to show them what modest and small boxes can do, as an argument against this kind of thinking.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Leon Stringer -
Core developers的头像 Particularly helpful Moodlers的头像

Does the cron come into this? Cron tasks can do all sorts of things up to every minute, database changes, file changes, network requests, all contributing to load.

One would expect most core tasks to be fairly well tuned but it maybe there's scope to reduce the frequency of some of these to reduce load (I haven't investigated this).

Then there are plugins which may also have tasks but where perhaps fewer people have looked at the code or examined the performance. I've seen one report of potential for tuning in mod_customcert (#387), this task is run every minute by default. In the absence of any improvement at code/query level this could perhaps be run (for example) every two minutes presumably with a resulting reduction of load with minimal loss of functionality.

回复Leon Stringer

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Oh No! Nothing should be excluded, if they lead to saving energy.

I haven't looked carefully enough at how the tasks are scheduled and sent to the background after Moodle went through a major overhaul in this central topic. (Yes, it is the pulse of a Moodle site.) So I can't say whether spreading the individual tasks differently will lead to less load. The general topic though, optimizing the application, always applies. But I excluded that, because that would mean code changes, which is beyond what I envisaged.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Leon Stringer -
Core developers的头像 Particularly helpful Moodlers的头像

Here's another one I've recently run into, file storage wasted by unwanted/unused PDFs (MDL-71909).

If you have the core assignfeedback_editpdf plugin enabled – the default setting – then a PDF is created for every assignment submission even if Annotate PDF isn't selected for that assignment. Worse, if the submission doesn't have a PDF equivalent (such as submitted media files) then a blank PDF is created. Worse still, because the blank PDF is timestamped each one has a different content hash. So you can end up with many unused (and useless!) PDFs in Moodledata which could all be blank.

You can disable this plugin to stop it happening (assuming it's not used for any assignments across the site) – but the submissions still get appended to mdl_assignfeedback_editpdf_queue and not removed (because the plugin is disabled). If you ever subsequently enable the plugin the queue gets processed (by \assignfeedback_editpdf\task\convert_submissions) and you get as many PDFs as there have been assignment submissions (excluding any submissions or mod_assign instances that have been deleted).

So with the no-code-change view I'd recommend disabling this plugin unless this assignment feedback type is actually being used.

回复Leon Stringer

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Ugh. Had a skirmish in the not-too-distant past, Has Ghostscript something to do with a half a million lock files?, which I'd prefer not to repeat. In the specific Moodle site though, the teachers can't live without this plug-in because they've developed an examination corrections procedure based on image formats!

Still, something we need to keep an eye on, if we are to reduce the server load.

回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Just to close that chapter on MDL-71909. It has been fixed since 4.1.6 LTS, 4.2.3 (yesterday). The cause is removed. One has to clean the bloat on their own.

P.S. @Leon, thanks for your cleaning script. I am yet to upgrade to those versions yet. And my major sites (two) are still 3.9 LTS.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
@everybody, so that this thread won't fly under the radar.
眨眼

Recently I did the following experiment. Not an experiment really, a real situation without rehearsals. (You see my trust on RPi.)

For 40 participants in a live class, 42 counting the two instructors, I ran a JazzQuiz. The questions were basic single-choice MCs with 4-5 solutions. For each question they had 60 sec and 10 sec pause in-between. 37 have actively participated.

Here are the Munin graphs:







I asked the participants whether they have experienced any sluggishness. The answer was No.

Hardware: Raspberry Pi 4 B 4G
Software: LEMP. RaspberryPi OS Lite Debian version: 11 (bullseye), Nginx, php-fpm, MariaDB default packages. Fresh, clean installation somewhere May 2023.
Network: All are in a tightly coupled academic network a couple of 100 km apart. They have minimum 100 Mbit/s to the network where the RPi is. That is from their routers. An unknown number was connected to their routers via wi-fi, which is likely to be the network bottle neck.

The site still runs for the same very active 40+ users. In normal usage, not during live sessions, they don't even scratch the resources.

You must know its Wattage. I've seen numbers like 5 W(!) in the Web.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

AL Rachels -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
That's pretty amazing, I think. As far as wattage, I don't think the average Pi uses as much as most people might think. I run all of mine on three Anker USB chargers where each charger has 10 USB charge ports. The individual ports are rated at less than that of the correct Pi charger, but the Pi's have all performed without a complaint. I even run my three new Orange Pi5's on the same chargers. The Orange Pi power supply is rated even higher than the one for the Pi 4, and again, they've now been running for a few months without any problems. I have even added a M.2 256GB SSD to each Orange Pi and they continue to run without any hiccups. It is rather nice when I see something like I did yesterday where it was showing me the performance of each of the eight cpu's!
 
I see you had a rather large temperature spike at the time. Do you have any cooling added to your Pi? I think the Pi supposedly has temp throttling so I don't think it would be a problem. Anyway, back when I bought all of mine, I got a bunch of passive aluminum coolers and do not ever remember going above about 58°C when I was testing. I recently even found some slimline coolers made of copper, but have not installed any of them yet as the aluminum ones seem to be doing such a good job.
回复AL Rachels

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brett Dalton -
Moodle HQ的头像 Particularly helpful Moodlers的头像
Rpi 4 can draw up to 15W the Pi5 is higher than hqn that.  if you don't have any active cooling they are likely to throttle.  The will slow down at 80 deg C and even more if they hit 85 def c. Although some sources say 60deg C it will start to soft throttle.  To really get the most out of  the hardware add a heat sink and/or a small fan to the case 
回复Brett Dalton

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi AL

Yes, the power of RPi 4 B as a server is amazing.

I missed a better occasion to monitor the load. The earlier live session has even more "action". I say load averages of 5 in htop. But no recording, a firewall blocked the monitoring traffic.
伤心

CPU temperature. Yes, that is the place where I should have been more cautious. The Pi 4 B has these two tiny "heat sinks", these may be 20 m square Aluminium fins, pasted to the chips. No fans, I don't like them. And worse, it is in the standard black Pi 4 case made of plastic and inside a closed rack cupboard. It is in a corner of a larger office space which has air conditioning. The history is that the RPi was initially a MoodleBox. So I didn't want to lose the wi-fi signal by putting the RPi in a metal case. I changed it last-minute to a regular LEMP server, manually installed. Had not many options in "housing" the server.

Yes, the graph shows that the CPU touched 80 C, the throttling temperature. I will give it a heavier heat at the next chance.

@Brett, according to the specs a RPi 4 *can* draw up to 15 W since 3 A are recommended for the power supply. I wish, I had a proper Watt meter on site! I quoted what I generally see on the web. Once I thoroughly measured the consumption of a RPi 2, can't remember the numbers, but they were well below the specs. An important reason is as headless server I don't connect anything to the device other than the Ethernet. And the load is spurious as usual in this kind of applications - only the live class generate heavy load, otherwise idling.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brett Dalton -
Moodle HQ的头像 Particularly helpful Moodlers的头像
Ideal power is pretty low.  Around 3w or less from memory.   I doubt it would ever draw 15w, but if you had some other peripherals it might, a pi hat on or 2.  Larger PSU is always good for stability 
回复Brett Dalton

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Brett and all
 
On power consumption, it varies a lot among the models, say anything from 150 mA idle for R Pi Zero and 300 mA idle for the 3 series and higher for 4 or 5 series. Here is a sample measurement:
 
I'm interested at the low end, Pi Zero (2) W, Pi 3 A+ and, if it has to be, 3 B. The reason is that I can't depend on mains power at the site. So the plan is either a power bank to power the device or, even better, the USB of a laptop to power the Pi. The Pi is purely headless server, no USB devices, no Ethernet, no Bluetooth. Only wi-fi - at two interfaces - most importantly uap0 as a hot-spot, sporadically wlan0 as client to connect to the Internet through a personal mobile hot-spot. Ref. https://discuss.moodlebox.net/d/451-connecting-the-moodlebox-to-a-wifi-network

In this connection I must mention that the shift to 64 bit PHP in Moodle 4.2 put a stop to the 512 MB devices like Pi Zero (2) W or 3 A+.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

AL Rachels -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
Hi Visvananth,

I guess that explains the big temperature difference I see, yours is in a case inside a cabinet. My SBC's are all in open air, dog bone stacks of three, six, seven, and seven. Plus the two stacks of seven RP's are all diagonally about four feet to the left and three feet below a ceiling fan that was running all the time when I was doing my performance checks.

Went back and did some looking at old pictures from January of 2013 where I was running Sam's old test on the sever I had just built. My old 66MHz server supported a whopping 4.99 "concurrent users" with 100% success for each requests. My new 3.7GHz upped that to 54 "concurrent users" with 100% success for each request.

While the report generated was interesting, I found that the OS System Monitor was even more interesting to watch live while the test was running. Memory usage was almost a flat line at around 10% of 32GB in use throughout the test. However, Network History, both sending and receiving, appeared to look like a square wave of 24.0 KBps and 48.0 KBps, with 8.8GB total received and 406.2MB total sent.

Even more interesting was the CPU History. During the early ramp up stage of the test, I could see the hint of a couple of square waves when two of the CPU's where at about 49%, three others were in use at 3%, 11.1% and 20.0%. The other three were flat lined at 0%. During the rest of the test, I could see all the CPU's becoming more and more involved until occasionally, I was seeing all eight CPU's basically maxed out at 97% to 100%. Between attempts, CPU usage would drop back to 4% to 12% on three, with 0% on the other five. The timeline graph looked very much like a nice square wave.

I need to see if I can find the test file and put it back in use to see what a Raspberry Pi and Orange Pi performance looks like. Maybe a Jmeter test too! 😁
回复AL Rachels

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
AL, you have done some tinkering! Doesn't surprise me after seeing your micro-board computer racks!

Yes, some common load testing scheme would be nice to compare these boards functioning as Moodle servers. The stress-strain type of testing, for example what JMeter does, is the most obvious. But after I've noted that JMeter has (had?) different (old?) versions for Linux and (the latest) for Windows and the mess Java make with endless dependencies, I stopped experimenting. I don't see me going back there for some months!
回复AL Rachels

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brett Dalton -
Moodle HQ的头像 Particularly helpful Moodlers的头像
" Plus the two stacks of seven RP's are all diagonally " its amazing how much a small slope on the board will increase airflow via convection. Way back in the day I ran a lecture capture systems at a University. we had 6 dedicatited capture boxes in a rack which kept overheating. I bent the brackets so rather than flat they sat at a 30% slope and all their temps drops a full 20dec C with no other active cooling.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Germán Valero -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像 Translators的头像
Very nice work for a Pi!
How can you have 40 clients from a Raspberry Pi that can only support 20 simultaneous wifi clients?
Please tell us if you use a router, model, cost, setup...
Thanks in advance.
回复Germán Valero

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像

Hi Germán

Simply because that group of 40 was accessing the Pi through the wired LAN! In addition there were a handful connected through the wi-fi interface of the Pi configured as an access point, but only via SSH for monitoring purposes.

Maybe you were thinking of the MoodleBox, which has this ~20 user limit, if connected through its built-in access point. That is because of the power limit of the wireless transmitter in the Pi (hardware) and how the network driver of the wireless interface optimized.

If you want to go beyond that limit you need an additional access point. See https://discuss.moodlebox.net/d/60-connect-an-access-point-to-the-moodlebox/7.

回复Visvanath Ratnaweera

Data Centers Are Consuming Electricity Supplies - and Possibly Hurting the Environment

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Keeping the topic afloat:
Data center construction "could delay California's transition away from fossil fuels and raise electric bills for everyone else,"
回复Visvanath Ratnaweera

Re: Data Centers Are Consuming Electricity Supplies - and Possibly Hurting the Environment

James Steerpike -
Particularly helpful Moodlers的头像
Data centers certainly consume lots of power but if the alternative is millions of underutilized boxes running at homes, they are the best choice for the environment.

I guess average electricity prices around US 30 cents a kw/h. At that figure, a 10 w load over the roughly 740 hours a month will use around $2 a month of power. A Pi may use as little as 2 watts in active mode and so
a monthly bill of 40 cents. Most old boxes reconfigured as servers will use in the range of 50 to 100 watts and that is $10 to $20 a month.

I fire up remote servers if I want to play with something and a low spec 1 CPU/1 GB RAM costs between $1 to $6 monthly depending on the supplier. Allowing for their hardware, internet traffic, service support and billing, their power costs must be a fraction of the billed figure. Not surprising as well utilized servers are going to be more energy efficient than idle servers.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Eduardo Kraus -
Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像

Hello Visvanath and all Moodlers! 🌟

This is a fantastic and very important question, especially nowadays with the growing awareness of sustainability and resource optimization! When we talk about creating energy-efficient Moodle servers, we're entering a field that involves both hardware and software, but there's no way to remove significant parts of Moodle without affecting the ability of students to access Moodle pages.

So the solution is to prevent requests from reaching the server. And for that, a CDN is one of the most effective ways to reduce the load on your main server. They work as global distributors of your content, reducing the number of direct requests to the server and improving latency for users in different parts of the world. I have had a very positive experience with BunnyCDN, where I managed to reduce direct requests to the server by up to 90%! Check out this article I wrote on the topic, I think you'll find it quite inspiring: Optimizing Moodle Performance - BunnyCDN. 🌍⚡

In addition to a CDN, implement caching at multiple levels: browser cache, page cache, and application cache (such as Redis or Memcached). This drastically reduces the load on the server by allowing Moodle to load static content directly from the cache without needing to process everything again for each request.

Eduardo Kraus
Professor / Programmer / Passionate about Moodle / Innovation and new products

回复Eduardo Kraus

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brett Dalton -
Moodle HQ的头像 Particularly helpful Moodlers的头像

While CDN's definetly can massively improve performance and user experience if its not your infrastructure serving the content it is someone elses. Caches are definetly a critical part of any Moodle installation at scale and there are some economies of scale to be had here but I'd question them on the energy efficiency front.  Any caching requires large volumes of data to be held in memory, large NoSQL databases etc. I'd be really interested to see any specific studies on this.

回复Brett Dalton

Re: Energy efficient Moodle servers: Ideas, examples, ..

Eduardo Kraus -
Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像

Hi, Brett! 😄

You raised a very interesting point about the use of cache and CDNs in Moodle, and I’m excited about it!

First, it’s worth highlighting that although caches and CDNs use resources and require memory to store large volumes of data, the performance and energy efficiency gains they bring can be significant, especially in large-scale installations like Moodle. What many don’t realize is that the resource consumption of cache is actually much lower compared to the processing Moodle needs to handle when responding to all requests directly.

Imagine that without cache, each simple request to load an image (for example, via pluginfile.php or theme/image.php) has to go through several steps: opening multiple tables in the database, authenticating the user, checking permissions, and only then delivering the file. This not only increases latency but also adds a significant load on the database and the application server.

With cache in place, on the other hand, these static files (like images, PDFs, videos, etc.) are served directly from the cache, eliminating the need to query the database. This drastically reduces backend processing, frees up server resources for more critical tasks, and lowers energy consumption.

The use of CDNs and local cache reduces energy usage because the main server doesn't need to handle so many repetitive requests. This also results in a better experience for the end-user, with faster load times and less strain on the server.

Eduardo Kraus
Professor / Programmer / Passionate about Moodle / Innovation and new products

回复Brett Dalton

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi all

Thanks for your contributions. In fact they came from an unexpected corner. I always connect power consumption with the hardware. For example, a certain machine consumes so many Watts when idle and so many Watts when running at full throttle. Therefore my approach is to gather experience from production and simulated environments to estimate the size of machine needed for a specific case - not to buy exaggerated hardware. But that has a practical problem. Rarely the system administrator buys (or advices on) the future server. Either he rents space in an available data center or the (IT) management procures the equipment. So the "learned estimation" of a sys admin has no value.

But you have a point. Even when the machine is given, if one can reduce the strain on the machine for the same load, it'll consume less energy. That a layer of caching around the server would make it more efficient makes sense. By how much is the question. I read in these forums that, since Moodle serves individual web pages to the users, there are not many common content to cache. As a result the efficiency gain is small. Maybe the counter argument is that CSS and JS are the same. And during a synchronous on-line exam Moodle is probably sending the same content to many users. Still I'm interested to know how you measured the 80% in your report.

Virtualization has the same problem: Given a big iron machine how would it consume less energy if it is virtualized or containerized? I would say, virtualization and containarization allow to put more Moodle instances on the same hardware, rather than buying new hardware, that saves energy.

Admittedly all speculation, I don't have measurements on those things. Happy to see reports from you all. @Eduardo, perhaps an English translation of this report https://pt.linkedin.com/pulse/maximizando-performance-cluster-do-moodle-eduardo-kraus-g3tif is on the way.
眨眼
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Brett Dalton -
Moodle HQ的头像 Particularly helpful Moodlers的头像
Virtualisation definately can reduce energy consumption by eliminating or significantly reducing the overhead of idle servers assuming the VM infrastructure is properly utilised. There are processing overheads introduced but these are generally lower than the gains but an order of magnitude. Physical density also has the advantage of reducing server room size and subsequent cooling and phyiscal costs and embodied energy requirements. I've been invovled in the design of a few server rooms over the years and those costs are not trivial.
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Just by chance discovered this mini-server. I am yet to find another machine with better performance/consumption.

I was looking for a home server and found this: HP EliteDesk 800 G1 DM. It is a 20x20x3.5 cm thing. With 8 GB RAM and without disc goes for USD 80.- in the second-hand market. A colleague said he measured 20-50 W from idle to maximum power. It has a quiet cooling fan. More amazing thing is through BIOS you can stop it completely when idle.
 
Its Geekbench6 figures, 1160 (single core), 2252 (multi-core) surprised me. Installed Moodle 4.5 LTS on LEMP and got this (varies in the range 39..43):
 
附件 Screenshot at 2025-01-12 21-52-46.png
回复Visvanath Ratnaweera

Re: Energy efficient Moodle servers: Ideas, examples, ..

Marcus Green -
Core developers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像
Nice find. Looks like it is selling for between £60 to £100 from UK sources.
回复Marcus Green

Re: Energy efficient Moodle servers: Ideas, examples, ..

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像

HP EliteDesk 800 G1 DM and RPi 4B are worlds apart in server performance. I get consistently a score of only 220 with a RPi 4B 4G: https://moodle.org/mod/forum/discuss.php?d=464548#p1864999. Compare that to the score of 40 with the hp. (lower the better, in a logarithmic scale, so 40 is more than 5.5 times better than 220).