Magento Memcached会话 [英] Magento Memcached Sessions

查看:54
本文介绍了Magento Memcached会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试通过以下设置为Magento建立生产环境:

I am currently trying to set up a production environment for Magento with the following setup:

2个Web服务器,1个DB服务器,负载均衡器.

2x Web Server, 1x DB server, Load Balancer.

因此,负载平衡器将在Web服务器之间分配流量,但不会使用粘性会话.

So the load balancer will be distributing the traffic between web servers but will not be using sticky sessions.

为解决服务器之间共享会话的问题,我选择使用Memcached.我有一个在每个Web服务器上运行的Memcached服务器,然后在每个Web服务器上的local.xml中指定了Memcached服务器列表.

To tackle the problem of sharing sessions between servers I have chosen to use Memcached. I have a Memcached server running on each webserver and have then specified the list of memcached servers in the local.xml on each web server.

因为我确实注意到速度有所提高,所以缓存正在工作,而且我可以看到会话正在Web服务器之间共享.问题在于缓存工作得太好了.页面的动态部分(例如购物车和消息)将完全为每个页面缓存.

The cache is working since I definitely notice an increase in speed, plus I can see the sessions are being shared across web servers. The problem lies in the fact that the cache is working a little too well. The dynamic portions of the page (such as the cart and messages) are being cached entirely for each page.

我注意到,您调用以将购物车放到页面上的getChildHtml()具有一个称为useCache的可选参数,我明确地将其传递为false,但这不会执行任何操作.这是我的local.xml定义,以防万一我在那做错了(敏感信息已被忽略):

I've noticed that the getChildHtml() that you call to put the cart on the page has an optional parameter called useCache which I am explicitly passing in false but this does nothing. Here is my local.xml definition just in case I've done something wrong in there (sensitive information has been left out):

<config>
<global>
    <install>
        <date></date>
    </install>
    <crypt>
        <key></key>
    </crypt>
    <disable_local_modules>false</disable_local_modules>
    <resources>
        <db>
            <table_prefix></table_prefix>
        </db>
        <default_setup>
            <connection>
            </connection>
        </default_setup>
    </resources>
    <session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files -->
    <session_save_path><![CDATA[tcp://X.X.X.X:11211?persistent=1&weight=2&timeout=10&retry_interval=10]]></session_save_path><!-- e.g. for memcache session save handler tcp://10.0.0.1:11211?persistent=1&weight=2&timeout=10&retry_interval=10 -->
    <session_cache_limiter><![CDATA[private]]></session_cache_limiter><!-- see http://php.net/manual/en/function.session-cache-limiter.php#82174 for possible values -->
    <cache>
        <backend>memcached</backend><!-- apc / memcached / xcache / empty=file -->
        <slow_backend>database</slow_backend> <!-- database / file (default) - used for 2 levels cache setup, necessary for all shared memory storages -->
        <slow_backend_store_data></slow_backend_store_data> <!-- 1 / 0 (default) - used for 2 levels cache setup, sets whether store data in db slow cache backend -->
        <auto_refresh_fast_cache>1</auto_refresh_fast_cache> <!-- 1 / 0 (default) - used for 2 levels cache setup, sets whether refresh data in fast cache backend -->
        <memcached><!-- memcached cache backend related config -->
            <servers><!-- any number of server nodes can be included -->
                <server>
                    <host><![CDATA[X.X.X.X]]></host>
                    <port><![CDATA[11211]]></port>
                    <persistent><![CDATA[1]]></persistent>
                </server>
                <server>
                    <host><![CDATA[X.X.X.X]]></host>
                    <port><![CDATA[11211]]></port>
                    <persistent><![CDATA[1]]></persistent>
                </server>
            </servers>
        </memcached>
    </cache>
</global>
<admin>
    <routers>
        <adminhtml>
            <args>
                <frontName><![CDATA[admin]]></frontName>
            </args>
        </adminhtml>
    </routers>
</admin>

我还注意到了其他一些奇怪的行为,例如能够在管理面板上的缓存管理"屏幕中清除缓存.在Magento中使用memcached时,这是否正常?我该如何解决整个页面都被缓存的问题?

I've also noticed other strange behaviour like to being able to clear the cache in the cache mangement screen on the admin panel. Is this normal when using memcached in Magento and how can I tackle the problem of the entire page being cached?

推荐答案

对于仍然遇到类似问题的任何人,我都设法解决了我的问题.我在这里遇到的主要问题是,我在每个Web节点上使用了不同的内存缓存服务器,这是不正确的,因为它使用会话作为查找缓存数据的键.另外,您需要确保将server标记中的persistent元素设置为0而不是1.通过这些设置,网站现在可以正常工作.

For anyone that's still having a problem similar to this I've managed to solve my problem. The main issue I had here was that I was using a different memcached server on each web node which was incorrect since it uses your session as a key to look up cached data. Also, you need to make sure that you set the persistent element in the server tag to 0 instead of 1. With these settings in place the site is working fine now.

这篇关于Magento Memcached会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆