This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Discussions » eZ session using...

eZ session using memcached....Performance

eZ session using memcached....Performance

Tuesday 27 December 2011 10:03:49 am - 8 replies

I have a client Database using 40GB only for ezsession Table. Sure I can bind "update/common/scripts/cleanup.php expired_session" in the daily or weekly cronjob, but the Idea is to use memcached to store,manage the sessions and to for quick access. How to configure eZ session Handler to use the memcached.are there any disadvantages to store eZ session in the The physical memory?

Tuesday 27 December 2011 2:51:24 pm


I don't have an experience of such a deployment but theoretically the main disadvantage is that data is not persistent : if your memcached service is restarded, all your active sessions are gone.

Should be a problem mainly if you use long life sessions ("Remember me" cookie) and maybe there are ways to backup/revover memcached state when you have to reboot for administrative/update purpose.

Tuesday 27 December 2011 3:32:59 pm

Hi Hugues,

I m agree with you "Memcache has no dump feature to move all its contents directly to a file and also no index feature to list the keys of all the stored data items." I've heard :itis possible to make a backup but it must be hard coded.although memcached is a good/ quickly solution to manage sessions, but if system crached or will be reboot it, then this is a big problem with not expired sessions.

Tuesday 27 December 2011 8:31:15 pm

For anyone feeling brave enough to depend on beta software, using mysql 5.6 might be a solution: they implement the memcache daemon inside the db, and store the data in tables for persistence. Kind of "best of both worlds".

about 40gb of session data:

1 - are you sure the gc_probability is set to > 0 in php.ini and that sessions are garbage-collected at all?

2 - are you storing a lot of custom data in the sessions? Maybe this might be improved by changing the custom code that does it

Saturday 31 December 2011 12:40:08 pm

Hi Giunta,

sorry, my database is 40 GB, the ezsession Table is ~ 6GB.

I have following php.ini setting:

session.gc_probability = 1
session.gc_divisor     = 1000         //because traffic is greater than 100,000 per day
session.gc_maxlifetime = 28800

In the sessions are not a lot stored of data , but expired session are not automatically destroyed. Thats why i have bind for the moment the cleanup.php in the daily cronjob.

Monday 02 January 2012 9:51:51 am

Hi Ramzi,

Maybe an alternative is to use mysql-proxy and mysql-proxy-lua library. I never tested this method but some website use it. Its totaly transparent for your application.


Here is directive with Debian lenny :

 aptitude install lua5.1 liblua5.1-md5-0 liblua5.1-socket2 luarocks

Luamemcached library is actually not on offcial lenny repository, but you could download it via

dpkg -i liblua5.1-memcached0.deb

Same for mysql-proxy-cache via git

git clone git://

Copy lua file to /usr/share/mysql-proxy/mysql-proxy-cache.lua
Now edit configuration file on /etc/default/mysql-proxy :


Start mysql-proxy and check on memcached if all is running correctly via stats command. 

Modified on Monday 02 January 2012 9:55:43 am by Philippe Vincent-Royol

Thursday 19 January 2012 10:01:09 am


I have succefully implemented ezPublish using memcached. I use it now in one server where no higher Traffic registered. But i think in higher Traffic Server, it will be better to restart memcached when the Traffic is lower and no many user are logged in. sure we must alert them bevor. We can also use other Server as memcached blunk.gif Emoticon  . Generally, using Memcache::addServer and at least it will be easy to add one Server as memcached  and restart the other.

Here are some instruction how to prepare the Platform to be able to use memcached with eZPublish:

1.Install memcached and the php extension:

  • $ apt-get install memcached php5-memcache

2. Proof if memcached Listen on tcp port:

  • $ netstat -tap | grep memcached

3.Configure php.ini

  •     session.save_handler = memcache
  •     session.save_path="tcp://"

6. Configure eZ to use php session handler in(../override/site.ini.append.php):


7. Actualize your Website and show memached Status:

  • $ echo "stats items" | nc 11211

     ->Output something like:

         STAT items:2:number 2
         STAT items:2:age 1695



That' s All happy.gif Emoticon . May be it will be help some developper.


Interessant memcached File:

      /etc/default/memcached            //enable or desable memcached
     /etc/memcached.conf                //config file
     /etc/php5/conf.d/memcache.ini   //Module activated
     /var/log/memcached.log             //log file


@ VINCENT-ROYOL : Than you for your Post. I will be try it, it seems very interessant solution.

Modified on Thursday 19 January 2012 10:06:19 am by Ramzi Arfaoui

Thursday 19 January 2012 1:37:37 pm

Nice example of use, we will try to add this to the eZ Publish documentation as soon as we have some more experience with this setup (as in verified/tested by QA). Eventually this would be the recommended way to setup sessions on cluster installs if sessions are guaranteed to be persisted across restart/crash. EDIT: Which is not the case, so we should probably find another key value store that is fast (Redis?) and provide a memcached compatible api, or provides a php plugin with session handler (Zends Server session handler), or we need to write our own handler using memcached to cache the session data in db (so stored both places).

@Ramzi: Did you also try/consider the "memcached" php extension? See StackOverflow and memcached/wiki/PHPClientComparison

Should be noted that ForceStart=enabled is only needed if you have a dependency on session values like LastAccessesURI for anonymous users, as it will always start the session even if it is not used in this case.

Modified on Tuesday 24 January 2012 11:11:52 am by André R

Friday 27 January 2012 11:40:04 pm

My little experience with memcached  was very nice and succefully . Sure I use the new php extension memcached . Also a memcached replication is possible, there is a replication(Master/slave) possibility using repcached , but this patch is not a stable version for use. I have try it on Gentoo and Ubuntu but it don’t give the desired result. But the installation was succefully only  in a Debian machine. The installation will breaking and the patch documentation(only the path use in active memcached environment  ) it’ s not precise. Sure I don’t want to save many data in the memcache , but only saving ez-sessions as semi persistent data but at any rate without a replication. But I think the question is how can the admin detect a memcached crash and to switch directly to the Slave machine in the cluster. Another solution is to use data machine cluster like couchbase . the project is very interesting and  provides the possibility to use many replication to guarantee a valid recovery. I will take care of it  as a next Step happy.gif Emoticon

 Sure the ForceStart=enabled is an option. If u want to register all user movement blunk.gif Emoticon

 Here are some link to repcached, how to :


Configuring repcached service on Debian/Ubuntu


Verteiltes Caching mit memcached


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from