Magento Expert Forum - Improve your Magento experience

View Poll Results: Are you using a caching strategy with Magento?

Voters
4. You may not vote on this poll
  • No

    0 0%
  • Memcached

    0 0%
  • APC

    1 25.00%
  • XCache

    0 0%
  • Redis

    4 100.00%
  • Other

    0 0%
Multiple Choice Poll.
Results 1 to 3 of 3

How to speed up Magento with Memcached fast backend cache

  1. #1
    Junior Member Sindre@ProperHost's Avatar
    Join Date
    Nov 2013
    Posts
    12
    Thanks
    0
    Thanked 1 Time in 1 Post

    Thumbs up How to speed up Magento with Memcached fast backend cache

    In the default configuration, Magento use the file system to store the cache. This is slow especially with traditional SATA disks, but even if faster Solid State Disks are used, great performance improvements can be achieved by replacing the file system with a faster cache backend. In this tutorial we will show you how to use Memcached with Magento, a memory based object cache that removes IO latency and speed up page loads significantly.

    Magento has a flexible plug-in architecture which makes it really simple to replace the cache implementation. The cache uses a two-level design, a fast backend which stores the most frequently accessed data, and a slower (but bigger) cache used to store data that does not fit in the fast backend. We will use Memcached for the fast backend and the database as the slower backend to get the benefits of both speed and storage capacity.

    To enable the Memcached backend in Magento, edit the app/etc/local.xml as following:

    Code:
    <global>
     ...
        <cache>
          <backend>memcached</backend>
          <slow_backend>database</slow_backend>
          <fast_backend>Memcached</fast_backend>
          <fast_backend_options>
            <servers>
              <server>
                <host>Memcached address or socket</host>
                <port>0</port>
                <persistent>0</persistent>
              </server>
            </servers>
          </fast_backend_options>
    
          <memcached>
            <servers>
              <server>
                <host>Memcached address or socket</host>
                <port>0</port>
                <persistent>0</persistent>
              </server>
            </servers>
          </memcached>
        </cache>
     ...
    </global>

    In the host setting above you need to type in the address where your Memcached server is running. It also accepts a unix socket in the following format: unix:///path/to/memcached.sock.

    Magento is now configured to use Memcached and you should immediately notice a performance improvement! To verify that Memcached is working, you can telnet to the Memcached server or use the nc command through SSH to connect directly to the socket. Then type "stats".

    Code:
    # nc -U /path/to/memcached.sock
    stats
    STAT pid 608573
    STAT uptime 604274
    STAT time 1386238869
    STAT version 1.4.4
    STAT pointer_size 64
    STAT rusage_user 3.598452
    STAT rusage_system 21.105791
    STAT curr_connections 1
    STAT total_connections 1363
    STAT connection_structures 18
    STAT cmd_get 187986
    STAT cmd_set 4559
    STAT cmd_flush 0
    STAT get_hits 157590
    STAT get_misses 30396
    STAT delete_misses 21
    STAT delete_hits 13
    STAT incr_misses 0
    STAT incr_hits 0
    STAT decr_misses 0
    STAT decr_hits 0
    STAT cas_misses 0
    STAT cas_hits 0
    STAT cas_badval 0
    STAT auth_cmds 0
    STAT auth_errors 0
    STAT bytes_read 36698235
    STAT bytes_written 5522895521
    STAT limit_maxbytes 67108864
    STAT accepting_conns 1
    STAT listen_disabled_num 0
    STAT threads 4
    STAT conn_yields 0
    STAT bytes 17152993
    STAT curr_items 716
    STAT total_items 4559
    STAT evictions 0
    END
    Here are some interesting numbers:

    Code:
    STAT total_connections 1363
    STAT get_hits 157590
    STAT get_misses 30396
    STAT bytes 17152993
    STAT evictions 0
    get_hits should be considerably higher than get_misses. If evictions is > 0 it means cache entries were removed to free space for new items. If you are seeing a high eviction rate, you should increase the memory available to Memcached.

    This tutorial is based on this blog post.

    View more threads in the same category:


  2. #2
    Junior Member
    Join Date
    May 2014
    Location
    India
    Posts
    28
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    That was a useful post!!

  3. #3
    New member
    Join Date
    Aug 2014
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi I was wondering if Ishould change my current set up and add a <slow_backend>
    My current one is this
    cache>
    <backend>memcached</backend>
    <prefix>test_</prefix>
    <memcached>
    <servers>
    <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><![CDATA[]]></file_name_prefix>
    </memcached>
    </cache>
    How should I change it?
    Thanks

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •