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

Reasons why php uses redis

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

Share

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

This article will explain in detail the reasons for the use of redis in php. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Introduction to Redis

Redis is a non-relational memory database widely used in Nosql database, and redis is a key-value storage system. It supports relatively more value types stored, including string (string), list (linked list), set (collection), zset (sorted set-ordered collection), and hash (hash type, similar to map in Java). Redis is a NoSQL database which runs on memory and supports persistence. It is one of the most popular NoSql databases and is also known as data structure server.

2. In the context of the Internet era, what is a great opportunity to use Nosql?

1) when the total amount of data is too small for a machine to fit.

2) data indexing when there is no room in a machine.

3) the number of visits (mixed read and write) when an instance cannot be put down.

Stand-alone era model

If you store thousands of pieces of data at a time, this will result in poor MySQL performance, slow storage and read speed, and then evolve into a cache + mysql+ vertical split.

Cache acts as an intermediate cache

Save all the data in the cache first, and then store it in mysql to reduce the pressure on the database and improve the efficiency. However, when the data increases to another order of magnitude, the above method can not meet the demand. Due to the increase of the write pressure on the database, Memcached can only alleviate the reading pressure on the database.

The concentration of read and write on a database makes the database unbearable. Most websites begin to use master-slave replication technology to achieve read-write separation, so as to improve read-write performance and read-library scalability. Mysql's master-slave mode has become standard for websites at this time.

Master-slave separation mode

On the basis of redis cache, master-slave replication and read-write separation of MySQL, the write pressure of MySQL master library begins to appear bottleneck, and the amount of data continues to soar. Because MyISAM uses table locks, there will be serious lock problems in high concurrency. A large number of highly concurrent MySQL applications begin to use InnoDB engine instead of MyISAM.

Sub-table and sub-database mode

Put small changes, business-related data in a database, many changes, irrelevant data in a database.

3. Advantages of nosql database

1) easy to expand

These types of data stores do not require fixed schemas and can be scaled horizontally without redundant operations. A particularly large number of tables and fields can be reduced compared to relational databases. It also brings scalable capabilities at the architectural level.

2) large amount of data to improve performance

3) various and flexible data models

In nosql, you can store not only String,hash,set, Zset and other data types, but also javaBean and a variety of complex data types.

4. The application of NoSql

1) in the era of big data, Taobao, Wechat, and Weibo all widely used redis database to store some fixed data such as schools, regions and other fixed information in the relational database. Then for frequently changing data such as Taobao every holiday there will be a more popular search displayed in the search box, when the holiday keywords are automatically deleted, in order to facilitate management, you can save these data in the redis database, and set the expiration time, the arrival time is automatically deleted.

2) in order to alleviate the database pressure, Weibo first saves the sent Weibo to the redis database so that it can see it immediately, and then synchronizes the in-memory data to the relational database.

So much for sharing the reasons for php's use of redis. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

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