High CPU load during quizzes

Re: High CPU load during quizzes

by Chris Kenniburg -
Number of replies: 6
Picture of Particularly helpful Moodlers Picture of Plugin developers

One thing we did was to put the database on a separate server altogether.  That seemed to help quite a bit.  We also utilized php-fpm and Apache Event MPM.  

We regularly have over 150 students for most of the day and during finals there are even more and mostly taking quizzes.

Average of ratings: Useful (2)
In reply to Chris Kenniburg

Re: High CPU load during quizzes

by Colin Matheson -

Thanks for the reply Chris (I work with Henry). What are the specs for your two servers in your set up? Our server is a virtual server with 8 cpus and 32 GB of RAM. Would we get an advantage splitting that into two 4 cpu/16GB servers (or a different fraction for code/web vs database)? Or should we throw more resources at the problem?

Also it seems like logins are a major part of the load. I am wondering what we can do to decrease the load on login (decrease available roles?).

In reply to Colin Matheson

Re: High CPU load during quizzes

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

On a much older Moodle we also used to have this problem. It seems pretty obvious now, but back then I did not know about opcache. Once we enabled that we got significant performance improvements. 

In reply to Colin Matheson

Re: High CPU load during quizzes

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

We use VMware with Linux. Apache & PHP7 on one box.  Maria DB on the other.   We use LDAP authentication.  The server specs are only 2 CPUs which operate at about 20% most of the day.  8Gig of RAM.  Average users are between 60 and 100 throughout the day.  Peaks at 150 to 200 during certain hours of the day.  

Splitting application from database as well as switching to Apache Event MPM made a huge difference.  

We use Apache Event MPM which made a huge difference over the default of prefork.  I am not a server expert but we always seemed to have bottlenecks with prefork.  Most of these probably stemmed from us not knowing how to set it up properly.  However, since switching to Event MPM it has been very fast and seems to handle the various loads throughout the day.  Making sure that the MPM is configured as well as the PHP-FPM seemed to make a difference as well.  We also increased some of the MARIA DB caches and settings.

If the logins are the issue then maybe it is more appropriate to look there first.  What authentication are you using?  We use LDAP and the only time we have issues with login are when that LDAP server acts up or there are networking issues.


Average of ratings: Useful (1)
In reply to Chris Kenniburg

Re: High CPU load during quizzes

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Here is our Moodle Application VMWare Linux 2 CPU/8G RAM server with 160 kids on it.  Barely breaking a sweat.  

The database server barely ever goes above 500MHZ CPU Usage.  800MHZ during hour changes and mass logins.

Page loads are about 2 seconds or less.  Opening quizzes and other activities is just as fast.  So are logins.

Apache with Event MPM, PHP7, PHP-FPM, Maria DB.  

Attachment 160 users server.png
Attachment Dashboard.png
Average of ratings: Useful (2)
In reply to Chris Kenniburg

Re: High CPU load during quizzes

by Colin Matheson -

We are using Google Oauth2 as a plugin in Moodle 3.2 and NGINX as the web server but otherwise a pretty similar setup (oh and 32 GB of RAM and 8 CPUs!!!). Maybe splitting into a database and a web server instance is the way to go, or maybe something with our NGINX config is the problem.

In reply to Colin Matheson

Re: High CPU load during quizzes

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Apparently there was a server issue on our end too.  In looking at our server to see about performance I noticed there were server updates and a few other things.  It dropped to around 800mhz with an average of about 100 kids the last two days.


With NGINX you shouldn't have any issues.  It should be way better out of the box for this.  Howeever, I really like Apache with Event_MPM and PHP-FPM.  

Quizzes seem to require a lot of back and forth with the database.  Do you have your database server optimized with caches and all that stuff?