当前位置:网站首页>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 .
边栏推荐
- Object mapping - mapping Mapster
- 串行通信接口8250
- [cloud native | kubernetes] in depth understanding of deployment (VIII)
- 695. maximum island area
- [target tracking] |pytracking configuring win to compile prroi_ pool. pyd
- Biological network analysis using deep learning
- Global capital market 101: Breit, one of the best investment targets for domestic high net worth people
- 60 个神级 VS Code 插件!!
- Some commonly used hardware information of the server (constantly updated)
- 90.(cesium篇)cesium高度监听事件
猜你喜欢

品达通用权限系统(Day 7~Day 8)

腾讯二面:@Bean 与 @Component 用在同一个类上,会怎么样?
![移除无效的括号[用数组模拟栈]](/img/df/0a2ae5ae40adb833d52b2dddea291b.png)
移除无效的括号[用数组模拟栈]

浏览器播放rtsp视频,基于nodeJs

Introduction to new features of ES6

Hannaiping of Qilin software: the construction of Digital China needs its own open source root community

Openmldb meetup No.4 meeting minutes

SuperMap iDesktop 常见倾斜数据处理全流程解析

Set set

Instructions for legend use in SuperMap iclient3d 11i for cesium 3D scene
随机推荐
Getting started with the go language is simple: go handles XML files
解决服务器重装无法通过ssh连接的问题
STM32 移植 RT-Thread 标准版的 FinSH 组件
Serial communication interface 8250
杂文:自家的智能家居方案研究
【LeetCode】15、三数之和
视频按每100帧存一个文件夹,处理完再图片转视频
21. Notes on WPF binding
DMA controller 8237a
Go 语言入门很简单:Go 处理 XML 文件
3D视觉检测在生产流水的应用有哪些
How to detect 3D line spectral confocal sensors in semiconductors
[bug solution] fiftyone reports attributeerror: module 'CV2' has no attribute 'GAPI_ wip_ gst_ Gstreamerpipeline 'error resolution
Swagger2自动生成APi文档
海思3559开发常识储备:相关名词全解
Time function and clock_ Differences between gettime() functions
edusoho企培版纯内网部署教程(解决播放器,上传,后台卡顿问题)
各厂家rtsp地址格式如下:
Vscode select multiple words
Building a database model using power designer tools