Moodle is very slow only on course page and resources.

Moodle is very slow only on course page and resources.

by Jose Galeano -
Number of replies: 23
I have read all of the performance documentation and many blogs on the internet but I don't seem to understand why my moodle is extremely slow on a course and its resources but on the home page and all administration pages works as expected. And the weird thing is that after I attempt to access a course and return to another page, all the site seems to slow down.

It has 22 quizes, 11 forums, 11 url modules (external url), 4 games and 2 questionare surveys. Is there a configuration I am missing out on or am I what could I be doing wrong?

# Description Time (seconds) Acceptable limit Critical limit
1 Moodle loading time 0,006 0,5 0,8
Load the "config.php" configuration file
2 Processor processing speed 0,296 0,5 0,8
Call a PHP function with a loop to check the processor speed
3 Reading file performance 0,018 0,5 0,8
Read a file multiple times to check the reading speed of the Moodle temporary folder
4 Writing file performance 0,124 1 1,25
Write a file multiple times to check the writing speed of the Moodle temporary folder
5 Reading course performance 0,037 0,75 1
Read a course multiple times to check the reading speed of the database
6 Writing course performance 1,340 1 1,25
Write a course multiple times to check the writing speed of the database
7 Database performance (#1) 0,029 0,5 0,7
Run a complex SQL query to check the speed of the database
8 Database performance (#2) 0,022 0,3 0,5
Run a complex SQL query to check the speed of the database
9 Login time performance for the guest account 1,831 0,3 0,8
Check the loading time of the guest account login page
10 Login time performance for a fake user account 1,530 0,3 0,8
Check the loading time of a fake user account login page
Total time 234,233

Average of ratings: -
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Ken Task -
Picture of Particularly helpful Moodlers

You are also admin of site, right?  Admin levels always requires more settings.  What's acceptable 'speed'?

Ok, you've read 'everything' [which I kinda doubt ;)] but what have you done to attempt to increase performance?

If you look at the items you've bolded ... 9 and 10 guest/fake user ... do you care?  What's it like for a student?

Number 6 however ... different story ... what have you researched to address number 6?   What could one do for 6?

'SoS', Ken


In reply to Ken Task

Re: Moodle is very slow only on course page and resources.

by Jose Galeano -
Everythin on moodle performace settings [https://docs.moodle.org/38/en/Performance_recommendations]. I have also used mysqltuner and adjusted the settings, this includes the follwoing configuration, I have 64Gb RAM. For students its the same thing, front page ok but in course is extremly slow, it can take up to 5 min to load a page.
[mysqld]
performance-schema=ON
innodb_buffer_pool_instances=40
innodb_buffer_pool_size=41.2G
innodb_file_per_table=1
innodb_flush_log_at_trx_commit=2
innodb_log_file_size=5G
join_buffer_size=257K
key_buffer_size=10G
long_query_time=5
max_allowed_packet=268435456
max_connections=700
max_heap_table_size=2G
query_cache_type=0
query_cache_size=64M
query_cache_limit=0
query_cache_min_res_unit=2K
thread_stack=256K
tmp_table_size=2G
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Ken Task -
Picture of Particularly helpful Moodlers

Good!   DB server on same server as code is sometimes a balancing act.

Tuner has info at top of a run ...

Physical Memory
Max MySQL memory
Maximum reached memory usage:Maximum possible memory usage:
Overall possible memory usage with other process is compatible with memory available

At bottom: Variables to adjust:

Sometimes variables adjusted have opposite desired affect.

Web service is?

Got any caching?  How often is cron running?  Is cron job via /usr/bin/php or wget/curl?

What does the 'top' of 'top' look like on your system?

'SoS', Ken


In reply to Ken Task

Re: Moodle is very slow only on course page and resources.

by Jose Galeano -
Cron is running at midnight everyday through crontab on centos "php [MOODLEDIR]/admin/cli/cron.php". I have cheked top and the only process consuming about 10% to max 30% of CPU is php-fpm, the most I've seen that mysql uses is 18% of memory. The only thing that I see taking alot of resource is php-fpm.
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Ken Task -
Picture of Particularly helpful Moodlers

Ok, so we are not gonna share what was requested concerning tuner output ... even though those are critical ... ok then we'll move on ...

This one IS a biggy ...

"Cron is running at midnight everyday" ... just once a day @midnight?

Should be running once every minute ... cron job won't execute all that is in jobs Moodle has to do ... take a look at the 'task' list of your site.   Lots of clean up task ... including caches ... which could be a bottleneck for your server.

Would also make sure the cron job is re-directed not to la-la-land but, rather, to a moodle-cron.log in /var/logs/

touch /var/log/moodle-cron.log

cron job every minute:

/usr/bin/php /path/to/moodle/admin/cli/cron.php > /var/log/moodle-cron.log

Anytime you want to see it work ... or not ...

tail -f /var/log/moodle-cron.log

and you can watch it realtime.

Also, are we sure that /usr/bin/php is the php for CLI?

I have 2 CentOS 7's myself ... on a Rackspace box: /usr/bin/php is cli ... however, on Google Compute Engine it is /bin/php - the initial image for server comes from provider.

'SoS', Ken


In reply to Ken Task

Re: Moodle is very slow only on course page and resources.

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up on 'top' of 'top' ... using any SWAP space?   What is using SWAP space?  Any disk I/O is generally not good.  IF it's DB server using SWAP ... that's where tweaking balance between php-fpm and DB server comes into play.   IF possible, more mem to DB ... DB's run best if one can fit them in memory ... no disk I/O then.  Faster ... coming from memory.  Fewer php-fpm .... but enough to handle traffic.

Is server also running 20 WordPresses 4 Joomla's ... other? or is it dedicated to Moodle.   Tuner output and recommenations consider *all* the databases.

Cull really un-needed DB's and apps running them .. reduces totals on DB server or allows one to dedicate more to Moodle ... which is really a memory hog! (nature of the beast) ;)

'SoS', Ken


In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Do you by chance have Theme Designer mode turned on? If so, turn it off...
In reply to Emma Richardson

Re: Moodle is very slow only on course page and resources.

by Jose Galeano -

No, it is turned off, that's the first thing I checked.

In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Ken Task -
Picture of Particularly helpful Moodlers

have 64Gb RAM - has to run everything
innodb_buffer_pool_size=41.2G ...
With that buffer pool setting MySQL should be using 42Gig of memory
If you actually get your server to use that.

64G - 42G = 12G to run everything else ... including apache (how ever that's configured) + anything else operating system wise.  Including the cron job which when set to run only once a day, will have to work hard to 'catch up'.

And the following items in Tuner output should verify 'calculation' above:

Physical Memory
Max MySQL memory
Maximum reached memory usage:Maximum possible memory usage:
Overall possible memory usage with other process is compatible with memory available

Cron job ... not running frequently enough ... once every minute.

You mentioned you saw a lot of php-fpm processes.   How many is a lot?

'SoS', Ken

In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi

Time durations of 6, 9 and 10 are probably related and indicate a terribly slow database. It is not just slow, either something is broken or it is on a unusable disk. You have to go below Moodle. I would start at the lowest level, disk performance with Bonnie, for example. If healthy then move on to the database.
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Jose Galeano -
I installed WordPress also on the same server and everything works fine on WordPress, the response time writing and reading data is really fast, but in Moodle everything is slow, so I am guessing there's something in Moodle, I have already check the theme designer mode is off. I am continuing looking at what may happen but I'm still looking for suggestions and help.

Ok I've have gone a step further and installed another clean moodle on the server and its also loading fine. So it is defenetly a Moodle configuration.
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Usman Asar -
Picture of Plugin developers Picture of Testers

Jose, you cannot compare WordPress to Moodle in terms of performance for WordPress comes with 12 database tables in all, whilst moodle comes with 450+, where WordPress is widely used CMS so hosting providers optimize their servers to accommodate WordPress's performance in priority (WSCache, LSCache etc)

if your clean moodle installation is faster compared to your questionable moodle, then it must be the theme or some plug-in making your moodle slower, you can check which one is slowing down your moodle, by installing all plug-ins that you've got originally installed one at a time and see which one is degrading your performance.

Average of ratings: Useful (1)
In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by Benjamin Cabassot -

Hey !

I have the same issue since i switched from Moodle 3.5 to Moodle 3.9.3 and switching the theme, to adaptable.

What is the theme your using ? it seems that for me it goes faster when iam using other theme than Adaptable.

My course contain SCORM, Forum, Test, Certificat, ressources and some links. Also there are a lot of students matriculated, more than 2000. I dont know if it is slower because of that .. Do you know?

Also i noticed that on some courses it goes fast, and some other, it goes slow (more than 15s). And it seems for now, that the only difference between a slow and a fast course is the number of student matriculated. Even if with other theme, i dont have this issue.

If you have any ideas about how to fix it, pls let me know.

Thanks,

Best regardsm


 

In reply to Benjamin Cabassot

Re: Moodle is very slow only on course page and resources.

by Andrew Molteno -
Hi Benjamin
Did you find a solution? I have the same issue with Moodle 3.9.3 and Adaptable theme 3.0.4. Some course sections load slowly for teachers (5+ seconds) while students on the same course experience faster load times (1.5s). This is consistent. I use OneTopic and in my case have found that the topics with lesson or feedback activities are affected.
The issue does not present when changing to Classic theme.

Regards
Andrew
In reply to Andrew Molteno

Re: Moodle is very slow only on course page and resources.

by Jean-François Lemoine -
Hi,

About Adaptable 3.

  • Does it impact only teachers, and not students?
  • Do you have more than a few thousand students enroled in the course?
If your answer is yes to both, you may have encountered a limit in course_participant_count(). In september this function have been rewrote to be more accurate, but slower.

Regards.
Jean-François
Average of ratings: Useful (1)
In reply to Andrew Molteno

Re: Moodle is very slow only on course page and resources.

by Benjamin Cabassot -
Hi Andrew,

Our institution and ourMoodle Partner did not find a solution.
So to allow the best user experience, we switch to Fordson theme.
I think that the anwser of Jean-François, can be the origin of the issue.

Best regards,
In reply to Benjamin Cabassot

Re: Moodle is very slow only on course page and resources.

by Andrew Molteno -
Hi @Benjamin, thanks for the update.
@Jean-François, yes, only teachers, not students. However this affects courses even with 100 students.

Regards
In reply to Andrew Molteno

Re: Moodle is very slow only on course page and resources.

by Jean-François Lemoine -

Here is an easy and safe way to verify if it’s the problem I was talking about:

  • Got to /admin/settings.php?section=theme_adaptable_course
  • In section Course page further information uncheck all the herebellow settings:
    • coursesectionactivityfurtherinformationassign
    • coursesectionactivityfurtherinformationquiz
    • coursesectionactivityfurtherinformationchoice
    • coursesectionactivityfurtherinformationfeedback
    • coursesectionactivityfurtherinformationlesson
    • coursesectionactivityfurtherinformationdata

Does it solve your problem?

Average of ratings: Useful (2)
In reply to Jean-François Lemoine

Re: Moodle is very slow only on course page and resources.

by Jean-François Lemoine -
Sorry, since 3.0.2, this settings’ page can be found at:
/admin/settings.php?section=themesettingadaptable#theme_adaptable_course
Average of ratings: Useful (1)
In reply to Jean-François Lemoine

Re: Moodle is very slow only on course page and resources.

by Andrew Molteno -
Thanks Jean-François, disabling those settings had a significant impact on load times. Do you know what the effect of disabling these options are when loading the course section? e.g. for assignment the description states "Show assignment information, such as due date, submission status. For teachers / admins, show number of submissions.". That information is still available when selecting the assignment, either as student or teacher.
Average of ratings: Useful (1)
In reply to Andrew Molteno

Re: Moodle is very slow only on course page and resources.

by Andrew Molteno -
Hi Jean-François, ignore that, I see it on the course page, under the activity, thanks again.
In reply to Andrew Molteno

Re: Moodle is very slow only on course page and resources.

by Jean-François Lemoine -

Hi Andrew,

Yes no side effect, except the removal of a very interesting piece of information.

The “faulty” commit can be found here:
https://gitlab.com/jezhops/moodle-theme_adaptable/-/commit/0bb920b70e9f433288b0ed62b947e81d972b871b

I use quotation marks to “faulty” because the new code is more accurate than the previous one, but it’s also a lot slower.

I tried to raise an issue, to no end. I finally reverted back the function course_participant_count() (and its calling).

Regards.
Jean-François

In reply to Jose Galeano

Re: Moodle is very slow only on course page and resources.

by alex higgins -
To make it fast, the most effective change that you can do is to increase the RAM on your web server. Check your RAM cache and minimize disk-based activity. The RAM and memory cache are also combined and they can affect the performance of our website.
Moodle can run on most of the operating systems if you want its best performance, experts recommend a Unix-based operating system because these operating systems require less memory than any other OS. You should also increase the processor capacity for the best performance. You can use dual or quad-core processors for this. These are just some main steps that you should do to make it fast. For more in-depth details and steps, try visiting this website https://www.allspeedtest.com/