当前位置:网站首页>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.
边栏推荐
- Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
- 攻防世界 MISC 进阶区 can_has_stdio?
- 攻防世界 MISC 进阶区 Ditf
- P2181 diagonal and p1030 [noip2001 popularization group] arrange in order
- 攻防世界 MISC 进阶区 Erik-Baleog-and-Olaf
- Redis: redis configuration file related configuration and redis persistence
- Google Earth engine (GEE) - tasks upgrade enables run all to download all images in task types with one click
- The difference between Max and greatest in SQL
- How to send a reliable request before closing the page
- 剑指Offer 68 - II. 二叉树的最近公共祖先
猜你喜欢
集群的概述与定义,一看就会
Redis入门完整教程:Bitmaps
Redis入门完整教程:哈希说明
[sword finger offer] questions 1-5
A complete tutorial for getting started with redis: transactions and Lua
Hit the core in the advanced area of misc in the attack and defense world
sobel过滤器
Advanced area of attack and defense world misc 3-11
Attack and defense world misc advanced area can_ has_ stdio?
Attack and defense world misc advanced zone 2017_ Dating_ in_ Singapore
随机推荐
9 - 类
串口数据帧
Sobel filter
【ODX Studio編輯PDX】-0.2-如何對比Compare兩個PDX/ODX文件
Co create a collaborative ecosystem of software and hardware: the "Joint submission" of graphcore IPU and Baidu PaddlePaddle appeared in mlperf
Li Kou 98: verify binary search tree
Install the gold warehouse database of NPC
Analysis of the self increasing and self decreasing of C language function parameters
MYSQL架构——用户权限与管理
MySQL Architecture - logical architecture
How can enterprises cross the digital divide? In cloud native 2.0
Google Earth engine (GEE) - tasks upgrade enables run all to download all images in task types with one click
[the 2023 autumn recruitment of MIHA tour] open [the only exclusive internal push code of school recruitment eytuc]
Gnawing down the big bone - sorting (II)
Talk about Middleware
Google Earth engine (GEE) - globfire daily fire data set based on mcd64a1
Redis入门完整教程:Bitmaps
质量体系建设之路的分分合合
Complete tutorial for getting started with redis: bitmaps
Google Earth Engine(GEE)——Tasks升级,实现RUN ALL可以一键下载任务类型中的所有影像