memcached similarities and differences of REDIS usage Summary

Source: Internet
Author: User
Tags memcached

What is Redis? Two sentences can be summed up:
1. is a fully open source free Key-value memory Database
2. It is generally considered a data structure server, mainly because of its rich data structure strings, map, list, sets, sorted sets

redis not what? The same is done in two ways:    
1. is not a relational database such as SQL Server or MySQL, mainly due to:    
    . Redis is currently only available as a small amount of data storage (all data can be loaded in memory), and the massive data storage aspect is not what Redis is good at    
    . Design, The implementation method is quite different. Relational databases use tables to store data and query data through SQL. And Redis through the above five data structures to store data, through the command to query data    
2.   is not memcached cache system, mainly due to the following:    
 & nbsp;  . Network IO Model aspect: Memcached is multi-threading, is divided into the listener thread, worker thread, introduces the lock, brings the performance loss. Redis uses a single-threaded IO multiplexing model to maximize the speed advantage and provides a simpler computing function    
    . Memory management Aspects: How Memcached uses a pre-allocated pool of memory , with a certain amount of space wasted and the memory still has a lot of space, the new data may also be rejected, and Redis uses the method of field application memory to store data, does not exclude any non-temporal data redis more suitable as storage instead of cache    
    . Consistency of data: Memcached provides CAS commands to guarantee. While Redis provides the functionality of a transaction, it guarantees the atomicity of a string of commands, which is not interrupted by any action    
    . Storage: Memcached only supports simple key-value storage, does not support enumeration, does not support persistence and replication, and so on.

A short summary: Redis is a high-performance Key-value database. The emergence of Redis, to a large extent, compensates for the lack of memcached such key/value storage, in some cases can be a good complement to the relational database.

What's the use of Redis? Only when we understand the characteristics of it, we use it to avoid weaknesses, for our use:
1. Fast: Write with standard C, all data is completed in memory, read and write speed is 100,000/200,000, respectively
2. Persistence: Updates to the data using Copy-on-write technology, can be asynchronously saved to disk, there are two main strategies, one is based on the time, the snapshot of the number of updates (save 300 10) Two is based on the statement append method (Append-only file,aof)
3. Automatic operation: the operation of different data types is automatic, very safe
4. Fast Master-from replication, the official provides a data, slave in 21 seconds to complete the Amazon Web site 10G key set replication.
5. Sharding Technology: It is easy to distribute data to multiple Redis instances, the expansion of the database is an eternal topic, in the relational database, mainly to add hardware, partition as the main technical form of vertical expansion to solve a lot of scenarios, but with web2.0, mobile Internet, The rise of applications such as cloud computing has become less suitable, so in recent years, such as the use of master-slave configuration, database replication form, sharding this technology to distribute the load to a number of special nodes on the scale-out mode of use more and more.

Here's a summary of the Redis database:
1. Improve the scalability of the DB, only need to put the new data added to the new server will be
2. Increased availability of DB, affecting only users who need access to data on the Shard server
3. Improve the maintainability of the DB, the system upgrade and configuration can be done by Shard, the impact on the service is small
4. Small Data inventory query pressure, query faster, better performance

Writing here, there may be someone who is impatient to use it, how to use it? can go directly to the official documents, which help us to organize the various language environment of the client, mainly Ruby, Python, PHP, Perl, Lua, Java, C # .... There are several languages, I have not seen, so do not say more, you understand ....

Finally, I use the process of some experience and lessons, make a summary:
1. To perform a master-slave configuration, you can support switchover in the event of a service failure.
2. Disable data persistence on the master side by simply configuring data persistence on the slave.
3. Physical memory + virtual memory is not enough, this time the dump has been dead, long time the machine hangs. This situation is a disaster!
4. When Redis physical memory uses more than 3/5 of the total memory capacity, it starts to be more dangerous, and it starts to swap, memory fragmentation is large
5. When the maximum memory is reached, the key with the expiration time is emptied, even if the key has not reached the expiration time.
6. Redis and DB synchronous write problem, first write db, then write Redis, because write memory basically no problem


Summary of Redis use and memcached similarities and differences

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.