当前位置:网站首页>Redis cache problem
Redis cache problem
2022-06-30 12:28:00 【Array_ new】
Preface :
Every time you start a project, there will be too much data in the database, which will lead to too much data storage when you first enter , Multiple requestors of home page information can be used directly MySQL The database is slow , Affect the user experience by redis Solutions to cache problems , To improve energy .
Cache penetration
This means that the data requested by the client does not exist in the cache or in the database , Such a cache will never work , These requests will all go to the database
Problem solving :
- Caching empty objects
advantage : Implement a simple , Convenient maintenance
shortcoming : Extra memory consumption , May cause short-term inconsistencies

2. Bloon filtration
advantage : Less memory usage , There is no excess Key
shortcoming : The implementation is complex , There is a possibility of misjudgment

Cache breakdown
Cache breakdown means that the data queried by the user does not exist in the cache , But the back-end database exists , The reason for this phenomenon is that it is generally caused by key Due to expiration . For example, a hot data key, It receives a lot of concurrent access all the time , If at some point this key All of a sudden it failed , This causes a large number of concurrent requests to enter the back-end database , Cause its pressure to increase instantaneously . This phenomenon is called cache breakdown .
There are two solutions to cache breakdown :
1) Change expiration time
Never expired data settings .
2) Distributed lock
Adopt the method of distributed lock , Redesign how cache is used , The process is as follows :
- locked : When we go through key When you go to query data , First query the cache , without , Lock through distributed lock , The first process to obtain the lock enters the back-end database to query , And slow the query results to Redis in .
- Unlock : When other processes find that the lock is occupied by a process , It will enter the waiting state , Until unlocked , The other processes then access the cached key.
Cache avalanche
Cache avalanche refers to a large number of key At the same time , At this time, the amount of data access is very large , This leads to a sudden surge in the pressure on the back-end database , Even hang up , This phenomenon is called cache avalanche . It's different from cache breakdown , Cache breakdown occurs when the amount of concurrency is particularly large , A hot spot key Suddenly expired , The cache avalanche is a lot of key At the same time , So they are not an order of magnitude at all .
Solution
There are similarities between cache avalanche and cache breakdown , So you can also use the method that hot data never expires , To reduce large quantities of key At the same time . Another is to key Set random expiration time , avoid key Concentration expired .
边栏推荐
- Introduction to sub source code updating: mid May: uniques NFT module and nomination pool
- 剑指 Offer 05. 替换空格: 把字符串 s 中的每个空格替换成“%20“
- QT MSVC installation and commissioning
- NoSQL - redis configuration and optimization
- Object mapping - mapping Mapster
- List collection
- Joplin implements style changes
- 腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
- 不同类型的变量与零究竟是如何比较
- AGCO AI frontier promotion (6.30)
猜你喜欢

海思3559萬能平臺搭建:獲取數據幀修改後編碼

Construction de la plate - forme universelle haisi 3559: obtenir le codage après modification du cadre de données
Redis - ziplist compressed list

What is the principle of spectral confocal displacement sensor? Which fields can be applied?
![[leetcode] 15. Sum of three numbers](/img/0c/4363d7737d90c170eb4519828990b9.png)
[leetcode] 15. Sum of three numbers

List集合

SuperMap iServer11i新功能----图例的发布和使用
![[target tracking] |pytracking configuring win to compile prroi_ pool. pyd](/img/ac/1e443164e57c4f34ddd1078de9f0d2.png)
[target tracking] |pytracking configuring win to compile prroi_ pool. pyd

Map collection

How to detect 3D line spectral confocal sensors in semiconductors
随机推荐
SuperMap iclient3d for webgl loading TMS tiles
Hisilicon 3559 universal platform construction: introduction to YUV format
通过EF Core框架根据SQL Server数据库表生成实体类
Remove invalid parentheses [simulate stack with array]
[bug solution] fiftyone reports attributeerror: module 'CV2' has no attribute 'GAPI_ wip_ gst_ Gstreamerpipeline 'error resolution
Redis6 learning notes - Chapter 2 - Basic redis6 operations
Redis-缓存问题
edusoho企培版纯内网部署教程(解决播放器,上传,后台卡顿问题)
1020. 飞地的数量
Solve the problem that the server cannot be connected via SSH during reinstallation
Use of polarplot function in MATLAB
Swagger2 automatically generates API documents
pyqt5界面的布局与资源文件的载入
lvgl 小部件样式篇
MySQL built-in functions
Introduction to new features of ES6
Mysql中 begin..end使用遇到的坑
Inner join and outer join of MySQL tables
Vscode select multiple words
Map collection