May 11, 2016 Some of the things that you know about Redis

Source: Internet
Author: User

1.

The daily base data and statistics are stored in Redis, which allows the average response time of the request to be below 10ms.
Other data still need to be stored in another place, in fact, the full use of Redis is also feasible, the main consideration is memory consumption.
In terms of experience, Redis's data structures are rich and well-designed to meet many application scenarios. At least a lot of times than MySQL More convenient 2. If you use Redis alone, it is the task of not starting a database, such as your daily active user is 10,000 people, but your redis has accumulated 500,000 people (this proportion is normal), then each Redis boot, you need to put 500,000 load memory, each Redis backup, and need to put 500,000 du MP to disk, is this reliable?
The cold data is dropped to MONGO and the thermal data is stored in Redis. 3.redis is currently recognized as the fastest memory-based key-value database, but the shortcomings of Redis is also very obvious, only provide the most basic hash set, list, sorted set, etc. based on data type, no table, no schema, no index, no foreign key, missing int /date and other basic data types, multi-condition queries need to be implemented indirectly through set-inline (Sinter,zinterstore) and connection, inconvenient operation, low development efficiency and poor maintainability; therefore, it is not generally considered as a complete database for individual use, Many websites use Redis as a cache and session state storage layer, and then work with other databases.
4. Core business recommendations The data is still on the ground to Mysql,redis in case of abnormal situation.
Non-core business, such as operations promotion, data aggregation statistics This allows a small amount of data loss of the business can be full use of MySQL, expansion convenience, high efficiency, business volume is not small. In particular, operation and promotion of this highly-sensitive business, after the end of the promotion of data access is useless, redis memory pressure is not very large. MySQL can support queries for each field, and Redis queries are limited to simple matches to keys, and Redis is not suitable for complex queries on value. 5. The Redis database is still not very reliable. It supports too few data types and the query function is too weak. Redis is not intended to be used as a database, it is more of a high-speed accessor, typically used as a cache and similar scenario. 6.redis is a k/v memory database, suitable for small data storage and high-real-time requirements, but not for the full database, the complete database is basically a set of detailed solutions, such as MySQL.
The Redis used in our project is used for caching, setting the expiration time, and then automatically clearing it. The database is still a mature solution such as MySQL.
If you have to use a NoSQL database, it is recommended that you use MongoDB
7.redis can be used to do database depending on the following conditions:
1: The amount of data, after all, the memory database, or is limited by the capacity of memory, although Redis can be persisted.
2: The structure of the data, whether the relational data structure can be converted to key/value form.
3: The efficiency of the query, the scope of query, and so on, whether it can be converted into efficient hash index query 8.MongoDB is not a memory-based database, he simply put all the file index into memory. On the same model, MongoDB will save more than Redis, but Redis responds faster. The key is how much it looks. 9.MongoDB is a nosql database that supports putting some of the hot data into memory, allowing users to handle it faster.

Redis is an in-memory database and a complete memory database! All the data is in memory, there is no part of the hard disk, and the memory is part of the situation. Of course, you can use Save to save data to the hard disk, but this is for backup security considerations rather than for use.
10. A hash is actually a set of key-value pairs, the key of which is the "parent key", and the number of fields that are contained in the hash are "subkeys" and each "subkey" has a corresponding value. There is no connection between the sub-keys, but they collectively form a complete hash structure. We can think of a hash as a row in a relational database, where each subkey of a hash corresponds to a field of a row. Therefore, it may be convenient to use a hash structure when caching data from a relational database to Redis. It is important to note that there is no sequential relationship between the sub-keys inside the hash structure. 11.

Redis is a kind of memory database, which makes it outstanding in data access efficiency. Since in-memory data is at risk of being lost at all times, Redis provides two persistence mechanisms to write in-memory data to the hard disk in a timely manner. The first mechanism is an RDB, which uses storage snapshots to write memory data to the hard disk on a regular basis, and the second mechanism is AOF, which, using the log-writing method, appends the command to the log and saves it on the hard disk with each command that changes the Redis data. Redis turns on Rdb mode by default, turning off aof mode because AOF is more time-consuming. However, if the data security requirements are very high, can not bear the consequences of any data loss, AOF mode becomes the first choice of persistence.

Of course, even though Redis has a persistence mechanism, data loss is unavoidable once the local hard drive is damaged. Therefore, Redis also provides replication functionality to automatically synchronize data from one primary database (master) to multiple slave databases (slave) to prevent data loss as much as possible. The Redis master-slave mechanism can be described simply as: After starting the database, the Sync command is sent to the primary database, and the snapshot is saved after the main database is connected to the Sync command, during which all the commands issued to the primary database are cached and when the snapshot is saved, The primary database sends the snapshot and cached commands together from the database, saves the snapshot files from the primary database from the database, and sequentially executes the cache command sent from the primary database. During synchronization, from the database is not blocked, it defaults to using the data before the synchronization to continue to respond to the commands sent by the client.

May 11, 2016 Some of the things that you know about Redis

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.