当前位置:网站首页>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.
边栏推荐
- 通过Go语言创建CA与签发证书
- 云服务器设置ssh密钥登录
- Is Huatai Securities a nationally recognized securities firm? Is it safe to open an account?
- 串口数据帧
- Create Ca and issue certificate through go language
- 攻防世界 MISC 進階區 Erik-Baleog-and-Olaf
- 模拟摇杆控制舵机
- 攻防世界 MISC 进阶区 hong
- 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
- Taobao commodity review API interface (item_review get Taobao commodity review API interface), tmall commodity review API interface
猜你喜欢
【剑指Offer】6-10题
Unity修仙手游 | lua动态滑动功能(3种源码具体实现)
小程序vant tab组件解决文字过多显示不全的问题
【图论】拓扑排序
Unity Xiuxian mobile game | Lua dynamic sliding function (specific implementation of three source codes)
A complete tutorial for getting started with redis: hyperloglog
Redis入门完整教程:键管理
Detailed explanation of heap sort code
常用技术指标之一文读懂BOLL布林线指标
Business is too busy. Is there really no reason to have time for automation?
随机推荐
NFT Insider #64:电商巨头eBay提交NFT相关商标申请,毕马威将在Web3和元宇宙中投入3000万美元
Notepad++ -- editing skills
Complete tutorial for getting started with redis: bitmaps
Redis: redis configuration file related configuration and redis persistence
Li Kou 98: verify binary search tree
Sword finger offer 65 Add without adding, subtracting, multiplying, dividing
Feature scaling normalization
攻防世界 MISC 进阶区 hong
啃下大骨头——排序(二)
Gnawing down the big bone - sorting (II)
Summary of index operations in mongodb
Unity-VScode-Emmylua配置报错解决
vim编辑器知识总结
Redis入门完整教程:慢查询分析
【图论】拓扑排序
Google Earth Engine(GEE)——Tasks升级,实现RUN ALL可以一键下载任务类型中的所有影像
集群的概述与定义,一看就会
Redis入门完整教程:事务与Lua
Create Ca and issue certificate through go language
Taobao commodity review API interface (item_review get Taobao commodity review API interface), tmall commodity review API interface