moving ezsession - user cache info to memcache

Author Message

Stéphane Couzinier

Saturday 30 August 2008 2:02:28 am

Hi

We are thinking about moving ezsession to memcache.
Somebody have already try it?

In more case our system crash because we have a lot of query on the ezsession table
and the table is lock all the time.
Of course we can use a master/slave database but it won't resolve all the pb.

 

http://www.kouz-cooking.fr

Maxime Thomas

Sunday 31 August 2008 2:22:19 am

Hi,
We also got this kind of problem specially on high visibility websites.
Our solution was to put a cron in order to clean up the table ezsession.
I'm not sure that memcache is a solution for this, but if you try it, just give us your feedback.

Maxime Thomas
[email protected] | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

André R.

Sunday 31 August 2008 7:18:29 am

Haven't tested it, but a first step to be able to have custom session handler (without hacking ezp):
http://issues.ez.no/IssueView.php?Id=13443&

The recommendations I've seen online is to use memcache for cache, but keep db as the storage. In other words get data from db if it's not yet in memcache, and have a flag that says if session has been written to. If it has, then write session data from cache to db at the end of the request ( with eZExecution::addCleanupHandler ).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Maxime Thomas

Sunday 31 August 2008 12:46:19 pm

hi andré,
I would like to know why the sessions are stored in db and why when there's a lot of simultaneous connections the db querries are so slow.
Is memcache a real alternative to the actual mecanism ?

Maxime Thomas
[email protected] | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Paul Borgermans

Sunday 31 August 2008 1:41:50 pm

>I would like to know why the sessions are stored in db and why when there's a lot of simultaneous >connections the db querries are so slow.
>Is memcache a real alternative to the actual mechanism ?

Not tried yet for sessions, but while the response time with memcached isn't that much faster than a DB under low load, it scales much better under high load.

What is scheduled for development soon (right after 4.1 is released -- which won't take that long), is a refactoring of all cache mechanisms (and add it for places in the kernel which are eligible for caching). The basic idea is:

- introduce hierarchical caching in front of persistent storage
- you can turn this on/off depending on your needs
- clustering is taken into account upfront

As the design phase is not finished at this point, I'm reluctant to tell you more now, but for bleeding edge discussions, feel free to contact me directly. Once the details are known, it will be shared with all

Best regards
Paul

 

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Gaetano Giunta

Sunday 31 August 2008 4:47:30 pm

"why the sessions are stored in db" ?

two very simple reasons:

- security: putting that data in the filesystem is very prone to information leaks

- scalability/availability: when session info is in the db, you can have many webservers serving up pages for the same site with a simple load balancer (ie. round robin). If session data was on disk, you would need to have a load balancer with session stickiness (not so cheap), and then the failure of one webserver would mean a part of the users loose their sessions anyway.

afaict, the best approach to scalability would be not using memcache, but rather putting all the session info in the cookie, and encrypt it. Yahoo does it (they use custom-bilt php extensions for doing the encription at the desired speed).

Principal Consultant International Business
Member of the Community Project Board

André R.

Monday 01 September 2008 12:46:14 am

afaict, the best approach to scalability would be not using memcache, but rather putting all the session info in the cookie, and encrypt it. Yahoo does it (they use custom-built php extensions for doing the encryption at the desired speed).

That could work to, but we would need to use one of the standard php extensions for encryption(imho).
And we would need to change all sensitive data storage to use ezpreference or something similar, encryption or not, some of our clients have higher security requirements then the average web app(also imho).

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Stéphane Couzinier

Monday 01 September 2008 9:16:26 am

Hi

Andre/Paul ... do you know when(if) the patch from andre will be integrate in the kernel.

Stephane

http://www.kouz-cooking.fr

Paul Borgermans

Monday 01 September 2008 9:53:13 am

@Stephane: we'll consider it as part of 4.1, in which many more performance patches and a refactoring of the autoload mechanisms will be done

hth

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Stéphane Couzinier

Monday 01 September 2008 2:04:30 pm

I would like to know why the sessions are stored in db and why when there's a lot of simultaneous connections the db querries are so slow.

From mysql
http://dev.mysql.com/doc/refman/5.0/en/query-cache.html
The query cache is extremely useful in an environment where you have tables that do not change very often and for which the server receives many identical queries.
->ezsession are update all the time and the query are never the same.

another article
http://www.mysqlperformanceblog.com/2006/07/27/mysql-query-cache/

http://www.kouz-cooking.fr

Nicolas Lescure

Thursday 06 May 2010 1:03:51 am

Hi all.

Months later, is there any news on ez publish and memcache support ?

I found those community extensions :

  1. http://projects.ez.no/lamemcache
  2. http://projects.ez.no/memcachedcluster

Do you have any feedback ?

Is there another way to use memcache ?

How to use memcache for ezpublish cache ? 

Thanks.

Bertrand Dunogier

Thursday 06 May 2010 1:42:18 am

It hasn't been implemented yet, but it is still part of the current plans.

Regarding sessions, for instance, file / memcache DB sessions, with session-less anonymous users should be part of eZ Publish Fuji (4.4).

Memcache for standard cache will be implemented through ezcCache, using hierarchical caching. This should also make APC based cache possible. However, this won't happen through little patches and attempts, but only when a rock solid cache API is ready, as we won't invest efforts in temporary features.

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.