In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Simple differences:
1. In Redis, not all data is stored in memory all the time, which is the biggest difference compared with Memcached.
2. Redis not only supports simple KBH data, but also provides storage of data structures such as list,set,hash.
3. Redis supports data backup, that is, data backup in master-slave mode.
4. Redis supports data persistence. You can keep the data in memory on disk and load it again when you restart it.
Redis has the characteristics of a database in many ways, or it is a database system, while Memcached is just a simple Khand V cache.
The following is a statement from the author of redis (above stackoverflow).
You should not care too much about performances. Redis is faster per core with small values, but memcached is able to use multiple cores with a single executable and TCP port without help from the client. Also memcached is faster with big values in the order of 100k. Redis recently improved a lot about big values (unstable branch) but still memcached is faster in this use case. The point here is: nor one or the other will likely going to be your bottleneck for the query-per-second they can deliver.
You should care about memory usage. For simple key-value pairs memcached is more memory efficient. If you use Redis hashes, Redis is more memory efficient. Depends on the use case.
You should care about persistence and replication, two features only available in Redis. Even if your goal is to build a cache it helps that after an upgrade or a reboot your data are still there.
You should care about the kind of operations you need. In Redis there are a lot of complex operations, even just considering the caching use case, you often can do a lot more in a single operation, without requiring data to be processed client side (a lot of I am O is sometimes needed). This operations are often as fast as plain GET and SET. So if you don't need just GEt/SET but more complex things Redis can help a lot (think at timeline caching).
Some netizens translated as follows [1]:
There is no need to pay too much attention to performance. Because Redis uses only a single core, while Memcached can use multiple cores, on average, per core, Redis performs better than Memcached when storing small data. In the data of more than 100k, the performance of Memcached is higher than that of Redis. Although Redis has recently optimized the performance of storing big data, it is still slightly inferior to Memcached. With all that said, 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, memcache has higher memory usage. If you use the hash structure, the memory usage of redis will be higher. Of course, these all depend on the specific application scenario.
You need to focus on data persistence and master-slave replication, only redis has these two features. If your goal is to build a cache that will not lose data before the upgrade or restart, then you can only choose redis.
You should be concerned about the operation you need. Redis supports many complex operations, even considering memory usage, and you can often do a lot in a single operation without reading data to the client (which requires a lot of IO operations). These complex operations are basically as fast as pure GET and POST operations, so redis will play a big role when you not only need GET/SET but also more operations.
The choice between the two depends on the specific application scenario. If the data to be cached is only a simple structure like key-value, I still use memcache in the project, which is stable and reliable enough. When it comes to a series of complex operations such as storage, sorting, and so on, there is no doubt about choosing redis.
Other:
1. Both Redis and Memcache store data in memory, and both are in-memory databases. However, memcache can also be used to cache other things, such as pictures, videos, and so on.
2. Redis not only supports simple KBH data, but also provides storage of data structures such as list,set,hash.
3. Virtual memory-Redis when physical memory is used up, you can swap some long-unused value to disk
4. Expiration policy-memcache is specified when set, for example, set key1 008, that is, never expires. Redis can be set by, for example, expire, such as expire name 10
5. Distributed-set memcache cluster and use magent to do one master and multiple slaves; redis can do one master and multiple slaves. All can have one master and one slave.
6. Storage data security-after memcache is hung up, the data is gone; redis can be saved to disk on a regular basis (persistence)
7. Disaster recovery-after the memcache is down, the data cannot be recovered; after the redis data is lost, it can be recovered through aof
8. Redis supports data backup, that is, data backup in master-slave mode.
With regard to the differences between redis and memcache, here are some relevant statements for recording:
The difference between redis and memecache lies in [2]:
1. Storage method:
Memecache stores all the data in memory and will hang up when the power is off. The data cannot exceed the memory size.
Part of redis is stored on the hard disk, which ensures data persistence and supports data persistence (the author's note: there are snapshot and AOF log persistence methods, in practical application, we should pay special attention to the configuration file snapshot parameters, or it is very likely that the server is frequently fully loaded to do dump).
2. Data support type:
Redis has a lot more data support than memecache.
3. Using the underlying model is different:
The new version of redis directly builds its own VM mechanism, because the general system calls system functions, it will waste a certain amount of time to move and request.
4. Different operating environments:
At present, redis officially only supports Linux uplink, thus eliminating the support for other systems, so that it can better focus on the optimization of the system environment, although a team at Microsoft later wrote a patch for it. But not on the trunk.
To sum up, for applications with persistence requirements or advanced data structure and processing requirements, choose redis, other simple key/value storage, and memcache.
The following focuses on the analysis of Memcached and Redis:
Memcached introduction
Memcached is a high-performance distributed in-memory object caching system, which is used for dynamic Web applications to reduce database load. It reduces the number of times to read the database by caching data and objects in memory, thus providing the speed of dynamic, database-driven websites. It has been used by LiveJournal, hatena, Facebook, Vox, LiveJournal and other companies.
Analysis of working Mode of Memcached
Many Web applications save data to RDBMS, where the application server reads the data and displays it in the browser. However, with the increase of the amount of data and the concentration of visits, there will be significant effects, such as the increased burden of RDBMS, the deterioration of database response, the delay of website display and so on. Memcached is a high-performance distributed memory cache server, by caching database query results, reducing the number of database access, in order to improve the speed and scalability of dynamic Web and other applications. The following figure shows the cooperation between memcache and database:
The process goes like this:
1. Check whether the data requested by the user exists in the cache, and if so, you only need to return the requested data directly without querying the database.
two。 If the requested data cannot be found in the cache, query the database at this time. While returning the requested data, store a copy of the data in the cache.
3. Keep the cache "fresh". Whenever the data changes (for example, when the data has been modified or deleted), update the cache information synchronously to ensure that the user will not get the old data in the cache.
As a high-speed distributed cache server, Memcached has the following characteristics:
1. The protocol is simple
two。 Event handling based on libevent
3. Built-in memory storage
4.memcached distributed without communicating with each other
How to achieve distributed extensibility?
The distribution of Memcached is not implemented on the server side, but in the client application, that is, the nodes where the target data is determined by the built-in algorithm, as shown in the following figure:
Redis introduction
Redis is a key-value storage system. Similar to Memcached, it supports relatively more value types to be stored, including string (string), list (linked list), set (collection), and zset (ordered collection). These data types support push/pop, add/remove, and take intersection union and difference sets, and richer operations, and these operations are atomic. On this basis, redis supports a variety of different sorting methods. Like memcached, data is cached in memory for efficiency. The difference is that redis will periodically write updated data to disk or modify operations to additional record files, and on this basis to achieve master-slave (master-slave) synchronization, the current application of Redis has been very extensive, domestic, such as Sina, Taobao, foreign such as Flickr, Github are using Redis cache services.
Analysis of working Mode of Redis
As a high-performance key-value database, Redis has the following characteristics:
1. Multiple data models
two。 Persistence
3. Master-slave synchronization
Redis supports a wide range of data types, with five of the most commonly used data types: String, Hash, List, Set, and Sorted Set. Redis usually stores data in memory or is configured to use virtual memory. A very important feature of Redis is that it can persist data in two ways: using RDB snapshots to continuously write data in memory to disk, or using an AOF log method similar to MySQL to log each update. The former has high performance, but may cause a certain degree of data loss; the latter is the opposite. Redis supports synchronizing data to multiple slave databases, which is very useful for improving read performance.
How does Redis achieve distributed scalability?
Prior to version 2.8: consistent with Memcached, it can be implemented on the client side or use a proxy. Twitter has developed a proxy Twemproxy for Redis and Memcached.
Version 3.0: compared with Memcached, distributed storage can only be implemented on the client side, while Redis builds distributed storage on the server side. Redis Cluster is an advanced version of Redis that is distributed and allows a single point of failure. It has no central node, each node has the same status, and has the function of linear scalability. The figure shows the distributed storage architecture of Redis Cluster, in which nodes communicate with each other through binary protocol, and nodes communicate with clients through ascii protocol. In the data placement strategy, Redis Cluster divides the entire key value field into 16384 hash slots, and one or more hash slots can be stored on each node, that is, the maximum number of nodes supported by Redis Cluster is 16384.
Comprehensive conclusion
It should be said that Memcached and Redis can solve our problems very well, and their performance is very high. Generally speaking, Redis can be understood as an extension of Memcached, a more heavyweight implementation, and provides more and more powerful functions. Specifically:
1. Performance:
The performance is excellent, specific to the details. Because Redis only uses a single core, while Memcached can use multiple cores, the average Redis on each core is better than when storing small data.
Memcached has higher performance. In the data of more than 100k, the performance of Memcached is higher than that of Redis. Although Redis has recently optimized the performance of storing big data, it is still slightly inferior to Memcached.
two。 Memory space and data size:
MemCached can modify the maximum memory, using the LRU algorithm. Redis adds the features of VM to break through the physical memory limitations.
3. Easy to operate:
MemCached has a single data structure and is only used to cache data, while Redis supports more abundant data types, and it can also carry out rich operations on the data directly on the server side, which can reduce the number of network IO and data volume.
4. Reliability:
MemCached does not support data persistence, data disappears after power outage or restart, but its stability is guaranteed. Redis supports data persistence and data recovery, allowing a single point of failure, but at the same time pays a performance price.
5. Application scenarios:
Memcached: dynamic system to reduce database load, improve performance; cache, suitable for more reading and less writing, a large amount of data (such as Renren query a large number of user information, friend information, article information, etc.).
Redis: suitable for systems that require high reading and writing efficiency, complex data processing business and high security requirements (such as Sina Weibo counting and Weibo publishing system, which have high requirements for data security, reading and writing).
Parts that need to be carefully considered
The size of a single key-value of 1.Memcached is limited. A value can only support 1MB at most, while Redis can support 512MB at most.
2.Memcached is only an in-memory cache and has no requirement for reliability, while Redis prefers an in-memory database, so it has higher requirements for reliability.
3. In essence, Memcached is only a single key-value memory Cache;, while Redis is a data structure memory database that supports five data types, so Redis can not only cache, but also handle some simple logical operations. Redis can not only be cached, but also can be used as a database.
4. The new version of Redis refers to the cluster distribution, that is, the cluster itself balances client requests, each node can communicate, expandable rows and maintainability are more powerful.
Ref:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.