How to setup memcached with Moodle?

Re: How to setup memcached with Moodle?

by Paul Verrall -
Number of replies: 4

Hi Pál,

I think you are going about this the wrong way. I don't think Nginx memcached module is suitable for Moodle. Moodle has it's own integration with memcached in the backend, and to quote from the docs for the nginx module docs...

"The ngx_http_memcached_module module is used to obtain responses from a memcached server ... A response should be put in memcached in advance by means external to nginx."

*means external to nginx* i.e. nginx does not manage the contents of memcached; only serves it.


TBH I stopped using memcached for moodle on my raspberypi deployment at moopi.uk (although this is not documented) and instead use a tmpfs with the default 'filesystem' cache for MUC.

As Matteo says your big and quick wins are in Opcache. In addition to that PHP7 gives a ~30% speed boost too if you can use it (I really have no clue when it comes to Gentoo!).

Average of ratings: Useful (2)
In reply to Paul Verrall

Tárgy: Re: How to setup memcached with Moodle?

by Pál Csányi -

Hi Matteo and Paul,

OK, then I will uninstall memcached and continue using just the PHP installed with opcache USE flag.

Here, on Gentoo linux the PHP version 7 is not yet the stable package, but is in the test branch.

# eix dev-lang/php
[I] dev-lang/php
     Available versions: 
     (5.4)  [M]5.4.45
     (5.5)  5.5.33 5.5.34
     (5.6)  5.6.19 5.6.20

     (7.0)  ~7.0.5

Installed versions:  5.6.20(5.6)(10.54.17 2016-05-02)(berkdb bzip2 cli crypt ctype curl fileinfo filter fpm gd gdbm hash iconv intl ipv6 json nls opcache phar posix postgres readline session simplexml soap ssl tokenizer truetype unicode xml xmlrpc xpm zip zlib -apache2 -bcmath -calendar -cdb -cgi -cjk -debug -embed -enchant -exif -firebird -flatfile -frontbase -ftp -gmp -imap -inifile -iodbc -kerberos -ldap -ldap-sasl -libedit -libmysqlclient -libressl -mhash -mssql -mysql -mysqli -oci8-instant-client -odbc -pcntl -pdo -qdbm -recode -selinux -sharedmem -snmp -sockets -spell -sqlite -sybase-ct -systemd -sysvipc -threads -tidy -vpx -wddx -xmlreader -xmlwriter -xslt)

I think is will be soon in the stable branch.


Thanks!

In reply to Pál Csányi

Re: Tárgy: Re: How to setup memcached with Moodle?

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

Hi Pál,
that's good approve Yes.
It's quite strange that PHP 7.0.6 is not considered stable yet.

BTW, please adopt Paul advice to let the default caching file store run as fast as possible by using tmpfs. See also https://docs.moodle.org/30/en/MUC_FAQ#What_is_wrong_with_the_default_file-system_MUC.3F and https://docs.moodle.org/30/en/MUC_FAQ#How_can_I_make_MUC_faster.3F.

HTH,
Matteo

Average of ratings: Useful (1)
In reply to Matteo Scaramuccia

Tárgy: Re: Tárgy: Re: How to setup memcached with Moodle?

by Pál Csányi -

Hi Matteo,

I just complete my Moodle site's setup by following

https://docs.moodle.org/30/en/MUC_FAQ#What_is_wrong_with_the_default_file-system_MUC.3F and https://docs.moodle.org/30/en/MUC_FAQ#How_can_I_make_MUC_faster.3F.

Steps I performed for this are on my Gentoo system:

  • emerge -aj net-misc/memcached dev-php/pecl-memcached
  • nano /etc/conf.d/memcached
    MEMUSAGE="128"
    PORT="11211"
    SOCKET="/var/run/memcached/memcached.sock"
  • /etc/init.d/memcached start
    rc-update add memcached default
  •  In Moodle
      * 'Site administration > Plugins > Caching > Configuration'
      * Under Installed cache stores look for Memcached and click the Add instance action.
      * Give the store a name, like 'Memcached_MUC'
      * In server, assuming the basic config above, type 'localhost'. Save Changes.
        This step I did leave out, because I don't understand where to do it?
      * Scroll to the bottom of the Cache administration page.
      * Under Stores used when no mapping is present click Edit Mappings.
      * In the Application drop down select the caches name. Save Changes.

What I don't know is that that how can I use tempfs for the default caching file store?


Best, Pál

Average of ratings: Useful (1)
In reply to Pál Csányi

Tárgy: Re: Tárgy: Re: How to setup memcached with Moodle?

by Pál Csányi -

OK,

what I did to set up tempfs for the default caching file store are followings:

added in to  /etc/fstab:
tmpfs                   /tmp            tmpfs           nodev,nosuid,size=128M  0 0
reboot the system

In Moodle
Dashboard > Site Administration > Plugins > Caching > Configuration / File cache / Add Instance:
Store name: add some name
Cache path: /tmp
Save Changes.

Is this the right setup?

Best, Pál