Moodle Connection Time Out Issue

Moodle Connection Time Out Issue

by N B -
Number of replies: 6

Recently, we've been encountering connection time out issues on our Moodle site. We have seen Moodle be sluggish in performing before but now we're getting connections that are timing out. It is happening very frequently too. I've raised this issue with our hosting provider Rackspace. We're on their cloud sites hosting (not the server hosting). They have been telling me that the issue lies with these slow SQL queries on the MYSQL database in regards to how Moodle handles sessions. They have sent me the slow logs and I can see that Moodle is running these SELECT GET_LOCK queries on the database that are taking up to almost 2 minutes to complete.

I've pored over Moodle's performance recommendation guide:
http://docs.moodle.org/22/en/Performance_recommendations

There's a limited amount of things I have access to as we're not hosting the server ourselves. I've increased the php memory limit to 512M as well as done a few other minor performance tweaks (decreasing the log life time, disabling track read posts, auto mark read, etc). There are some other things such as disabling automatic backups that I have done. The other thing I changed that I thought would help was changing the session handling from database to file based sessions. However, changing that didn't seem to have much of an effect either. We're still getting connection timed out issues.

What Rackspace was telling me was happening is that our Moodle site is trying to load something, most likely running a query on the database that is taking too long to complete. The load balancer on Rackspace sees that it is taking too long and closes the connection because no data is being sent back after the initial request.

We're running Moodle version 2.4.5 (Build: 20130708).

We've been running Moodle for a couple of years now on Rackspace with no issues. We've had sluggish performance before but never to the point where our connections are timing out.

Can anyone provide any clues as to where I can start resolving this issue? Thank you very much!

Average of ratings: -
In reply to N B

Re: Moodle Connection Time Out Issue

by james mergenthaler -

You may want to check the moodle server session handling setting.  I had a problem like this once, users sessions timing out during long quizzes, or at least them starting a quiz, then walking away and trying to submit much later and their session had timed out. 

I changed the timeout setting to 4 hrs.

Site Admin | Server | Session handling.

This is on a moodle 2.2 instance.

In reply to N B

Re: Moodle Connection Time Out Issue

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

Hi, did you ever manage to get the performance of your moodle server under control? We too are experiencing timeouts a lot on our own server, running 2.6.8. I'm try to pass additional ideas to our IT guys..

In reply to Przemek Kaszubski

Re: Moodle Connection Time Out Issue

by Katie Pritchard -

I'm having the same issue. Did you ever get your issue figured out?


In reply to Katie Pritchard

Re: Moodle Connection Time Out Issue

by Przemek Kaszubski -
Picture of Particularly helpful Moodlers Picture of Testers

In our case, as it turned out, the problem was the Piwik analytics plugin installed on the same server. At peak usage times this multiplied the number of connections to the database (or the server) needed. We tried maximising the number of connections declared in /etc/mysql/my.cnf :

max_connections        = 300

cf. https://moodle.org/mod/forum/discuss.php?d=274077

Among others this was helping us:

http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html 

In the end, however, we were forced to switch off Piwik. We're now using a cloud-based subscription, and all systematic time-outs are gone.

Maybe you too have something installed on your server(s) that Moodle connects to and exceeds its config limit?

HTH.

Average of ratings: Useful (1)
In reply to Przemek Kaszubski

Re: Moodle Connection Time Out Issue

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

With my moderator hat on... please don't bring ancient threads back from the dead. I've almost never seen anybody reply to these "did you ever fix it?" posts. You'd be much better starting a new thread with *full details* of your problem. 

In reply to Howard Miller

Re: Moodle Connection Time Out Issue

by C Behan -

Hi Howard,


That may be true but I, and I'm sure many others, often end up on these old discussions when searching for solutions. Often the "did you ever fix it?" posts show that the issue remains or is a common problem, and often there is a fresh response. Better to be able to trawl through one discussion than several in my opinion! smile

Average of ratings: Useful (1)