Moodle 2.5.1 running slow -- with troubleshooting details

Moodle 2.5.1 running slow -- with troubleshooting details

by Megan Hayes-Golding -
Number of replies: 6

I'm seeing Moodle sometimes run incredibly slow, resulting in either a database connection error or an internal server error. In trying to pin it down, I turned on the debugging at the footer of each page.

My environment:

  • Moodle 2.5.1 with Fusion theme
  • Hosted with site5 Managed VPS
  • php 5.3.21
  • mysql 5.1.67.14.3

I've followed the Five Simple Settings blog post: Moodle automated backups are disabled, enable statistics is disabled, theme designer mode is disabled, keep logs is set to "never delete logs" and grade history lifetime is set to "never delete history" but in my defense the server has only existed for a month, and I disabled database for session information.

I don't think the problem's with site5: I had a cheaper plan with site5 and Moodle 2.0 running with lots more users with no performance problems earlier this year. This new server has 1100 users, of which about 40 are concurrent.

Home > Site administration > Server > Environment says OK on everything except php_extension intl, which it asks me to check. A total of 12 php extensions say they must be installed & enabled (iconv, curl, ctype, zip, etc). Several items say I should install them for best results (prceunicode, mbstring, soap, xmlrpc, etc). Do I need to take action on any of these?

We notice the worst performance at the start of our face-to-face class. At first, I thought the slowdown might be tied to authentication (we're using Manual Accounts), but I've seen no definitive proof. Students report very few slowness issues outside of class hours.

Today, I had a group of kids login at the same moment then send me the info in the footer. I have the following data:

Right away, I noticed the slowest load times came with the highest ticks and load average. I think I understand what load average means (it's a CPU thing, right?). What does ticks mean? Where can I go from here to figure out what's causing my super-slow Moodle?

Many thanks for any pointers you can give.

Average of ratings: -
In reply to Megan Hayes-Golding

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by J S -

Based on the information you provided, the most likely problem is that you dont have enough CPUs powering your web server.  When Clark and Ethan logged in, your load was nearing 20.  Load is a measurement to see how well your CPU is doing in regards to the work you are asking it to perform.  Here is how load works as an example...

On a one lane freeway, you can have one car driving 60mph.  You only have 1 lane, so you can only fit one car on the highway.  Your load in this case is 1. (we are disregarding 1min, 5min, 15min load averages here and just focusing on the concept)

Say you still have a one lane freeway, but wanted to have two cars go down the road.  There is only one lane so the second car would have to get in line behind the first.  You would have a load of 2, but only a one lane freeway.  In order to have things go faster, you would need to turn your one lane freeway into a two lane freeway.  Now both cars can go down the road at the same time and no one has to queue up.

When more students are using your site, the cpu is getting overloaded and processes are getting put into a waiting queue, and I say that because I doubt you have 20 cpus on your web server if you are getting that long of page load times.  If you have a 2 cpu web server (guessing here), you would have 18 processes waiting to be run when showing a load of ~20.  

Adding CPUs may not be sufficient.  You need to observe your system when under these high load conditions and see what the system is doing.  Is it spending a lot of time in User? System? Wait?  Depending on where the CPU is spending most of its time will determine how to solve the problem.

Average of ratings: Useful (1)
In reply to J S

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by Megan Hayes-Golding -

Thank you! This is very helpful.

My hosting plan is site5's VPS1, with 2 cores and 768 MB of memory. Up till now, I had as many concurrent users (maybe even more) on a much cheaper shared hosting plan, with no issues.

I'm referring to Linux Load Average explained to help me diagnose. I suppose my host can probably provide guidance, too.

Again, thank you for the pointer.

In reply to Megan Hayes-Golding

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

768MB is nowhere near enough to run a production Moodle site. The installation requirements do tell you this. I would say an absolute minimum of 2GB for Moodle 2.5, preferable 4GB+. 

Consider that a shared hosting plan may actually give you access to a lot more resource than a VPS does. 

Think of load average as (very roughly) the average number of processes waiting for a processor. If you have 2 cores then a load average consistently higher than 2 means that processes are queueing. Much higher than 2 (like you have) is a problem. This can mean that you need more cores but is nowhere near as simple as that. 

Average of ratings: Useful (2)
In reply to Howard Miller

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by Megan Hayes-Golding -

Thank you for confirming what I suspected about my hosting specs. I wasn't involved in purchasing the hosting plan, so I didn't realize the memory was so low until I started troubleshooting these problems.

I never had any performance problems on site5's most basic shared hosting, so I'm going to pursue switching us back to the super-cheap plan.

We saw the load average spike this morning around the time two teachers asked students to login (probably 20-30 students in total).

I ran sar -A, which gave me load averages of 56.78, 31.58, and 13.26. A few other times this morning, I've seen the load averages spike to 2-2.5 but nothing like those really high numbers from earlier.

Thank you Howard. I appreciate the time you took to help me out.

Average of ratings: Useful (1)
In reply to Megan Hayes-Golding

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

As I'm sure I don't need to tell you, a machine with load averages like that is effectively dead in the water. 

Average of ratings: Useful (1)
In reply to Megan Hayes-Golding

Re: Moodle 2.5.1 running slow -- with troubleshooting details

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What operating system is this? What is the specification of the VM - how much RAM, what and how many CPUs?

Is this one box for both the web server and the database server?

Have you looked at the performance tips (see forum pre-amble) and done any tuning for the web server and database (they are unlikely to be optimal 'out of the box')?