The difference between memcache, memcached and Groupcache

Source: Internet
Author: User
Tags php language
This is a creation in Article, where the information may have evolved or changed.

For the PHP language, PHP uses memcache has two modules, called Memcache and memcached, respectively, their differences look at the following table:

Reference: http://hi.baidu.com/tony_wd/item/605e959241f87c8c59146164

For other scenarios:

Memcache is the name of this cache entry (http://memcached.org/), and memcached is its server-side main program file name.

Memcached author Brad Fitzpatrick (Blade Fize Patrick) developed an alternative version of the former with go: Groupcache (https://github.com/golang/groupcache).

Similarities between Groupcache and memcached:

Through key sharding, and through key to query the response peer.

The difference between Groupcache and memcached:

1. There is no need for separate settings for the server, which will significantly reduce the amount of deployment and configuration. Groupcache is both the client library and the server library, and connects to your peer.

2 a cache filtering mechanism. It is well known that when the memcached "Sorry,cache miss (cache loss)" occurs, the database (or other components) is often caused by a "surprise swarm effect" (thundering herd) due to an uncontrolled number of users. The Groupcache coordinates the cache population, only one of the duplicate calls is placed in the cache, and the processing results are sent to all the same callers.

3. Multiple versions of values are not supported. If the "Foo" key corresponds to a value of "bar", then the value of the key "foo" is Always "bar". There is neither a cache expiration nor a clear cache recovery mechanism, so there is no CAs or increment/decrement.

4. Based on the previous change, Groupcache has automatic backup "super-hot" items for multiprocessing, which avoids overloading the machine CPU or NIC in memcached for excessive access to certain key values.

5. Now only support go

In addition to some optimizations, the biggest difference is that Memcache has a cache expiration policy, Groupcache no cache expiration and expiration policy. Groupcache gives up the ability to change and delete, bringing new capabilities: the ability to cluster, the ability to deal with hotspots. (compared to the old version of Memcached,groupcache, the cache expiration date and cache recovery mechanism are removed, and the load is balanced by automatic backup.) )

There was no intersection between the Memcache servers before, and the Groupcache was clustered together.

In addition, the previous memcache will be due to access the same key at the same time caused the single CPU overloading problem, in the Groupcache through the auto-mirror mechanism to solve.

Http://www.tuicool.com/articles/mmiuQb

Http://www.csdn.net/article/2013-07-30/2816399-groupcache-readme-go

http://blog.csdn.net/heiyeshuwu/article/details/14225343

Operating mechanism

In short, the process of Groupcache finding a Get ("foo") is similar to the following scenario:

    • Whether the value of key "foo" will be stored in local memory because of "overheating", if it is, it will be used directly;
    • Whether the value of key "Foo" will be used directly because the peer #5是其拥有者而储存在本地内存, if it is;
    • First determine if the key "fool" belongs to the peer of its n machine set, and if so, it is loaded directly. If there are other callers involved (through the same process or peer RPC requests, these requests will be blocked, and when the processing is finished, they will get the same result directly). If not, RPC the owner of the key to the appropriate peer. If the RPC fails, it is loaded directly locally (still in response to the load by backup).
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.