In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
What is an Redis in-memory database?
Redis is essentially an in-memory database of KEY-VALUE type. The whole database is loaded and operated in memory, and the database data is saved to the hard disk regularly through asynchronous operation. So it is a pure memory operation, and the performance of Redis is excellent, handling more than 100000 read and write operations per second. Although it is an in-memory database, its data can be persisted and supports rich data types.
Redis supports the preservation of data structures for LIST lists and SET collections, as well as various operations on LIST, such as PUSH and POP data from both ends of LIST, fetching LIST intervals, sorting, and so on. SET supports the union and intersection of various collections, and the maximum limit for a single value is 1GB.
The main disadvantage of Redis is that it is limited by physical memory and can not be used for high-performance reading and writing of massive data, and it has no native scalable mechanism and scalability, so it depends on the client to achieve distributed reading and writing, so its suitable application scenarios are mainly limited to high-performance operations and operations with a small amount of data.
Best application scenario: suitable for applications where data changes quickly and the database size can be met (memory size).
For example: stock software, data analysis, real-time data collection, real-time communication.
Redis belongs to the category of NoSQL, which means: Not only SQL, which is not only SQL, is a new technology, which has been widely used with the advent of WEB 2.0. The idea is to use non-relational data storage.
Key-value databases mainly use hash tables, which have a specific key and a pointer to specific data. The advantage of KEY/VALUE model for IT system is that it is simple and easy to deploy. The main feature is extremely high concurrent read and write performance.
What is persistence?
All data in Redis is stored in memory and then saved to disk asynchronously from time to time (called semi-persistence); every data change can also be written to disk (this is called full persistence). The so-called persistence is the conversion of memory data to hard disk data, the conversion of memory model to storage model, or the conversion between instantaneous state and persistent state.
There are two persistence methods for Redis. The default is snapshot. The implementation method is to persist the snapshot of memory to the hard disk on a regular basis. The disadvantage of this method is that a piece of data will be lost if crash occurs after persistence. The other is aof, which saves the operation commands to the log file while writing the data in memory.
Snapshot method:
This snapshot method is the same as the snapshot of a virtual machine, saving the complete data at a certain time. When Redis persists in this way, it will write to a temporary file on a regular basis (default is 5 minutes), and then replace the old file with this file when the write is complete. The advantage of this approach is that any snapshot file is fully available. But the disadvantage is that it is done at regular intervals (1 minute at the earliest and 15 minutes at the slowest by default), so there will be a period of data loss.
AOF mode:
This way is to record the write instructions to the Redis memory data, these instructions will be recorded at the end of the AOF file, and then do a fsync operation every second (default once per second), the instruction in the background in the execution process is actually to modify the contents of the database on disk. So if there is a failure, only 1 second of data will be lost.
The above approach is very similar to the transaction log of a traditional database server.
If you encounter an accident while appending a log, you can use the redis-check-aof tool to fix the log.
Because the append method is used, the AOF will become larger and larger (which is different from the traditional database, which has relatively small transaction log files), so another mechanism for redis is AOF file rewriting. when the AOF file reaches a set threshold, it automatically starts AOF file compression, leaving only the minimum set of instructions that can recover the data.
From the above description of AOF, we can see that AOF is process-oriented and RDB is object-oriented.
A little bit of the AOF way:
Minimum data loss
Disadvantages of the AOF approach:
With the same amount of data, AOF files are larger than RDB files.
The recovery speed of AOF is slower than that of RDB
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.