当前位置:网站首页>Redis缓存雪崩
Redis缓存雪崩
2022-06-10 19:55:00 【飞Link】
一、问题描述
key对应的数据存在,但在redis中过期,此时若有大量并发请求过来,这些请求发现缓存过期一般都会从后端数据库加载数据并回设到缓存,这个时候打冰法的请求可能会瞬间把后端数据库压垮
缓存雪崩与缓存击穿的区别在于这里针对很多key缓存,前者则是某一个key
正常访问

缓存失效瞬间

二、解决方案
1. 构建多级缓存架构
nginx缓存 + redis缓存 + 其他缓存(ehcache等)
2. 使用锁或队列
用加锁或者队列的方式保证不会有大量的线程对数据库一次性地进行读写,从而避免失效时大量的并发请求落到底层存储系统上。不适用高并发情况
3. 设置过期标志更新缓存
记录缓存数据是否过期(设置提前量),如果过期会触发通知另外的线程在后台去更新实际key的缓存
4. 将缓存失效时间分散开
比如我们可以在原有的失效时间基础上增加一个随机值,比如1-5分钟随机,这样每一个缓存的过期时间的重复率就会降低,就很难引发集体失效的事件
边栏推荐
- MySQL service startup failed
- Is Zhongyan futures a regular platform in China? Is it safe to open an account? Want to open a futures account
- 解决idea超过5个相同包的时候自动变成*的问题
- Is Jiuzhou futures regular? Is it safe to open an account
- Pytorch deep learning -- convolution operation and code examples
- Power consumption development experience sharing: design power consumption board
- Arduino中Serial.print()与Serial.write()函数的区别,以及串口通信中十六进制与字符串的收发格式问题和转换过程详解
- Recommend a crud tool that may become the best crud tool in 2019 during the National Day
- How to use Diablo immortal database
- 在阿里云国际上使用 OSS 和 CDN 部署静态网站
猜你喜欢

In MySQL basics, MySQL adds an automatically added primary key (or any field) to an existing table

Elastic-Job的快速入门,三分钟带你体验分布式定时任务

You have to learn math to play art?

LeetCode:1037. Effective boomerang - simple

Microsoft Word 教程「5」,如何在 Word 中更改页边距、创建新闻稿栏?

canvas 高级功能(上)

PDF. JS - - - - JS analyse le fichier PDF pour réaliser l'aperçu et obtenir le contenu du fichier PDF (sous forme de tableau)
![JS basic and frequently asked interview questions [] = =! [] result is true, [] = = [] result is false detailed explanation](/img/42/bcda46a9297a544b44fea31be3f686.png)
JS basic and frequently asked interview questions [] = =! [] result is true, [] = = [] result is false detailed explanation

Microsoft Word tutorial, how to change page orientation and add borders to pages in word?

详解三级缓存解决循环依赖
随机推荐
CET-6 - Business English - the last recitation before the test
NetWorkX使用方法及 nx.draw()相关参数
Microsoft Word tutorial "5", how to change the margins and create a newsletter column in word?
Self attention and multi head attention
P5723 [deep base 4. example 13] prime number pocket
H5 van popup full screen pop-up window, simulates the page fallback effect, supports the return button in the upper left corner, and is suitable for physical return, side sliding and bottom return key
Recommend a crud tool that may become the best crud tool in 2019 during the National Day
在阿里云国际上使用 OSS 和 CDN 部署静态网站
Pytorch deep learning -- neural network convolution layer conv2d
vulnhub-The Planets: Earth
Redis set password command (temporary password)
保姆级教程:如何成为Apache Linkis文档贡献者
轻便型FDW框架 for pb
Networkx usage and nx Draw() related parameters
Mixin -- mixed
Mysql database foundation
35岁被裁员,还能拥有美妙人生吗?
In depth learning experience and tools
农产品期货开户的条件是什么?现在开户的手续费是多少?
Redis cluster form - sentry mode cluster and high availability mode cluster - redis learning notes 003