What is Redis? What is it used? What are its advantages and disadvantages ?, What does redis do?

Source: Internet
Author: User

What is Redis? What is it used? What are its advantages and disadvantages ?, What does redis do?

Question guidance:
1. What is Redis?
2 What is Redis used?
3 What are the advantages of Redis?
4 What are the disadvantages of Redis?


Objective: To have a conceptual understanding of what a memory-type database is .?



What is Redis?

Generally, there are several types of databases, including SQL/NSQL, relational databases, and key-value databases, redis is also a key-value database in nature, but it keeps the key-value database simple and fast, while absorbing the advantages of some relational databases. So that it is located between the relational database and the key-value data base. Redis not only saves Strings data, but also stores Lists (ordered) and Sets (unordered) data. It also supports advanced functions such as sorting, this ensures the atomicity of operations when implementing functions such as INCR and SETNX. In addition, it also supports master-slave replication and other functions.

For more detailed descriptions, see:

Http://code.google.com/p/redis/wiki/index

Redis also provides a project code named Retwis.

2 What is Redis used?

Generally, Redis also exists in the form of message queues as an embedded List to meet real-time high concurrency requirements. In the process of processing data of an e-commerce type, queues related to commodities, hot sales, and recommended sorting are usually stored in Redis, during which Storm is also expanded to read and update the Redis list.


3 advantages of Redis

High Performance-Redis supports read/write frequencies of over 100 K + per second.

Rich data types-Redis supports binary case Strings, Lists, Hashes, Sets, and Ordered Sets data type operations.

All the operations of atomic Redis are atomic, and Redis also supports atomic execution after the sum of several operations.

Rich features-Redis also supports features such as publish/subscribe, notification, and key expiration.

4. disadvantages of Redis

Because the database capacity is limited by physical memory and cannot be used for high-performance read/write of massive data, Redis is suitable for scenarios mainly limited to high-performance operations and operations with small data volumes.

Conclusion: due to specific scenarios, Redis focuses on specific fields, and the speed is quite fast. Currently, no alternative products have been found.



When using cache, redis has more advantages than memcached and supports more data types.


What is Redis? Two sentences can be summarized as follows:
1. It is a completely open-source and free key-value memory database.
2. It is generally considered as a data structure server, mainly because it has a wide range of data structures, such as strings, map, list, sets, and sorted sets.
What is Redis? The comparison is also made from two aspects:
1. It is not a relational database such as SQL server or mySQL because:
Currently, redis can only be used as storage of small data volumes (all data can be loaded into the memory), and massive data storage is not a field that redis is good.
The design and implementation methods are quite different. Relational databases store data through tables and query data through SQL. Redis stores data through the above five data structures and queries data through commands
2. It is not a cache system such as Memcached. The main reasons are as follows:
In terms of network I/O model: Memcached is a multi-thread, divided into listening thread and worker thread. The introduction of locks leads to performance loss. Redis uses a single-thread IO multiplexing model to maximize its speed advantage and provides simple computing functions.
. Memory Management: Memcached uses a pre-allocated memory pool, which results in a certain amount of space waste. When the memory is still large, new data may also be removed, redis uses on-site memory application to store data without removing any non-temporary data. Redis is more suitable for storage than cache.
. Data Consistency: Memcached provides the cas command to ensure. Redis provides the transaction function, which can ensure the atomicity of a string of commands without being interrupted by any operation.
In terms of Storage Methods: Memcached only supports simple key-value storage, does not support enumeration, does not support persistence, replication, and other features. A summary: Redis is a high-performance key-value database. The emergence of redis largely compensates for the shortage of key/value storage such as memcached. In some cases, it can play a good complementary role for relational databases.
What is the use of Redis? Only by understanding what features it has can we use it to foster strengths and circumvent weaknesses:
1. High Speed: Use Standard C writing, all data is completed in the memory, and the read/write speed reaches 0.1 million/0.2 million respectively.
2. persistence: data update adopts the Copy-on-write technology and can be asynchronously saved to the disk. There are two main policies: one is based on time, snapshot of the number of updates (save 300 10) Second, based on the statement Append method (Append-only file, aof)
3. Automatic Operation: all operations on different data types are automatic and safe.
4. Quick master-Slave replication. The official website provides a data record. Slave completes the replication of the 10G key set on the Amazon website in 21 seconds.
5. sharding technology: it is easy to distribute data to multiple Redis instances. database expansion is an eternal topic. In relational databases, however, with the rise of web, mobile Internet, cloud computing, and other applications, this scaling mode is not suitable for users. In recent years, Sharding has been widely used to distribute loads to multiple special nodes, such as master-slave configuration and database replication.
Here is a summary of the Redis database:
1. To improve the database scalability, you only need to put the newly added data on the newly added server.
2. improves the availability of the database and only affects the users of data on the shard server to be accessed.
3. the maintainability of the database is improved, and the upgrade and configuration of the system can be performed one by one based on shard, which has little impact on the service.
4. the query pressure of small data inventory is small, the query is faster, and the performance is better
If I write it here, someone may be eager to use it. How can I use it? You can directly go to the official documentation to help us sort out the clients in various language environments, including Ruby, Python, PHP, Perl, Lua, Java, C #.... there are several languages that I have never met, so I won't say much, you know ....
Finally, I will summarize some of my experiences and lessons in the use process:
1. You need to configure Master-slave. You can switch between them in case of service failure.
2. Disable data persistence on the master side. You only need to configure data persistence on the slave.
3. The physical memory + virtual memory is insufficient. At this time, the dump remains dead and the machine crashes after a long time. This is a disaster!
4. When the Redis physical memory usage exceeds 3/5 of the total memory capacity, it will start to be dangerous. Then we will start to do swap, with a large memory fragmentation.
5. When the maximum memory size is reached, the key with the expiration time is cleared even if the key has not reached the expiration time.
6. For synchronization between redis and DB, write the database first and then redis, because there is basically no problem in writing memory.



Top
2
Step on
0
View comments

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.