File or Database Sessions?

File or Database Sessions?

- Marcus Green の投稿
返信数: 6
画像 Core developers 画像 Particularly helpful Moodlers 画像 Plugin developers 画像 Testers
I am researching performance on a Moodle 2.5 instance that may be upgraded to 2.6
in the not too far future. We have web load balancers feeding two Debian/Apache servers
that use the Oracle OCFS clustered file system. We are using a mysql/innodb database on a
separate server. Could anyone advise on selecting between File or Database sessions.
The admin page option at

moodle/admin/settings.php?section=sessionhandling

Has a checkbox for
Use database for session information

The help next to it says
"...This is especially useful for large/busy sites or sites built on cluster of servers. "
Which I think describes our use

So I was thinking of switching to database sessions. However the documentation at
http://docs.moodle.org/27/en/sessions#Database

Says
"The performance is relatively low, it is not recommended for large sites."

Can anyone advise?

評点平均:Useful (1)
Marcus Green への返信

Re: File or Database Sessions?

- Howard Miller の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers

You almost certainly can't use file-based sessions if you are load-balancing. They need to be located in a shared-file area and the chances are that this will be far too slow (if NFS for example). 

You also shouldn't use the database on a very busy site (almost certainly you) as it can bung up the database quite easily with the high levels of activity.

If you search down config-dist.php a bit further, you will see that you can set up sessions on memcache/memcached. This is the way forward. 

A word of warning, if you are using memcache/memcached in the MUC then you will need to set up another instance for sessions. If you don't, purging the MUC caches will also throw out all your users. 

See... http://docs.moodle.org/26/en/Session_handling#Session_drivers

Howard Miller への返信

Re: File or Database Sessions?

- Marcus Green の投稿
画像 Core developers 画像 Particularly helpful Moodlers 画像 Plugin developers 画像 Testers

It looks like we are using file based sessions and they are on a shared area done through OCFS. Is there a way of getting a metric on the creation and access of sessions, i.e. to compare what happens at the moment with what would happen if it were on non shared disk space.

Marcus Green への返信

Re: File or Database Sessions?

- Jeff White の投稿
Recommend checking out moodle-performance-comparison tool. 


What do you mean by non shared disk space? If you are using a cluster then all the apache nodes need their session files on a shared location otherwise each time a user's request jumps to a different apache node they will have to log in again. 

Howard Miller への返信

Re: File or Database Sessions?

- Luis de Vasconcelos の投稿
画像 Particularly helpful Moodlers

Thanks Howard,

So memcache/memcached seems to be the only way to go for big Moodle sites. But does memcache/ memcached run well on Windows Server OS? Is it a viable way to do session management on Windows*?

I've got a test server running Memcached, but working out what Memcached is doing, how it's doing it and if it's doing it well is another story!

* Ok some may argue that nothing runs well on Windows, but lets not go there...

Luis de Vasconcelos への返信

Re: File or Database Sessions?

- Mark Picker の投稿


Hi Luis,

How did you go with setting up Memcached on Windows? I was looking at this a couple of months ago and kept hitting issues and could only use memcache not memcached.

Out of interest are you running on Windows 2012 or something earlier? We recently went from 2008 to 2012 and are having a lot of performance issues (which is why I was looking at the caching solutions).

Cheers
Mark