Home > Database > Redis > body text

Why does php use redis?

王林
Release: 2019-09-18 17:57:24
Original
2689 people have browsed it

Why does php use redis?

1. Introduction to Redis

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

2. With the great opportunities in the Internet era, why should we use Nosql?

1) When the total size of the data cannot fit in one machine.

2) When the data index cannot be stored in the memory of a machine.

3) When the number of visits (mixed reading and writing) cannot be accommodated in one instance.

Single-machine era model

Why does php use redis?

If you store thousands of pieces of data each time, this will be very As a result, the performance of MySQL is very poor, the storage and reading speed are very slow, and then it evolves into a vertical splitting method of caching mysql.

Why does php use redis?

##Cache serves as an intermediate cache

Save all data to the cache first and then save it Enter mysql to reduce database pressure and improve efficiency. But when the data increases to another magnitude again, the above method cannot meet the demand. As the writing pressure of the database increases, Memcached can only relieve the reading pressure of the database.

The concentration of reading and writing on one database makes the database overwhelmed. Most websites have begun to use master-slave replication technology to separate reading and writing to improve reading and writing performance and the scalability of reading databases. Mysql's master-slave mode has become the standard for websites at this time.

Why does php use redis?

Master-slave separation mode Based on redis cache, MySQL master-slave replication, and read-write separation, at this time The write pressure of the MySQL main database began to appear bottlenecks, and the amount of data continued to surge. Since MyISAM uses table locks, serious lock problems will occur under high concurrency. A large number of high-concurrency MySQL applications began to use the InnoDB engine instead of MyISAM.

Why does php use redis?

Sub-table and sub-database mode

Put the ones with small changes and business-related in one database, and those with many changes will not Relevant data is placed in a database.

3. Advantages of nosql database

1) Easy to expand

These types of data storage do not require a fixed schema , horizontal expansion can be performed without redundant operations. Compared with relational databases, the number of tables and fields can be reduced. It also brings scalable capabilities at the architectural level

2) Large data volume improves performance

3) Diverse and flexible Data model

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

4. Application of NoSql

1) In the era of big data, Taobao, WeChat, and Weibo have widely used the redis database to convert some fixed Data such as schools, regions and other fixed information are stored in relational databases. Then for frequently changing data, for example, Taobao will have popular searches displayed in the search box every holiday. When the holiday passes, the keywords will be automatically deleted. In order to facilitate management, these data can be saved in the redis database and set the expiration time. The time will be automatically deleted.

2) In order to relieve the pressure on the database, Weibo first saves the sent Weibo to the redis database so that it can be viewed immediately, and then synchronizes the data in the memory to the relational database.

The above content is for reference only!

Recommended video tutorial:

redis tutorial

The above is the detailed content of Why does php use redis?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!