Comparison and selection of Redis and Memcache

 There is no need to pay too much attention to performance. Since Redis only uses a single core, and Memcached can use multiple cores , in comparison, Redis has higher performance than Memcached when storing small data on average per core. For data above 100k, the performance of Memcached is higher than that of Redis. Although Redis has recently optimized the performance of storing large data , it is still slightly inferior to Memcached. Having said all that, the conclusion is that no matter which one you use, the number of requests processed per second will not be a bottleneck.

    You need to pay attention to memory usage. For simple data storage such as key-value, the memory usage of memcache is higher. If the hash structure is used, the memory usage of redis will be higher. Of course, these all depend on specific application scenarios.

    When you need to pay attention to data persistence and master-slave replication , only redis has these two features. If your goal is to build a cache that will not lose the data before the upgrade or restart, then you can only choose redis.

    You should care about the operations you need. Redis supports many complex operations, even considering only memory usage, you can often do a lot in a single operation without reading data to the client (which would require a lot of IO operations). These complex operations are basically as fast as pure GET and POST operations, so when you don't just need GET/SET but more operations, redis comes into play.

    The choice between the two depends on the specific application scenario. If the data to be cached is only a simple structure such as key-value, I still use memcache in the project, which is stable and reliable enough. If it involves a series of complex operations such as storage and sorting, there is no doubt that redis is chosen.

   

    Regarding the difference between redis and memcache, some related statements are listed below for the record:

    The difference between redis and memecache is [2]:

    1. Storage method:
    memecache stores all the data in the memory, it will hang up after a power failure, the data cannot exceed the memory size
    , and some redis are stored on the hard disk, which can ensure the persistence of the data and support the persistence of the data (the author's note : There are two persistence methods: snapshot and AOF log. In actual application, special attention should be paid to the configuration file snapshot parameters, otherwise it is very likely that the server will be frequently full and dumped ).
    2. Data support type:
    Redis has more data support than memecache.
    3. The underlying model is different:
    the new version of redis directly builds the VM mechanism by itself, because if the general system calls system functions, it will waste a certain amount of time to move and request.
    4. Different operating environments:
    Redis currently only officially supports Linux  , which saves support for other systems. In this way, you can better devote your energy to the optimization of the system environment, although Microsoft has a team for it. Wrote a patch. but not on the trunk

 

Reprinted from http://www.cnblogs.com/EE-NovRain/p/3268476.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326460408&siteId=291194637