[pulledquote]Moodle is becoming increasingly popular at my current school. While this is great, the server is starting to feel sluggish. I wanted to find out how much further I can take my current hardware and how much strain Moodle actually place on my server. This is why I have decided that October would be… Oktobertest for Moodle! Here are 3 ways that will help you find out if your server can cope with the demands you place/want to place on it.[/pulledquote]
Note: This is by no means supposed to be a definitive guide to load testing. It is an introduction to what can be done to ensure a Moodle installation can cope with a specific number of simultaneous users. It is aimed at Moodle admins who haven’t really done load testing before. Be careful, load testing can crash your server and you could get in trouble with your host company – always check with them first.
Why is Moodle so demanding? A look under the hood
Warning – what follows is a very simplified version of the truth, but close enough for jazz.
Moodle is a very powerful, but demanding web application. It is basically a collection of files saved on a hard drive and data from a database that get pieced together into a webpage for every click a user performs. For example, if a student visits a Moodle homepage, then a course page, and then posts a forum discussion, a total of 7 webpages will have been created (homepage > login page > course page > forum page > new post > post discussion > return to course page). For every page that is created, it is necessary for the server to go and collect the correct files, call the database multiple times, and also ‘write’ data to the database. The more users visit the site, the more pages need to be generated, the more strain on the server. If you follow the simple example above for a class of 30 students, 210 pages need to be generated in a very short period of time. It is also important to know that not all parts of Moodle were born equal and some of Moodle’s popular modules, such as ‘Quiz’, put more of a strain on the server than other modules such as ‘page’ or ‘URL’; This can be a real problem if your server cannot cope with a class full of students taking a test at the same time.
Why you should test
In short, to prevent alienating teachers and students. A lot of people use Moodle for work/school related activities, at my school alone over 800 people. I am prepared to take a risk here and say that most of those people would rather do something else than be on Moodle. As a Moodle administrator, I thrive to ensure the server is as fast and reliable as possible so that people can go about their business swiftly, and this is made possible by testing different scenarios, with specific numbers of users. I test to find out:
- how long it takes to perform a specific task, for one or multiple concurrent users
- how many people can use Moodle at the same time to perform a series of tasks, and still have a usable (read fast) system
- how much RAM, CPU, bandwidth, etc. is used during a test, and see if I am close to the limits
- if I need to upgrade my hardware/hosting package and when I might need to upgrade
What to test
As you are testing your Moodle installation, you will be recording the vitals of your server, such as CPU usage, RAM, disk input/output, bandwidth, SQL usage, etc. to zero in on possible bottlenecks (check this useful blog post on server monitoring). To get meaningful results from your testing, you’ll want to have a testing strategy that mimics real world usage as much as possible. In order to achieve this, you might want to try and have a look at your Moodle logs. Here are a few rules that I try and stick to when testing:
- test a mixture of activities
- some that are database intensive e.g. chat
- some that are disk intensive e.g. download large files
- some that are CPU intensive e.g. quiz
- add randomness to the test, if the tool allows to do so. For example apply some random ‘waiting’ time between clicks
- test a mixture of accounts (teacher, admin, student) – not always able to do this
- if on a ‘live’ server, perform the tests when there is little to no use e.g. 3AM for me
- repeat the same test several times, at different times of the day. This is especially important if you are testing on a ‘live’ server.
Tools to test Moodle
This post offers only a short introduction to the load testing tools and I have listed them in order of difficulty to use.
Tool 1: iMacros extension
iMacros is an automation tool provided free of charge by iOpus. It is not meant to be a load-testing tool but works fine as one. There are free add-ons for Internet Explorer, Firefox and Google Chrome. I personally use the Firefox version, as it’s available both for Windows, Mac and Linux, and is more powerful than the Chrome version.
iMacros records your web browsing activity so that you can later simulate the actions of a real Moodle user, all automatically. For example, you start up Firefox and set iMacros to record. You go about your daily business on Moodle as normal (e.g. login, view your course, add an assignment, answer some forum posts and logout), iMacros keeps a record of everything you click on during your session, including all the forms that you fill in until you press ‘Stop recording’. Those steps are saved in a macro, which you can then play back later by opening that macro. This means that you can press the ‘play’ button and Firefox will repeat all of the steps that you did during your session, without any more interactions from your part, thus automatically simulating the web browsing activities of a Moodle user. You can ‘loop’ the action to repeat it automatically as many times as you like.
I use iMacros to record simple tasks, for example:
- Login > View course > View resource > Logout
- Login > View course > View directory > Logout
- Login > View course > Post to forum > Choice > Logout
- Login > View course > Take quiz > Logout
- Very easy to use for simple workflows (e.g. login, view course)
- Gentle learning curve
- Exact replica of what a real user’s browsing experience is like
- Excellent support in the form of a vibrant community and wiki
- Macros are portable and can be saved/run on multiple computers, from within or outside your network
- More demanding workflows require to dive into the code
- Limited number of simultaneous users, unless macros are run from multiple computers
Tool 2: Loadstorm
Loadstorm is a web based load testing service. Their business is to simulate multiple virtual users simultaneously navigating a website, following a pre-recorded scenario. It is similar to iMacros in that you can record your web activity to play later (scenario), but you have to use Loadstorm’s interface to do it. Although it is not as intuitive as iMacros, it is still simple enough to use to record simple workflows. Loadstorm is free to use for up to 25 simultaneous virtual users (forever, not just once), which is quite handy considering it is quite close to a ‘regular’ classroom size. The 25 user-limit is usually enough to test sites on shared hosting, and bring the server down. You can purchase extra virtual users to test larger sites. To date, I have not yet needed to purchase additional users as Loadstorm often runs promotions whereby you get free users if you follow them on Twitter, or like them on Facebook. I must say that their service is top-notch and will be purchasing when I run out of users.
- Can be used on any device with a web browser and access to the Internet
- Easy to use for simple workflows
- Company behind the product provides excellent support
- Servers based around the World, mimics real-world usage for students accessing Moodle from home
- Relatively gentle learning curve
- Pay-for service if you want to test more than 25 concurrent users
- Some more complex workflows are difficult to set up (e.g. multiple quizzes)
- Doesn’t work behind some firewalls
- Web based service so there is some extra latency involved
Tool 3: JMeter
JMeter is a fully-fledged load and performance open-source software by the Apache foundation. It is much more powerful than the other tools mentioned (although I suspect Loadstorm is actually based on JMeter) but also has a much steeper learning curve. Luckily, an excellent JMeter script generator was created and shared by the good people of the Open University UK (download it here). Without this tool, it would be rather difficult to create scripts (scenarios) to test your Moodle installation. This tool will help you generate users, and get those users to post to forums, participate in chat sessions and take quizzes. Nothing stops you from adding to the generated script, should you want to add more steps to it. Should you wish to dig further into JMeter, I would strongly recommend you to read the excellent ‘Apache JMeter‘ book by Emily H. Halili.
- Java based, so can be used on all platforms
- Scripts are portable – test from within or outside your network
- Extremely powerful
- Steep learning curve
What tools do you use to load-test Moodle? Please feel free to share in the comments section.