Comparison of Redis and memcached

Source: Internet
Author: User
Tags memcached memory usage

Referenced from: http://blog.csdn.net/e_wsq/article/details/23551799

Recently, we need to use NO-SQL database to save a lot of data, insert and query are more frequent, relatively more frequent query. Choose Memcached, or Redis? Memcached and Redis to do a related test, you know.

memcached vs Redis Test:

1) Performance aspects:

The same number of write and read data, key for UUID, value for analog terminal information approx. 600 bytes

Single Thread:

Memcached write time is better than Redis, while Redis reads better than memcached

20,000 write data, memcached write time is approximately 9000,msredis write time is about 13000MS

20,000 read data, memcached read time approx. 7000,msredis read time is about 6000MS

Multithreading:

Redis is better than memcached when it's low concurrency

60 concurrent

Redis writes 1000 data per thread, with total execution time of approximately 5000ms;memcached each thread writes 1000 data, total execution time is approximately 10000ms

Redis reads 1000 data per thread, with a total execution time of approximately 2000ms; memcached reads 1000 data per thread and takes approximately 8000ms execution time

2) Memory usage efficiency:

If you use simple key-value storage, the memory utilization of the memcached is higher.

If Redis uses a hash structure to do key-value storage, its memory utilization will be higher than memcached due to its combined compression.

This is related to application scenarios and data characteristics.

Redis when physical memory runs out, you can swap some long-unused value to disk

Memcache exists in memory, when allocated memory is full, some k/v data (LRU rule) is deleted according to certain rules

3) Data manipulation

Redis has more data structures and supports richer data operations than memcached.

Usually in memcached, you need to get the data to the client to make similar changes and set it back.

This greatly increases the number of network IO and the volume of data. In Redis, these complex operations are often as efficient as the general get/set.

4) Data persistence and data synchronization

Redis supports both, periodically writes the updated data to the disk or writes the modification to the appended record file, and on this basis implements the Master-slave (master-slave) synchronization, which can be loaded again after upgrading or rebooting the system, and memcached does not support

5) distributed

Both support cluster one master multiple from or one master one from

Summary: Both performance is relatively high, this is not a bottleneck, Redis not only supports simple k/v type of data, but also provides data structures such as list,set,hash storage, if the need for caching to support more complex structure and operation, then Redis is a good choice. Redis, with certain database characteristics, can keep in-memory data on disk, when the importance of data is relatively high, restart upgrade system, Redis can recover some data through aof.

Based on the above analysis, it is recommended to use Redis.

Comparison of Redis and memcached

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.