Memcache Configuration

Memcache Configuration

by Mark Williams -
Number of replies: 8

Hi All,

We're using a load balanced WAMP setup here and managing php through Zend Sevrer. I have enabled memcache on both webservers, but I'm assuming I should just point moodle to one cache store. I'm using the ipaddress of one of the servers in the memcache store setup screen, but when I save the configuration and try mapping to it, I get a "store not ready message".

Have I set this up in the correct manner?

and

What do I need to do to  "check that the store backend is ready to be used and that any PHP requirements are met."?

Cheers,

 

Mark 

Attachment Screen Shot 2013-08-16 at 10.21.25.png
Average of ratings: -
In reply to Mark Williams

Re: Memcache Configuration

by jason everling -

Did you enable memcache in PHP like so;

Add the memcache.ini in the /etc/php5/conf.d/ ? or add it to the php.ini file.

For ours I did;

echo "extension=memcache.so" | sudo tee /etc/php5/conf.d/memcache.ini

For windows you would add the .ini to the appropriate folder in the WAMP folder. If you need to manually create it just create a new file and add extension=memcache.so to the first line then do a File, Save As, "memcache.ini" . You have to use the quotes in the name field. Then put into the correct folder.

After enabling memcache in PHP, you should do a restart. 

Also I think in Windows you just have to add extension=php_memcache.dll to the php.ini file after you place the dll into the ext folder . We only have a few Windows servers but none that run any web applications.

After you get it added to PHP you should also change the default memory available to memcache which is 64mb. It is in the registry under, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached Server under the ImagePath key. Change to at least 128mb or if you can spare memory 512mb or higher.

JASON

In reply to jason everling

Re: Memcache Configuration

by Mark Williams -

Memcache is definitely enabled in PHP. and I've given it maximum available memory. As we're using sticky sessions which last 8  hours, would this negate the need for using Memcache?

In reply to Mark Williams

Re: Memcache Configuration

by jason everling -

Have you verified memcached.exe service is running? Using memcache for the MUC will help boost the overall performance.

You can check this script to see if memcache is working properly, you can save it as anything like memtest.php or whatever, just save it to a webroot and make sure it is executable.

<?php
$memcache = new Memcache;
$memcache->connect("localhost",11211); # You might need to set "localhost" to "127.0.0.1"
echo "Server's version: " . $memcache->getVersion() . "<br />\n";
$tmp_object = new stdClass;
$tmp_object->str_attr = "testing";
$tmp_object->int_attr = 123456;
$memcache->set("key",$tmp_object,false,10);
echo "Store data in the cache (data will expire in 10 seconds)<br />\n";
echo "Data from the cache:<br />\n";
var_dump($memcache->get("key"));
?>

JASON

In reply to jason everling

Re: Memcache Configuration

by J S -
If you just want to verify that you can connect to a memcached service, another test can be to just telnet to the port. Example: $ telnet $ telnet localhost 11211 Once you connect to the service, you can pull memcached stats by typing "stats". This is how we monitor our memcached servers for hits, misses, evictions, etc. Jason's is a more complete answer if you are testing to ensure that the memcached module is working within php.
In reply to J S

Re: Memcache Configuration

by J S -
Wow...that post got a little jacked up...
$ telnet <host> <port>
Example:
$ telnet 192.168.0.3 11211

Once connected, you can type "stats" and that will display the current stats.
 
In reply to Mark Williams

Re: Memcache Configuration

by Matteo Ricci -
Hi everybody,
  
   we are try to find a way to prevent the loss of sessions in a cluster with moodle 2.5 when a server goes down. 
After a couple of days of search for information, the two best solutions that do not need code modification are:
 
memcached with repcached;
or memcache ( > 3.0 ) with redundancy parameters.
 
Does anyone have experience about those solutions? Which way is better ?
 
Thanks,
In reply to Matteo Ricci

Re: Memcache Configuration

by J S -

 Never heard of repcached but we use dual memcached VMs to back our web fleets.  The only problem is that if your memcached services crash/drop/restart you lose sessions.  Works well for us. 

In reply to Matteo Ricci

Re: Memcache Configuration

by jason everling -

Instead of using repcache you can setup Couchbase as a drop in replacement for memcache. It is automatically made Highly Available and Persistant at the cluster level. You would install Couchbase and add a "memcached" bucket type. Point memcache config to couchbase IP,

http://www.couchbase.com/memcached

Thanks,

JASON