Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Inconsistent behavior between using memcache and db for sessions
 
Carumba
Jr. Member
 
Total Posts:  18
Joined:  2009-02-27
California
 

Looking at the heading information, it appears that when using memcache as session cache, no Expires/Cache-Control headers are being emitted.

This is with memcache (sessions and backend cache):
a002:/tmp$ curl -I http://shop.carumba.org/
HTTP/1.1 200 OK
Server: Hai
Date: Thu, 05 Mar 2009 06:53:11 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: frontend=fec52b626f1f147e1585d4c4f376cc8f; expires=Thu, 05 Mar 2009 07:53:10 GMT; path=/; domain=shop.carumba.org; HttpOnly

Using db sessions, I get:
a002:/tmp$ curl -I http://shop.carumba.org/
HTTP/1.1 200 OK
Server: Hai
Date: Thu, 05 Mar 2009 07:31:08 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: frontend=7487d341dcd8f6cdcf95f0c333d90c7e; expires=Thu, 05 Mar 2009 08:31:08 GMT; path=/; domain=shop.carumba.org; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

As you can see, the Expires and Cache-Control are now set.

Even though they are set, I am having trouble finding the “right” way to override them as I would like to have things set to be “public, must-revalidate, max-age=300”

This way, I can experiment with sticking a Varnish cache in front of Magento to aid in caching already rendered pages.

PS: It also appears to me that using the memcache backend appears to cache a lot less data in memcache vs APC (several hundred KB to 20-30MB). What gives?

 
Magento Community Magento Community
Magento Community
Magento Community
 
powerhosting.dk
Guru
 
Avatar
Total Posts:  549
Joined:  2008-10-20
 

Hi JHO.

Are you setting the correct ‘session_cache_limiter’ when using memcache ?  php-manual-here

Would you mind terrible to share your memcache-section of /app/etc/local.xml ?

With varnish, do you plan to strip cookie/session data from the request in order to cache it ?

We are quite keen on getting Magento to play well with Varnishd, would you be interested in joining forces there ?

Best regards.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Carumba
Jr. Member
 
Total Posts:  18
Joined:  2009-02-27
California
 

@powerhosting,

Sure I would be happy to share my memcache config. I can see memcache being used via memcache.php (http://cvs.php.net/viewvc.cgi/pecl/memcache/memcache.php?view=markup)

<session_save><![CDATA[memcache]]></session_save>
<session_save_path><![CDATA[tcp://localhost:11211?persistent=1&weight;=1&timeout;=1&retry;_interval=15]]></session_save_path>
<session_cache_limiter><![CDATA[must-revalidate,public]]></session_cache_limiter>
<cache>
<backend>memcached</backend><!-- apc / memcached / empty=file -->
<memcached><!-- memcached cache backend related config -->
<servers><!-- any number of server nodes can be included -->
<server>
<host><![CDATA[127.0.0.1]]></host>
<port><![CDATA[11211]]></port>
<persistent><![CDATA[1]]></persistent>
</server>
</servers>
<compression><![CDATA[0]]></compression>
<cache_dir><![CDATA[]]></cache_dir>
<hashed_directory_level><![CDATA[]]></hashed_directory_level>
<hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
<file_name_prefix>alphanumeric</file_name_prefix>
</memcached>
</cache>

With varnish, there will need to be some tricks with cookies as you implied.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kerry Hatcher
Sr. Member
 
Avatar
Total Posts:  96
Joined:  2008-07-15
Macon, GA
 

Just would like to get some feed back on a project I’m working on. I drew a lot of my ideas from the post so I thought I’d share back.

The idea is to use:
A memcache to share session data (which is highly scalable)
A NFS server to share web data (the php, image, css, etc, files) across the web-servers
2 or more web-servers
load balancer / firewall to split the load between the web servers.
A SQL server
A extra SQL server slave for every few web-servers.

A note about the NFS server. The share will be held in Ramdisk. I know this could be dangerous but that data doesn’t change often. I envsion a cron job pulling a copy off ram into a folder on disk every hour or so and a statup script to mount the Ramdisk and copy it back from the harddrive. I just figured that speed is more important than anything else here.

I’m currently working towards a cluster of VM’s, across several physical hosts (1 VM per host).  I’ll attach a diagram of what I’m doing.

I haven’t fully implemented this yet and it is only mostly tested. The system can be rolled out in stages as demand grows. If you have any questions please feel free to email me at kerry@hatchmediapro.com

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top