Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The reason for introducing redis into web Project

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Why do web projects need redis? This problem may be our daily study or work often see. I hope you learned something from this question. The following is the reference content brought to you by Xiaobian. Let's take a look together!

redis is a Nosql database, a key-value storage system. Although redis is a key-value storage system, redis supports a wide variety of value storage types, such as strings, lists, sets, ordered sets, and hashes.

Redis is a key-value storage system. Similar to Memcached, it supports a relatively large number of stored value types, including string, list, set, zset, and hash. These data types all support push/pop, add/remove, and take intersection union and subtraction, as well as richer operations, all of which are atomic. On this basis, redis supports a variety of different ways of sorting. As with memcached, data is cached in memory for efficiency. The difference is that redis periodically writes updated data to disk or changes to additional log files, and on this basis achieves master-slave synchronization.

Redis is a high-performance key-value database. The emergence of redis largely compensates for the lack of key/value storage such as memcached, and can complement relational databases in some cases. It provides Java, C/C++, C#, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, very convenient to use.

Redis supports master synchronization. Data can be synchronized from a master server to any number of slave servers, which can be master servers associated with other slave servers. This allows Redis to perform single-layer tree replication. Save can intentionally or unintentionally write data. Because the publish/subscribe mechanism is fully implemented, the slave database can subscribe to a channel and receive the master server's complete message publication record when synchronizing the tree anywhere. Synchronization is helpful for scalability and data redundancy of read operations.

Redis is completely open source and free, complies with the BSD protocol, and is a high-performance key-value database.

Redis supports five data types: string, hash, list, set, and zset.

Redis and other key-value caching products have three characteristics:

Redis supports persistence of data. It can save data in memory to disk and load it again for use when restarting.

Redis not only supports simple key-value data, but also provides storage for list, set, zset, hash and other data structures.

Redis supports data backup, namely master-slave mode data backup.

Redis Advantage

Very high performance- Redis can read at 110000 times/s and write at 81000 times/s.

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

Atomic-All operations in Redis are atomic, meaning they either succeed or fail at all. Individual operations are atomic. Multiple operations also support transactions, i.e. atomicity, wrapped by MULTI and EXEC directives.

Rich features- Redis also supports publish/subscribe, notifications, key expiration, etc.

How does Redis differ from other key-value stores?

Redis has more complex data structures and provides atomic operations on them, which is a different evolutionary path than other databases. Redis data types are based on basic data structures and are transparent to programmers without additional abstraction.

Redis runs in memory but can persist to disk, so there is a trade-off between high-speed reads and writes to different data sets because the amount of data cannot be larger than hardware memory. Another advantage in terms of in-memory databases is that they are much simpler to operate in memory than the same complex data structures on disk, so Redis can do a lot of internally complex things. At the same time, they are compact in disk format and generated additively because they do not require random access.

So why use a Nosql database like redis?

1, when the total size of the data can not be placed on a machine;

2, data index when a machine's memory can not fit;

3. Access (mixed reading and writing) When an instance cannot be put down.

In the single-machine era, storage is only installed on one machine. If thousands of pieces of data are stored at a time, this will lead to poor performance of mysql, slow storage and reading speed, and then evolve into cache +mysql+ vertical split mode.

Cache as an intermediate cache era, all the data will be saved to the cache first, and then stored in mysql, reducing database pressure, improve efficiency.

However, when the data increases to another magnitude, the above method cannot meet the demand. As the write pressure of the database increases, the cache can only relieve the read pressure of the database. The concentration of reads and writes on one database overwhelmed the database, and most websites began to use master-slave replication technology to achieve read-write separation to improve read-write performance and scalability of the read database. Mysql's master-slave mode became standard on websites at this time.

In the era of master-slave separation mode, on the basis of redis cache, MySQL master-slave replication, and read-write separation, the write pressure of MySQL master library began to appear bottleneck, and the data volume continued to soar. Due to MyISAM using table locks, serious lock problems occurred under high concurrency. A large number of highly concurrent MySQL applications began to use InnoDB engine instead of MyISAM. Advantages of Nosql Database:

1, easy to expand

These types of data stores do not require a fixed schema and can scale horizontally without unnecessary manipulation. Compared with relational databases, it can reduce the number of tables and fields. And also between typelessness brings scalability at the architectural level.

2. Large amount of data improves performance

Flexible and diverse data models

Thank you for reading! After reading the above, do you have a general understanding of the reasons for introducing redis in web projects? I hope the content of this article is helpful to everyone. If you want to know more about related articles, please pay attention to the industry information channel.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report