Parts of Moodle and the home page load very slowly

Parts of Moodle and the home page load very slowly

by James Marshall -
Number of replies: 9

Hey,

I am having some speed issues that I would like help with if possible. We have just moved our VLE internally so hosting it ourselves is relatively new. Please be patient with me smile

We have a server which serves Moodle 1.7.2+. It is a Windows Server 2003 machine with IIS6, PHP 5.2.3 & MySQL 5.0.37. We have 2GB of RAM installed and I'm not sure of the processor, although I think it is dual core (can't be certain though)

Basically the main problem we are having is the home page loads very slowly. The header section loads fine but then it takes about 5-10 seconds for the rest of the page to load. I have read a lot of forum posts on this but most of them mention RSS feeds, which we don't use. I have checked the settings and RSS is disabled.

Does anyone have any ideas what could be causing this?

There is also a general slowness of the site aswell. It could be linked to the home page but again I don't know what could be causing it.

Thanks,
James

Average of ratings: Useful (1)
In reply to James Marshall

Re: Parts of Moodle and the home page load very slowly

by Chris Lamb -

Try taking out all your blocks and see if the remaining page loads fast - if it does, add the blocks back one at a time until you see it suddenly slow down again, at which point you've found the culprit.  Does your page finish loading properly, including the footer?  If there's stuff missing, like the footer or part of the page, then this suggests that there's a problem with whatever is the first thing to be missed, as it would prevent everything subsequent to it in the code from running and would cause the rest of the page to be kept back until the problematic bit had timed out, when the browser would show the part of the page that had been supplied.

Try changing your theme to the standard Moodle one - I had a problem with page slowness (30+ seconds) which I traced to the theme I was using trying to run the cron jobs when it loaded the header.  When I commented out the bit of code that was trying to run the cron the page loaded in under 2 seconds.  If changing your theme to the standard one speeds things up you can then investigate your other theme to see why it's slowing things down.

If the slowness only affects one page then it's something on that page which is causing the problem, and you have no general problem.  If every page is slow then it's either your theme, your header, or your server which is the problem - try repairing and optimising all your database tables, if they've got themselves in a mess then MySQL could be struggling to pull data out.

HTH

Chris

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

Re: Parts of Moodle and the home page load very slowly

by James Marshall -

Hmmm... (not sure why I didn't think about doing that before TBH!)

Now this might seem a little strange but for me, as an admin, it seems as though the Site Administration block is slowing the front page down massively. I clicked Turn Editing On and hid the block (by clicking the eye icon) and the page immediately loaded faster. I tried messing with all the blocks on the home page and that is the only one that made the page load faster.

Now as for regular staff members (i.e. non admins)...with the Site Admin block enabled it still causes the page to load slowly even though they can't see that particular block. However as soon as you disable it the page loads very quickly. I am guessing the Site Admin block is still being loaded even though the user isn't an admin???

I have also noticed that the admin page (http://mymoodle.com/admin/ for example) loads even slower than the front page did. I have even removed the Site Admin block as above but it still loads incredibly slowly. Not even a header is displayed before the page comes up.

We are using a standard Moodle theme (formal_white) at the moment so there shouldn't be any problems with that.

Every page seems to load fine with no error messages, but the whole site still seems a little sluggish - each course takes around 2-3 seconds to appear - i'm not sure if this is normal but it feels so slow. I am guessing this could be a MySQL issue as all the data is coming from there. Any suggestions on what to check RE MySQL performance?

Thanks for your help so far, much apreciated!

James

In reply to James Marshall

Re: Parts of Moodle and the home page load very slowly

by Chris Lamb -

I doubt if the Site Admin block is being loaded for non-admins - I would imagine that Moodle checks to see if you're an admin and if the block is supposed to be displayed, and if the answer to either question is 'no' then it skips that bit of the code completely.

I'd be inclined to check your database - as you say, everything comes from there, so if MySQL is having trouble finding stuff that will slow things down.  Try using PHPMyAdmin, or whichever MySQL database tool you favour, and get it to check and repair all the tables and then optimise them.  It might also be worth checking how long you keep log files for - if you've got logs set to 'Never delete' you might have a very long database table (I found whilst upgrading all our Moodles over the last couple of weeks that one of them had over 600,000 entries in the user logs table, which is a bit much!).  Every time you do anything in Moodle it makes an entry in the log file, and if it's having to access a table with tens of thousands of records every time you sneeze this will slow things down quite a bit.  If your server is a Windows box it might also be worth checking the drive for fragmentation and defragging it - if you've got big database tables and Windows is having to wander round the drive collecting bits from all over the place like picking daisies in a meadow that will affect performance as well.

Moodle has to do a lot of work to render even a simple page - if you select the standard theme and then click on 'Server' in your Admin block, then 'Debugging' and tick 'Performance info' it will tell you in the footer how many files Moodle had to load to render a page, and how long it took the server to generate the page.  I've just tried a couple of mine, and a simple front page with hardly anything on it required 78 files and took 2.17 seconds, and the front page of a well-used Moodle needed 120 files.  I think this is in addition to all the database tables it needed to look things up in and and make log entries in, so you can see how much it's having to do!  You should be able to make it run a bit slicker by repairing and optimising things, as above, but given the amount of work it has to do 2-3 second page loads aren't too out of the way.

HTH

Chris

Average of ratings: Useful (2)
In reply to James Marshall

Re: Parts of Moodle and the home page load very slowly

by Michael Penney -
1.7 had some big performance issues with admin users, which 1.8.2 took care of.

However see: http://tracker.moodle.org/browse/MDL-10635 (I think this issue also exists on 1.7).
In reply to Michael Penney

Re: Parts of Moodle and the home page load very slowly

by Michael Penney -
PS we didn't notice this problem on our Solaris dev/test servers, but when our clients put the code on their linux cluster they had problems with 100+ simultaneous logins due to the tremendous # of db calls from update_course_icon().

The patch in 10635 did a great deal to solve the immediate problem, though we all anxiously await Martin L.'s good fix.

Until that time, the latest code with the patch in 10635 and a good batch of Solaris boxen is my top recommendation.
In reply to Chris Lamb

Re: Parts of Moodle and the home page load very slowly

by Janak Sodha -
I too am able to reproduce the same problem - namely the admin login slows very much only if the administration block is visible. If this block is hidden, then it works well.

Lets hope for a fix in the future.
In reply to Janak Sodha

Re: Parts of Moodle and the home page load very slowly

by Janak Sodha -
Using version 1.9.7 and still have the same problem - please, any advice beyond simply hidding the admi block?
In reply to Janak Sodha

Re: Parts of Moodle and the home page load very slowly

by Daniel Bailey -
I'm on the same boat Janak,

I'm having "time out" issues when loading mymoodle.com/admin/
I added a few unnecessary modules. I'm hoping that optimizing MySQL and removing unused mods and blocks can fix it.

You think the fact I'm using a shared godaddy account make a difference? I think so, but not sure.

Danny
In reply to James Marshall

Re: Parts of Moodle and the home page load very slowly

by Martín Langhoff -

The current roles & permissions code (accesslib) in 1.7/1.8 gets quite slow with growing number of courses. Note that the slow performance is specially noticeable when youy login as administrator (as moodle does a lot of extra work). Try logging in as a non-super-privileged user...

I am working hard on a definitive fix -- but it's likely to appear late in the 1.9.x branch, or directly in 2.0.

In the meantime:

  • upgrade to v1.8.x heavily recommended
  • eaccelerator!
  • Try enabling rcache, and if you have eaccelerator/turkmmcache enable the eaccelerator rcache option.
  • Probably mysql's query cache can help too
  • There's a ton of mysql optimisation you can do.
  • Filesystem tuning will help too. I don't know a thing about fs tuning on windows though.
  • If you have lots of courses (in the hundreds or thousands)... can you remove old/unused ones?
  • If you have lots of courses... try disabling the calendar block
  • If you have lots of courses... try disabling the "my courses" block
  • Course listings in the homepage can also hit

Let us know how it goes!