memcache slow?

memcache slow?

by Rikard E -
Number of replies: 7
We are using Moodle 2.6.5 and currently we have our moodledata NFS mounted, including all caches. We are now trying out the application cache in memcache but page rendering times seems to be slower with memcache.

Btw, we cannot use memcached because of this bug: https://tracker.moodle.org/browse/MDL-43614 . But that's another story.

If I refresh the course overview page I might get something like 0.15 secs with default NFS file caching. When I activate memcache I rather get like 0.25 secs in average instead. I have compared different pages and memcache is always slower. Another page might deliver in 1 sec and with memcache it instead maybe says 1.2-1.5 sec.

The moodle performance caching test says untestable on memcache (not on memcached though). However I can see that the memcache-server is used when it is activated.

I also made two jmeter-loadtests (500 requests 5 users per run). In that case the average response time seems to be about the same.

Run1, Run 2

Memcache:

avg: 7.7s , 6.3s

min: 0.256s , 0.275

max: 80s? , 78s

 
NFS Filesystem cache:

avg: 7.3s , 6.4s

min: 0.068s , 0.115s

max: 92s ? , 77s

So what do you all say about this? Does this seem normal?
----------------------------------
Our virtual environment:
LAMP (Ubuntu 12.04)
Three application nodes with four cores each and 8G of RAM.
MySQL server with 4 cores and 12G of RAM
NFS share for moodledata. Standard cache settings
No. users: ~10000
No. courses: ~1500
----------------------------------

Average of ratings: -
In reply to Rikard E

Re: memcache slow?

by Daniel Tran -

Try this:

your moodledata currently sits on an NFS mount.

What you need to do is only  keep moodledata/filedir on the NFS mount, the rest keep it on local disk

Do this:

- move your moodledata to a local disk, say /moodledata

- In /moodledata, create a symlink that point to "filedir" on the nfs mount (sudo ln -s <nfsmount>/filedir   /moodledata/filedir

So it will look something like:

drwxrwxr-x   7 apache apache    4096 Sep 18 11:31 cache
drwxr-xr-x   3 apache apache    4096 Feb  9  2012 codecoverage
lrwxrwxrwx   1 apache apache      31 Jun  8  2012 filedir -> /nfsmount/moodle_data/filedir
drwxrwxrwx   3 apache apache    4096 Mar 25  2012 filter
drwxrwxr-x   5 apache apache    4096 Sep 16 01:30 lang
drwxrwxr-x   3 apache apache    4096 Oct 26  2011 local
drwxrwxrwx   5 moodle moodle    4096 Sep 16 16:35 localcache
drwxrwxrwx 258 moodle moodle    4096 Sep 16 17:50 lock
drwxrwxrwx   2 apache apache    4096 Mar 14  2014 muc
drwxrwxrwx   2 apache apache 1318912 Sep 18 11:40 sessions
drwxrwxrwx   1 apache apache      16 Feb  8  2012 temp
drwxrwxrwx   4 apache apache    4096 Sep 18 09:38 trashdir

Your performance will improve.

NFS writes are very expensive.  Better to off load writes to local disk.  Filedir is the only directory would use a lot of disk space.

FYI, we were using moodle 2.5 and now 2.7.  Using memcached as MUC with both version.  No problem.

In reply to Daniel Tran

Re: memcache slow?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Daniel,
the OP is using more than one front-end i.e. unless the balancer is session friendly (sticky) you need to share the /sessions folder, not to mentions the /lock folder. Same shared issues with /cache where e.g. the theme files are saved and Purge all caches will work just for the node which your request has been sent to by the balancer. Shortly, given a load balanced environment only the /localcache folder could be installed locally to each front-end: for example /trashdir must be kept shared for the same reason you keep /filedir shared.

More info about clustering here: https://docs.moodle.org/27/en/Server_cluster.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: memcache slow?

by Rikard E -

Yes that's right, we have both localcache and tempdir located locally on each node.

In reply to Matteo Scaramuccia

Re: memcache slow?

by Daniel Tran -

Thanks for the correction. I didn't pay attention to OP's environment of having 3 application nodes smile.


In reply to Rikard E

Re: memcache slow?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Rikard,
that's strange even if the memcached module usually works faster than the memcache client (10-15%): what are the module and PHP versions? Has the memcache client been compiled from source? Any network issue between the front-ends and the memcached server?

Matteo

In reply to Matteo Scaramuccia

Re: memcache slow?

by Rikard E -

You could be right about the network, we have done some changes in that area. We have now activated memcache in our production environment. We will see what happens but I can't say that we have any downgrade in performance so far.

We are using standard php from Ubuntu:

PHP 5.3.10-1ubuntu3.13 with Suhosin-Patch (cli) (built: Jul  7 2014 18:54:55)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies


Memcache:

Version 3.0.6 , revision 310129

Memcached:

Version 1.0.2 , libmemcached v.:0.44


Apache:

Server version: Apache/2.2.22 (Ubuntu)
Server built:   Jul 22 2014 14:35:25


In reply to Rikard E

Re: memcache slow?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Rikard,
you could give phpMemcachedAdmin a try to see what is the load of your daemon and, in your test environment, try to use a more recent daemon version: if you're running Ubuntu 12.04 it should be 1.4.13.

HTH,
Matteo