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

What's the difference between redis and mysql?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Editor to share with you what is the difference between redis and mysql, I hope you will gain something after reading this article, let's discuss it together!

The differences are as follows:

1. Database types of mysql and redis

Mysql is a relational database, which is mainly used to store persistent data and store the data in the hard disk with slow reading speed.

Redis is NOSQL, that is, non-relational database, is also a cache database, that is, the data is stored in the cache, the cache read speed is fast, can greatly improve the running efficiency, but the preservation time is limited.

2. The operation mechanism of mysql

As a relational database with persistent storage, the relatively weak point of mysql is that there is an IWeiO operation every time you request to access the database, if you visit the database repeatedly and frequently. First, it will spend a lot of time on repeatedly linking the database, resulting in slow running efficiency; second, repeated access to the database will also lead to excessive database load, then the concept of caching is derived.

3. Caching

A cache is a cache for data exchange. When a browser executes a request, it first looks for it in the cache and, if it exists, gets it; otherwise, it accesses the database.

The advantage of cache is that it is fast to read.

4. Redis database

Redis database is a cache database, which is used to store frequently used data, so as to reduce the number of visits to the database and improve operational efficiency.

5. Summary of the difference between redis and mysql

(1) on type

In terms of type, mysql is a relational database and redis is a cache database

(2) in effect

Mysql is used to persistently store data to the hard disk. It is powerful, but slow.

Redis is used to store frequently used data into the cache with fast reading speed.

(3) demand

Mysql and redis are generally used together because of their different requirements.

Add:

Redis and mysql should be selected according to specific business scenarios.

Mysql: data on disk redis: data on memory

Redis is suitable for frequently used and hot data, because it is placed in memory and the speed of reading and writing is very fast. It is generally used in some of the following scenarios.

Rankings, counters, message queue push, friend followers, fans

First of all, we should know that mysql is stored on disk, redis is stored in memory, and redis can be used for both persistent storage and cache. at present, the storage of most companies is mysql + redis,mysql as primary storage, and redis as secondary storage is used as cache to speed up access and read speed and improve performance.

So why not just store it all in redis?

My opinion is: because redis is stored in memory, if it is stored in memory, the storage capacity must be much less than that of disk, so if you want to store a lot of data, you can only spend more money to buy memory, so it is relatively wasteful in some places where high performance is not needed, so at present, it is basically mysql (primary) + redis (secondary), using redis where performance is needed and mysql where high performance is not needed. Good steel is used on the blade

1. Mysql supports sql query, which can implement some related queries and statistics.

2. Redis has high memory requirements, so it is impossible to put all the data in redis under limited conditions.

3. Mysql tends to store data, and redis tends to fetch data quickly, but redis is not as good as mysql when querying complex table relationships, so you can put popular data in redis,mysql to store basic data.

After reading this article, I believe you have a certain understanding of "what's the difference between redis and mysql". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!

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