Moodle APC

This ‘Speed up Moodle’ series of 4 posts will teach you step-by-step how to optimise your Linux server for Moodle. It is aimed at beginner server administrators. If you find any mistakes or inconsistencies, please comment and I’ll rectify ASAP. This fourth post is about enabling APC, an opcode cache on your server, probably the easiest and most efficient step to increase server performance.

Continue reading

iMacros Moodle Logos

 

 

 

 

 

This post is part of the Oktobertest series. It is not meant to be a definitive guide on how to use iMacros. Rather it is a quick introduction to get Moodle administrators started with iMacros.

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.

Before you start following this tutorial, you should download the following:

 You might also be interested in reading this blog post, where you can find real world examples of iMacros macros (!).

 

Step 1: Open iMacros

 
  1. Click on the iMacros icon
  2. Open the webpage where you want to start your test from
  3. Click on the ‘Rec’ icon

 

 

 

Step 2: Start recording your macro

 
  1. Click the ‘Record’ button
  2. As you navigate your Moodle site, you will see that lines of text are added to this box, this is normal

Note: 3. Make sure that the ‘Click mode’ is set to ‘Auto’

 

 

 

Step 3: Stop recording when you’re happy

 
  1. Click ‘Stop’ when you have finished navigating your Moodle site
  2. The macro you have just recorded is called ‘current.iim’. I strongly advise you to rename it to something else, as every time you click the ‘record’ button it overwrites the ‘current.iim’ file (simply right-click on the file name to rename it)

 

 

 

Step 4: Try it

 

Try and play your macro just to make sure it works

  1. Click on the ‘Play’ tab
  2. Click on the ‘Play’ button (make sure the correct macro file is selected)
  3. Sit back and relax

If you want to loop your macro, take a look at this webpage.

 

 

 

Step 5: Load test

 

The macro you recorded will only mimic one user when you play it – hardly useful for load testing. To mimic multiple users at once, you will need to run multiple instances of the macro at the same time. Note that using different tabs will not work, you have to open each new instance of Firefox in its own window. (Ctrl N on Windows/Linux, or Cmd N on Mac). The only limitation is the amount of instances your computer can cope with in terms of CPU/RAM and bandwidth.

It is also possible to run the macro from command line or task scheduler. Procedures differ depending on the platform you use, so instead of me re-inventing the wheel, please check the following links:

 

LoadStorm Moodle

Note: this post is part of the Oktobertest series

Using this step by step ‘how-to’, you will be able to test how well your Moodle installation would be able to cope with a certain amount of users, using the loadstorm.com service. Whilst this is not a perfect representation of what real life usage of your Moodle installation would be like, it will still give you a very good idea of whether your system is good enough to run Moodle for your expected number of users.

Loadstorm is a web based load testing service. Their business is to simulate multiple virtual users simultaneously navigating a website, following a scenario that you pre-recorded using the loadstorm point and click interface.

This tutorial will show you how to test your Moodle installation with 25 simultaneous users, as you get 25 lifetime free virtual users with loadstorm. It also turns out to be the maximum number of students I have in my classes. If you would like to test with more users, you would need to purchase extra virtual users. I have found the service to be very good value and the support top-notch.

Warning – This tutorial is for Moodle 1.9 but the steps for Moodle 2.x are virtually the same.

 

Before starting this tutorial, you should download the following files:

 

Step 1: Upload test users to Moodle

 

 
  • Note: You must be logged in as an administrator
  • Site Administration > Users > Accounts > Upload users
 
 
  1. Choose file > Select file > Select the mdl_users CSV file you downloaded prior to starting this tutorial
  2. Do not change any of the default values
  3. Click on ‘Upload users’
 
 
  1. Check that the data has been uploaded correctly
  2. Do not change any of the defaults
  3. Click ‘Upload users’
 
 
  • You will get a report of all users that have been created. Click ‘Continue’
  • Note: Don’t forget to enroll those newly created users into the course you want to use for loadtesting.
 
 

Step 2: Upload loadstorm.csv file to your loadstorm account

 

 
 
 
  • Scroll down to the bottom of the page ‘Form Data Sets’
  • Click on ‘Upload data’
 
 
  1. Enter ‘Moodle users’ in the ‘Label’ box
  2. Click ‘Choose’ – Go and select the ‘loadstorm.csv’ file you downloaded prior to starting this tutorial
  3. Click ‘Upload’
 
 
  • Your file is now ready to be used
 
 

Step 3: Build a load test plan

 

 
  • In the ‘Build’ tab, click on ‘Add plan’
  • A ‘plan’ is a collection of ‘scenarios’ in loadstorm. More on this in the steps below
 
 
  1. Use a name that you can easily understand, as you might use many plans in loadstorm
  2. Again, your description should be as detailed as possible
  3. Click ‘Save’ when you’re happy with your form

Note: You can always edit the name & description of your plan

 
 

Step 4: add a scenario to your plan

 

 

A ‘plan’ is a collection of ‘scenarios’. A ‘scenario’ is a series of steps that a virtual user will follow on Moodle. For example, you could have one scenario where a user logs in, looks at the homepage and then logs out (scenario 1); Another scenario could be a user logs in, visits a course, answer a quiz and then logs out (scenario 2). The more scenarios you have in a plan, the more realistic your load testing will be. You can then assign a weight for each scenario so that it further ressembles how Moodle is actually used in your organisation. For example, one could argue that scenario 1 mentioned above would take place a lot more often than scenario 2. You could set a weight of 90 to scenario 1 and 10 to scenario 2 to reflect that.

For the sake of simplicity, we will only create 2 scenarios in this tutorial.

Scenario 1 with a weight of 40:

  • User looks at the homepage
  • Logs in
  • Downloads a 500KB resource
  • Logs out

Scenario 2 with a weight of 60:

  • User looks at the homepage
  • Logs in
  • Downloads a 500KB resource
  • Views a forum
  • Answers a forum post
  • Posts a blog post
  • Logs out

Click ‘Add Scenario’

 
 

1 & 2. Be as descriptive as possible
3. Assign the weighting you have decided to allocate
4 & 5. This is the minimum/maximum amount of time a virtual user would wait between steps (or ‘clicks’ in the real world). The actual time will be picked randomly by loadstorm for every step and every virtual user, between your chosen minimum and maximum values. If you want to put maximum strain on your server, you should try and keep those values as low as possible.
6. Make sure the correct CSV file is selected
7. Leave both boxes ticked so that your test is as close to real life as possible
8. Click ‘Save’

 
 
  • Check that all the options are correct and click ‘Add step’
 
 

Scenario 1, action 1: Visit the homepage

 

 

Warning: If this is your first time using loadstorm you will need to verify your server using the ‘Add a new server’ link. As I have used it before I cannot show you how to do that but there is a good tutorial at http://loadstorm.com/load-test-servers

  1. Leave this as ‘/‘ if your moodle is accessible via an address such as http://www.mymoodle.com. My Moodle installation is accessible at http://www.vleteacher.com/version19 hence the need for me to add ‘/version19’
  2. Select the correct server. Please see the warning note above if it is the first time you are using loadstorm
  3. Click ‘Save’

 

 
 
  • Loadstorm will open the page so that you can check the step was performed correctly
  • Click ‘New step’
 
 

Scenario 1, action 2: Login to Moodle

 

 
  1. The ‘Login’ page of Moodle is located at http://yourmoodleserver.com/login/index.php. Fill in the correct information for your server
  2. Click ‘Save’
  • Click ‘New step’ when the preview shows up
 
 
  • You will now need to tell virtual users what usernames and passwords to use to login. 
  • Check that your values match the ones circled in red above
  • Click ‘Save
 
 
 
 

Scenario 1, action 3: Visit the Load Testing course

 

 
  1. Select ‘Click a link’
  2. Look for and select ‘Load testing course’ (or whatever else course you want the virtual user to access)
  3. Click ‘Save’
 
 
  • Check that the step has been successfully created and click ‘New step’
 
 

Scenario 1, action 4: View a 500KB image

 

 
  • Select ‘Click a link’ and then scroll down to the correct resource
  • Click ‘Save’
 
 
  • Check that the step was successfully created and click ‘New step’
 
 

Scenario 1, action 5: Logout

 

 
  1. Select the ‘Click a link’ option
  2. Select the ‘Logout’ link
  3. Click ‘Save’
 
 
  • Check that the step was successfully created and click on the name of your plan (or the ‘build’ tab).
  • Well done, your first scenario has now been created.
 
 

Step 5: Add scenario 2

 

 
 
 
  • As for scenario 1, make sure you are as descriptive as possible. Note that I have added a weight of 60 to this scenario. Scenario 1 has a weight of 40, therefore the weight of both scenarios equates to 100.
 
 
  • Check that the details are correct and click ‘Add step’
  • Note: We could have copied scenario 1 and edited it, but as this is a tutorial aimed at very beginners, repetition of steps is a good way to learn.
 
 

Scenario 2, action 1: Visit homepage

 

 
  1. Leave this as ‘/’ if your moodle is accessible via an address such as ‘http://www.mymoodle.com
  2. Select the correct server. Please see the warning note above if it is the first time you are using loadstorm
  3. Click ‘Save’
  • Note: After each new step you have created, you will receive a message telling you that the step was created successfully. To keep this tutorial as succinct as possible, I have removed those screenshots for scenario 2. Simply click on ‘New step’ whenever that screen shows up
 
 

Scenario 2, action 2: Login to Moodle

 

 
 
 
  • Make sure your options are similar to the ones shown in the image above
 
 

Scenario 2, action 3: Visit the Load Testing course

 

 
  1. Select ‘Click a link’
  2. Look for and select ‘Load testing course’ (or whatever else course you want the virtual user to access)
  3. Click ‘Save’
 
 
  • Click a link > Choose the right file > Click ‘Save’
 
 

Scenario 2, action 4: Return to course homepage

 

 
 
 

Scenario 2, action 5: View a forum

 

 
  • Click a link > Look for ‘Forum – Standard’ > Click ‘Save’
 
 

Scenario 2, action 6: Post a forum message

 

  • Make sure your details are the same as above
 
 
  • Make sure your details are the same as above
 
 

Scenario 2, action 7: Return to course homepage

 

 
  • The previous step will have returned a message that prevents you from clicking on any links so you’ll have to copy your course URL. The URL to a course is always something like http://www.yourmoodle.com/course/view.php?id=somenumber
  • Simply change ‘somenumber’ to the correct number for your course. Look in your browser address bar to find out what your course ID number.
 
 

Scenario 2, action 8: add a blog post

 

 
  • Click a link > Look for ‘Add a new entry’ > Click ‘Save’
  • Note: you must have the ‘Blog’ block on your course page for that link to show up.
 
 
  • Copy the details as above
 
 

Scenario 2, action 9: Logout

 

 
  • Click a link > Find ‘Logout’ > Click ‘Save’
 
 

Step 6: Add a new load test

 

 
  1. Click on the ‘Build’ tab
  2. When you have checked that the steps are correct, click ‘Add scenario’
 
 
  1. Ensure the right plan is selected
  2. Schedule when your test should be run, or simply tick ‘Start load test as soon as possible’
  3. Be as detailed as possible in your description
  4. These settings are self-explanatory. To replicate real classroom use, I like to use the same figure for ‘Start users’ and ‘Peak users’
  5. Click ‘Save’
 
 

Step 7: Understand the results

 

 

Both graphs show the progression for the entire duration of the test. The example test we ran was 30 minutes long, and this is represented on the X axis.

Graph 1:

  • Throughput: amount of kilobytes per second transferred between your server and the virtual users. Please note that it is bytes, and not bits. This is important as your web hosting company will probably will mention their network throughput in bits, not in bytes. If you would like to convert the throughput shown in this graph against your theoretical server throuput, you would have to multiply the peak number by 8. In this example, the peak throughput was 650KBps or 5200Kbps – which translates as 5.2Mbps.
  • User load: The amount of virtual users completing the scenarios at any given time. Note that there is no scale for this data so you have to over your mouse on the graph to find out the exact data. Our example test started with 15 users and finished with 25 users in increments of 1.
  • Requests per seconds: depending on how you setup your scenarios, virtual users will wait for a random period of time between each ‘click’ (or step). As the time they wait is random, the graph is an easy way to find out how many requests per second your server received during the test. The shorter the wait between steps, the more requests per seconds your server would receive.

Graph 2:

  • Response time, average: shows how long it takes for your server to respond to the request. As far as I understand it, this metric does not reflect how long it takes for a page to fully load.
  • Response time, peak: it won’t always take the same amount of time for your server to respond to requests.
  • Error rate: if a page is not accessible for whatever reason, loadstorm would record it as an error. In this example, there were no errors. Errors should be taken very seriously as a healthy server should never return any errors. Errors could be returned if the server is overloaded. You should download the CSV file for detailed results (see below) and also look at your webserver error logs to find out more.

Note: Click on ‘Click here for details…’ link to get access to useful reports

 
 

Step 8: Dig further

 

Step 9: Dig further
 
  1. When looking at a specific report, you can click on ‘Download as CSV’ – This will show you results for every individual requests
 
 

Looking through the individual results would allow you to zero in on specific issues or find out where your server ‘breaking point’ is at.