I've been using redis recently and I find it quite convenient, but I'm confused about when to choose redis and when to choose memcache when choosing an in-memory database. Then I found the following relevant information, which comes from the author of redis (on 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/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). A netizen translated it as follows[1]: There is no need to focus too much on performance. Since Redis only uses a single core, while Memcached can use multiple cores , in comparison, on average, Redis has higher performance than Memcached when storing small data on each core. For data larger than 100k, Memcached performs better than Redis. Although Redis has recently been optimized for storing big 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 per second will not be a bottleneck. You need to keep an eye on memory usage. For simple data storage such as key-value, memcache has a higher memory utilization rate. If the hash structure is used, the memory usage of redis will be higher. Of course, all of this depends on the specific application scenario. When you need to pay attention to data persistence and master-slave replication , only You should care about the operations you need. Redis supports many complex operations, and even just considering memory usage, you can often do a lot in a single operation without having to read the data into the client (which would require 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 need more operations than just GET/SET. The choice between the two depends on the specific application scenario. If the data to be cached is a simple structure like key-value, I still use memcache in my 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 the right choice. Regarding the differences between redis and memcache, here are some relevant statements for record: The differences between redis and memecache are [2]: 1. Storage method: To sum up, for applications with persistence requirements or advanced requirements for data structure and processing, choose redis, and for other simple key/value storage, choose memcache. This is the end of this article about the comparison between Redis and Memcache and how to choose. For more relevant comparison content between Redis and Memcache, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future! |
<<: Where is mysql data stored?
>>: Specific method to delete mysql service
When writing HTML code, the first line should be ...
Install axios and implement communication Here we...
Table of contents Create a vue + ts project using...
Nowadays, cross-platform development technology i...
1. Business Background Using a mask layer to shie...
Result:Implementation code: html <!-- Please h...
There are many tasks to be done in search engine o...
What is the main function of Docker? At present, ...
1. Check and install pssh, yum list pssh 2. Becau...
This article mainly records a tomcat process, and...
In the course of work, you will encounter many ca...
> Deploy MySQL 5.7 cluster master & slave ...
Table of contents Vue this.$store.state.xx.xx Get...
1. Check the synchronization status of A and B da...
In actual web page development, accordions also a...