Tagged: moodle

Redis Over EFS for Caching In moodle cluster solution

If you are on this page, it means you are going with a scaling part for moodle. Now web server part is okay, the challenge comes with Shared file storage. That is also get resolved by using shared storage like EFS.

In case , if you want to read about horizontal Scaling for moodle cluster solution.

in case of AWS, EFS is good as shared storage for media data.

But if you are using EFS as filestore caching (required and default) , means you are using $CFG->cachedir at EFS location, this will make the system response slow.

Challenge with Memcache to use as application cache mode

So , we see that there are lot of posts for memcache. But the problem with Memcache is , this does not provide data guarantee and locking . For the application cache which are stored in $CFG->cachedir, it is base requirement. Memcache is good option for session store.

Just for reference : there are three type of cache modes in moodle ( application, session, static request [localcache])

Now we have choice for mongo db for application cache with new moodle version. Redis is more popular and have support for session store as well while mongo db mode is application only.

so the the choice for selection are , shared storage EFS or Redis.

I will go with redis, because of following testing results.

Test-Config

Load test Env : 2 aws t2.micro server 1 medium DB server, 1 ALB,  one window  server from another region used for testing.
load test Config: https://developerck.com/load-testing-on-moodle/

EFS for caching store

20 user, 30 seconds rampup time, 1 iteration

30 user, 30 seconds rampup time, 1 iteration

40 user, 30 seconds rampup time, 1 iteration

note : system was failed for this test. it is just an upper cap

Redis Cache for caching store (AWS Elasticache, micro server)

20 user, 30 seconds rampup time, 1 iteration

30 user, 30 seconds rampup time, 1 iteration
40 user, 30 seconds rampup time, 1 iteration

note : system was failed for this test. it is just an upper cap

Comparison

Disclaimer : Test are repeated with same configuration, just a change of Caching store. In both cases, server stats were also monitored and did on a virgin stage. Before putting load, cache were generated by manually following same steps. In spite of all these consideration, Caching store may not be the only reason for difference pattern in response time. There may be other factors as well, however, it is one of the factor.

by comparing above charts, one can see, there was a lot of improvement once i moved my application cache from EFS to REDIS .

EFSREDIS
20/30/12000-10000 ms1000-2200 ms
30/30/1mostly > 9000 msmostly < 6000 ms

If you are using only one web server, EBS volume results are 10 times better than Redis. It is just , if we have more than one application server and a shared storage, REDIS is performing much better than EFS for cachestore.

more about redis : https://aws.amazon.com/redis/

Quick Start guide for Stress / Load Testing on Moodle

I hope, you have your environment ready, now you want to put a load to Test it.

We will be utilising, Apache Jmeter tool for this. A basic knowledge of Jmeter will be required.

Moodle comes with a built-in support for Jmeter Load test script.

For advanced user, here is the Moodle git repository link, contains useful scripts to setup / test / compares the whole site performance

https://github.com/moodlehq/moodle-performance-comparison

For Beginners, Following are the steps.

If you want to test a course page, then you must have the course. and when you are putting the load with users , you must have created the account of the users. and they should be enrolled in the course.

This part can be done manually or dynamically

[Plan -1] : Quick Start

” In this, you can download the attached material to create and run. The request flow will be : login > course view > logout

  • Create a course and use the shortname “m1” while creating the course. Make sure manual enrolment plugin is enabled . Note down the course id from url.
  • Go to Site Administration > Users > upload Users and upload the file course_user.csv , present in download zip. this will create users and enroll them into this “m1” course. This csv contain 100 users.
  • Load the test_plan.jmx file in Jmeter.
  • Put the user_credential.csv in the home folder for jmeter.
User Credential File
  • Change the variable values with your in Jmeter
Jmeter Plan (change the highlighted Values)

[Plan-2]

Use Moodle functionality to create the course for you, and create the enhanced Jmeter Load Plan for you for that particular course.

  • put this code in config.php
$CFG->tool_generator_users_password = 'any123' ; // this will be the password for the users created in next command
  • go to location <moodlecodebase>admin/tool/generator/cli & run the following command
php maketestcourse.php  --shortname="loadtest1" --fullname="loadtest1" --size="XS"

This will create a course in moodle with name as loadtest1.

SIZES :

  • XS : 1 Users
  • S : 30 users
  • M : 100 Users
  • L : 1000 Users
  • XL : 5000 Users
  • XXL : 10000 Users

This will automatically create the course , with activities with test users and enrolled them in this course.

  • Now , go to “Site Administration > Development > Make Jmeter Test Plan”
  • Select the Plan with size
  • Select the Course “loadtest1”
  • Jmeter Plan file and User Credential CSV file will get download
moodle jmeter load test plan

“Now, You have the Jmeter load test plan, You have the Course users list, and you know the password. Load the Test plan and Credential File in Jmeter. and You are ready to put the load.”