Skip to content

[Deprecated] A previous labs feature for using memcache(d) for caching DFS Cluster metadata

License

Notifications You must be signed in to change notification settings

ezcommunity/ezmemcachedcluster

Repository files navigation

eZ Memcached cluster

[Deprecated] This extension adds cluster events support with Memcached backend server.

Requirements

Install

  • Activate the extension
  • Regenerate autoloads
  • In settings/override/file.ini.append.php, add:
[ClusterEventsSettings]
ClusterEvents=enabled
Listener=eZMemcachedClusterEventListener

Using Memcached PECL extension

Memcached PECL extension is currently the recommended way for communication with Memcached server.

  • Make an override of memcachedcluster.ini in settings/override and customize default values (like adding some Memcached servers). Placing it in the global override directory is mandatory to workaround cluster limitations about very early loading.
    IMPORTANT: Be sure to have all the default values in settings/override/memcachedcluster.ini.append.php (make basically a copy of all default values)

Example:

[ServerSettings]
Servers[]=memcachedhost1:11211;34
Servers[]=memcachedhost2:11211;66

ConnectionTimeout=2000
  • Copy content of eZMemcachedCluster's config.php.RECOMMENDED to config.cluster.php at eZ Publish root. Here you can configure it the way you want, adding servers, modifying options via eZMemcachedClusterOptions object.
    Note that every options MUST reflect configuration placed in memcachedcluster.ini (see comments in default INI file).

Example following previous INI configuration example:

<?php
// config.cluster.php
require 'extension/ezmemcachedcluster/autoloader.php';

// instanciating the autoloader is enough, no need to assign it to a variable or call anything
new eZMemcachedAutoloader;

// Let's add 2 servers, with some weight.
// See extension/ezmemcachedcluster/settings/memcachedcluster.ini for more information.
$options = new eZMemcachedClusterOptions;
$options->servers[] = 'memcachedhost1:11211;34';
$options->servers[] = 'memcachedhost2:11211;66';
// Now let's modify the connect timeout
$options->connectTimeout = 2000;
// For other options, see extension/ezmemcachedcluster/classes/ezmemcachedoptions.php

// The following should not be modified
$memcachedConfiguration = new eZMemcachedClusterConfigurationManual(
    $options, new eZMemcachedClusterClientMemcached()
);
eZMemcachedClusterGatewayMySQLi::setConfiguration( $memcachedConfiguration );
ezpClusterGateway::setGatewayClass( 'eZMemcachedClusterGatewayMySQLi' );

Using Memcache PECL extension

If you prefer to use Memcache (though not recommended)

In addition to previous settings explained for Memcached client, you will need to change the following in settings/override/memcachedcluster.ini.append.php:

[ClientSettings]
BackendClient=eZMemcachedClusterClientMemcache

And in config.cluster.php, replace:

$memcachedConfiguration = new eZMemcachedClusterConfigurationManual(
    $options, new eZMemcachedClusterClientMemcached()
);

By:

<?php
$memcachedConfiguration = new eZMemcachedClusterConfigurationManual(
    $options, new eZMemcachedClusterClientMemcache()
);

Memcached server backend

  • Start your Memcached server(s) with your preferred options.

If everything is OK, cluster queries count appearing in the debug output should be drastically reduced once cache has been generated (no query most of the time).

Debugging

Memcached keys watch

Several tools can be used in order to watch/adminitrate Memcached servers.

You might consider PHPMemcachedAdmin for debugging purpose. It will help you check keys stored in Memcached.

Logging

If something is going wrong for any reason, you might want to activate error logging to see what happens. To do that, you need to enable clustering conditional debug:

# In an override of debug.ini
[DebugSettings]
ConditionDebug=enabled

[GeneralCondition]
kernel-clustering=enabled

Additionnaly, any errors occuring via index_cluster.php (like while serving binary files) are logged in the default PHP's error_log.

Flushing Memcached

If for some reason you need to flush Memcached keys from eZ Publish, you can use bin/php/ezcache.php script for that:

php bin/php/ezcache.php --clear-id=ezmemcachedcluster

About

[Deprecated] A previous labs feature for using memcache(d) for caching DFS Cluster metadata

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages