Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Load testing Moodle with JMeter: Difference between revisions

From MoodleDocs
No edit summary
m (Tsala moved page JMeter to Load testing Moodle with JMeter: Clearer name as suggested by Visvanath in https://moodle.org/mod/forum/discuss.php?d=424763#p1710930)
(No difference)

Revision as of 05:44, 27 July 2021

Being the original load testing tool for servers, introduced in 1998(!), JMeter [1] has always been the number one load testing resp. performance measuring tool for Moodle. Around its release 2.5, Moodle developers made the testing process vastly simpler by adding many scripts. The topic of this page are the two scripts Make test course and Make JMeter test plan, both available under Site administration > Development. Together with the set of add-ons Moodle performance comparison they comprise a full set of load testing tools.

Warning: Do not run these scripts on a production system! These scripts generate large amounts of artificial data and load the server to its limit and beyond, making it to bloat and become non-responsive. Don't even run them on a separate Moodle instance in the production server: their effect on the DBMS is undocumented.

Make test course

This tool creates sample courses with many sections, files, various activities and users. These are intended to be used as standardized loads for checking the reliability and performance of various system components under load.

Warning: Courses created using this feature can occupy a large amount of database and filesystem space (tens of gigabytes). You will have to delete those courses (and wait for various cleanup runs) to release the space they consumed.

Before making a course first you have set the debugging level under Site administration > Development > Debugging to DEVELOPER. Then go to Site administration > Development > Make test course. You have a choice amoung the sizes XS, S, M, L, XL and XXL:

make-a-test-course.png
Size of course Approx. size No. of assignments No. of pages No. of small files No. of big files No. of sections No. of users No. of forum posts Approx. time to create
XS 10 kB 1 1 1 1 1 1 2 1 sec
S 10 MB 10 50 64 2 10 100 20 30 sec
M 100 MB 100 200 128 5 100 1,000 500 2 min
L 1 GB 500 1,000 1,024 10 500 10,000 5,000 30 min
XL 10 GB 1,000 5,000 16,384 10 1,000 50,000 10,000 2 hours
XXL 20 GB 2,000 10,000 32,768 10 2,000 100,000 20,000 4 hours

Sample output (from a course of type M):

 Creating course
 Creating [Course name]
 Creating assignments (100): . . . . . . . . . . . . done (12.7s)
 Creating pages (200): . . done (1.5s)
 Creating small files (128): done (0.4s)
 Creating big files (5): . done (1.3s)
 Checking user accounts (1000)
 Creating user accounts (1 - 1000): . . . . . . . . done (8.7s)
 Enrolling users into course (1000): . . . . . . done (5.7s)
 Creating forum (500 posts): . . done (1.7s)
 Course completed (32.2s)

Pl. note that bigger courses take longer to be created - the biggest up to 4 hours on a decent server. Your server may run out of space or time out if it can't handle the size you selected.

Make JMeter test plan

This script creates a JMeter test plan file along with the user credentials file. Here too it is necessary to set Site administration > Development > Debugging to DEVELOPER. Also note that, unlike making the test course, this is a single script. Therefore the PHP max_execution_time need to be at least as long as the time for the whole script, which could be anything from a minute to hours depending on the size of the course you select.

This test plan is designed to work along with Moodle performance comparison [2], which makes it easier to run the test plan in a specific Moodle environment, to gather information about the runs and to compare the results, so you will need to download it and use it's test_runner.sh script or follow the installation and usage instructions.

You need to set the same password for all the test users by adding the line "$CFG->tool_generator_users_password = 'YOURSECRET';" to config.php of Moodle. You might want to set "$CFG->passwordpolicy = 0;" too, in case the proposed user password does not satisfy the password policy of the site. There is no default value for this password to prevent unintended usages of the tool. You need to use the update passwords option in case your course users have other passwords or they were generated by tool_generator but without setting a $CFG->tool_generator_users_password value.

This script is a part of tool_generator so it works well with the courses generated by the courses and the site generators, it can also be used with any course that contains, at least: - Enough enrolled users (depends on the test plan size you select) with the $CFG->tool_generator_users_password password set - A page module instance - A forum module instance with at least one discussion and one reply

You have to consider your server's capacity when running large test plans as the amount to load generated by JMeter can be specially big. The ramp-up period has been adjusted according to the number of threads (users) to reduce this kind of issues but the load is still huge.

Visit Site administration > Development > Make JMeter test plan. Under Size of course your have six possibilities: XS (1 user, 5 loops and 1 ramp-up period), S (30 users, 5 loops and 6 ramp-up period), M (100 users, 5 loops and 40 ramp-up period), L (1000 users, 6 loops and 100 ramp-up period), XL (5000 users, 6 loops and 500 ramp-up period) and XXL (1000 users, 7 loops and 800 ramp-up period). As target course select one of the courses created above. Also Update course users password should be ticked.

Consider that the server resources you will need to make bigger test plans will be accordingly higher.

Once successful you can download a test plan testplan_timestamp.jmx and a users file users_timestamp.csv

There is also a PHP CLI version of the script. Run it with --help to see its options:

 $ php admin/tool/generator/cli/maketestplan.php --help
 Options:
 -h, --help              Print out this help
 --shortname             Short name of the test plan's target course (required)
 --size                  Size of the test plan to create XS, S, M, L, XL, or XXL (required)
 --bypasscheck           Bypasses the developer-mode check (be careful!)
 --updateuserspassword   Updates the target course users password according to $CFG->tool_generator_users_password
 
 * XS (1 Nutzter, 5 Schleifen und 1 Steigerungsrate)
 * S (30 Nutzter, 5 Schleifen und 6 Steigerungsrate)
 * M (100 Nutzter, 5 Schleifen und 40 Steigerungsrate)
 * L (1000 Nutzter, 6 Schleifen und 100 Steigerungsrate)
 * XL (5000 Nutzter, 6 Schleifen und 500 Steigerungsrate)
 * XXL (10000 Nutzter, 7 Schleifen und 800 Steigerungsrate)
  

Example:

 $ sudo -u www-data /usr/bin/php admin/tool/generator/cli/maketestplan.php --shortname="testcourse_12" --size=S

Running the test plan on JMeter

JMeter is a Java application so it can run on Windows, Mac, or Linux. It can be run on the command line or on its graphical client on your desktop. First check if Java is installed in your client computer by opening a console and entering ' java -version'. If it doesn't return a version, first install Java on your client. The instructions vary with the operating system.

To install JMeter go to the JMeter page, download the zip and unzip it to the directory of your choice.

To run JMeter. open the /bin subdirectory and use either jmeter.bat on Windows or ./jmeter on Linux. This will open the JMeter GUI.

First step is to go to File -> Open and select the testplan.jmx file. This will open a tree on the left hand side of JMeter. Open the Warm-up site -> Default site request and enter the protocol (http or https) and Server name or IP. Then go to CSV Users Data and locate your users.csv file under Filename. Repeat this for Moodle Test.

Right mouse click on the Test Plan, then Add -> Listener. I choose Aggregate Report so I can follow the run as it happens. Save the changes in your test plan and run it.

References