当前位置:网站首页>A complete tutorial for getting started with redis: redis usage scenarios
A complete tutorial for getting started with redis: redis usage scenarios
2022-07-04 22:59:00 【Gu Ge academic】
1.3.1 Redis What can be done
1. cache
Caching mechanism is used in almost all large websites , Reasonable use of cache can not only add
Fast data access speed , And it can effectively reduce the pressure of back-end data sources .Redis Provides
Key value expiration time setting , It also provides the elimination strategy after flexibly controlling the maximum memory and memory overflow
A little . You can say that , A reasonable cache design can guarantee the stability of a website . The first
11 This chapter will describe the design and use of cache in detail .
2. Ranking system
Ranking system exists in almost all websites , For example, ranking by popularity , according to
Ranking list of release time , Rankings calculated from various complex dimensions ,Redis Provides a list
And ordered set data structures , Using these data structures reasonably can easily build various rankings
List system .
3. Counter application
Counters play an important role in websites , For example, the video website has the number of plays 、 E-commerce websites have
Browse the number , In order to ensure real-time data , Every time you play and browse, you have to add 1 The operation of , Such as
As a result, the large amount of concurrency is a challenge to the performance of traditional relational data .Redis Natural support count
Function and counting performance is also very good , It is an important choice of counter system .
4. Social networks
Fabulous / Step on 、 fans 、 Common friends / like 、 push 、 Pull down and refresh are necessary functions of social networking sites , Because social networking sites are usually heavily visited , Moreover, the traditional relational data is not suitable for saving
This type of data ,Redis The data structure provided can realize these functions relatively easily
can .
5. Message queuing system
Message queuing system can be said to be a necessary basic component of a large website , Because it has a business
decoupling 、 Non real time service peak shaving and other features .Redis It provides publish and subscribe function and blocking queue function
can , Although it's not strong enough compared to a professional message queue , But for general message queuing functions
Can basically satisfy .
1.3.2 Redis What can't be done
In fact, like any technology , Each technology has its own application scenarios and boundaries , also
That is to say Redis It's not a panacea , There are a lot of problems that it can solve , But there are also many disagreements
The problem it solves . We can analyze it from the perspective of data scale and hot and cold data .
From the perspective of data scale , Data can be divided into large-scale data and small-scale data , We
know Redis Is stored in memory , Although memory is cheap enough now , But like
The amount of data is very large , For example, there are hundreds of millions of user behavior data every day , Use Redis To store the
word , It's basically a bottomless hole , The economic cost is quite high .
From a data perspective , The data is divided into hot data and cold data , Thermal data usually refers to the need
Data to be operated frequently , On the contrary, it is cold data , For example, for video sites , Basic video information
Basically, there are data that need to be operated frequently in all business lines , And the user's viewing record is not necessarily through
Data that often needs to be accessed , Let's not discuss the difference of data scale between the two , Simply stand on the data cold
From the perspective of heat , Video information belongs to hot data , User viewing records are cold data . If the
Put some cold data on Redis in , It's basically a waste of memory , But for some heat numbers
It can be put in Redis Speed up reading and writing in , It can also reduce the load of back-end storage , It can be said to be half done
Work twice .
therefore ,Redis It's not a panacea , I believe that with our understanding of Redis Step by step learning , Can clear
Chu Redis Real use scenarios .
1.4 The use of good Redis The advice of
1. Don't use it as a black box , Development is as important as operation and maintenance
Many uses Redis Most developers think that as long as they can use API Develop the corresponding functions , What's more
Even think Redis Namely get、set、del, You don't need to know Redis Principle . But in our reality
International transportation and peacekeeping use Redis In the process of discovery , A lot of online failures and problems are due to completely
Redis As a black box , If you don't understand Redis Single thread model , Some developers will have
Tens of millions of keys Redis On the implementation keys* operation , If you don't understand the principles of persistence , Will be in
A large number of write operations Redis The configuration is saved automatically RDB. And in many companies, there are only specialized
Job relational database DBA, did not NoSQL The relevant operation and maintenance personnel , That is to say, developers
It is likely to operate and maintain by itself Redis, about Redis It's both a good thing and a bad thing for developers . standing
On the bright side , Developers can use operation and maintenance Redis Really understand Redis Some of the principles , No
Simply stay on development . On the bad side ,Redis It's not just about supporting development ,
We have to take the responsibility of operation and maintenance , Moreover, due to lack of operation and maintenance experience, it may cause online failure . But from
From practical experience , Operation and maintenance is of sufficient scale Redis Will make good use of Redis More helpful .
2. Read the source code
We mentioned earlier ,Redis It's an open source project , Because of the author's understanding of Redis The ultimate pursuit of code
seek ,Redis The amount of code is relative to many NoSQL Database is very small , That means
As an ordinary development and operation and maintenance personnel, you can “ Read and ”Redis Of . By reading excellent sources
code , Not only can we deepen our understanding of Redis The understanding of the , And it can also improve its coding level ,
You can even be right Redis Make it customized , That is to say, it can be modified Redis Source code to meet their own needs
seek , For example, Sina Weibo is Redis The early version of has made a lot of customization to meet their own needs , Pea pod is also open source based on Proxy Of Redis Distributed implementation Codis.
边栏推荐
- [the 2023 autumn recruitment of MIHA tour] open [the only exclusive internal push code of school recruitment eytuc]
- 攻防世界 MISC 进阶 glance-50
- 【图论】拓扑排序
- The overview and definition of clusters can be seen at a glance
- The table is backed up in ODPs. Why check m in the metabase_ Table, the logical sizes of the two tables are inconsistent, but the number of
- 特征缩放 标准化 归一化
- Three stage operations in the attack and defense drill of the blue team
- Attack and defense world misc advanced area ditf
- Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
- Google Earth Engine(GEE)——Tasks升级,实现RUN ALL可以一键下载任务类型中的所有影像
猜你喜欢
Attack and defense world misc advanced grace-50
Three stage operations in the attack and defense drill of the blue team
Google Earth Engine(GEE)——Tasks升级,实现RUN ALL可以一键下载任务类型中的所有影像
Redis getting started complete tutorial: publish and subscribe
[OpenGL] note 29 anti aliasing (MSAA)
攻防世界 MISC 进阶区 Ditf
【剑指Offer】6-10题
Redis入门完整教程:Bitmaps
安装人大金仓数据库
Unity-VScode-Emmylua配置报错解决
随机推荐
攻防世界 MISC 进阶区 hong
[Lua] Int64 support
[machine learning] handwritten digit recognition
Gnawing down the big bone - sorting (II)
【lua】int64的支持
A complete tutorial for getting started with redis: redis shell
P2181 diagonal and p1030 [noip2001 popularization group] arrange in order
Mongodb aggregation operation summary
A complete tutorial for getting started with redis: hyperloglog
The solution to the lack of pcntl extension under MAMP, fatal error: call to undefined function pcntl_ signal()
The difference between Max and greatest in SQL
SHP data making 3dfiles white film
Unity vscode emmylua configuration error resolution
[odx Studio Edit pdx] - 0.2 - Comment comparer deux fichiers pdx / odx
Redis入门完整教程:客户端通信协议
How can enterprises cross the digital divide? In cloud native 2.0
攻防世界 MISC 高手进阶区 001 normal_png
Redis入门完整教程:有序集合详解
Business is too busy. Is there really no reason to have time for automation?
Erik baleog and Olaf, advanced area of misc in the attack and defense world