当前位置:网站首页>Cache avalanche and cache penetration solutions
Cache avalanche and cache penetration solutions
2022-06-30 11:43:00 【Full stack programmer webmaster】
Cache avalanche and cache penetration Cache avalanche : Simply put, cache invalidation , Originally, the cached data is directly accessed to the database , This causes great pressure on the database and memory , Serious problems may lead to database downtime 、 Server crash . Solution : 1. Use distributed locks or control the number of threads reading and writing to the database cache for columns , Ensure that there are threads to operate . Lack of This reduces the throughput of the system 2.redis Medium key The failure time shall be set as evenly as possible 3. Use mq To solve the cache avalanche effect . When a large number of requests for access redis No value in , Put the query parameters on the message queue , The consumer receives the message, queries the database, and returns the result to the generator in a synchronous manner . Message oriented middleware has the function of caching messages 4. Set L1 and L2 cache . If the L1 cache fails , Let access request L2 cache , It should be noted that the L2 cache expiration time is better than the L1 cache expiration time . 5. If it is one redis Server down , Can be built redis The main equipment High availability .
The upper level of the cache can also set the service degradation 、 Isolation 、 Fault tolerance 、 Fuse, etc. to prevent avalanche .—-springcloud Service governance framework , Service fault tolerance mechanism hystrix
Cache penetration : The process of caching : When users query data, they first query the cache , If the cache does not , Query the database , Put the result of the query into a cache , The next time you query, if there is data in the cache , It is directly returned to the client to reduce the pressure on the database . Cache penetration : The data queried by the user does not exist in the database , Therefore, there is no result of user query data in the cache . If someone maliciously attacks and uses this query data to query all the time , Causing database pressure to increase .
Solution :1. Cache an empty result of the query . This can simply and effectively avoid bypassing the cache and directly querying the database . 2. At the same time, you can also set a separate cache area to store null values , For the query key Pre check , And then release it to the normal cache processing logic
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/100801.html Link to the original text :https://javaforall.cn
边栏推荐
- PointDistiller:面向高效紧凑3D检测的结构化知识蒸馏
- Set up your own website (13)
- Line generation (Gauss elimination method, linear basis)
- 孔松(信通院)-数字化时代云安全能力建设及趋势
- Qualcomm released the "magic mirror" of the Internet of things case set, and digital agriculture has become a reality
- 暑假学习记录
- Record the memory leak of viewpager + recyclerview once
- Esp32-c3 introductory tutorial question ⑨ - core 0 panic 'ed (load access fault) Exception was unhandled. vfprintf. c:1528
- 10 reasons for system performance failure
- What is erdma as illustrated by Coptic cartoon?
猜你喜欢

孔松(信通院)-数字化时代云安全能力建设及趋势

If it is not listed again, Kuangshi technology will not be able to endure

R language view version R package view version

Oracle NetSuite 助力 TCM Bio,洞悉数据变化,让业务发展更灵活

Object mapping - mapping Mapster

【IC5000教程】-01-使用daqIDEA图形化debug调试C代码

谁还记得「张同学」?

考研这些“不靠谱”的经验有多害人?

Set up your own website (13)

"New digital technology" completed tens of millions of yuan of a + round financing and built an integrated intelligent database cloud management platform
随机推荐
19年来最艰难的618,徐雷表达三个谢意
A quietly rising domestic software, low-key and powerful!
60 个神级 VS Code 插件!!
A theoretical defect of relative position coding transformer and Its Countermeasures
Filter error in dplyr: can't transform a data frame with duplicate names
限时预约|6 月 Apache Pulsar 中文开发者与用户组会议
Shutter from zero 004 button assembly
R language de duplication operation unique duplicate filter
“新数科技”完成数千万元A+轮融资,造一体化智能数据库云管理平台
H3C switch emptying configuration
"New digital technology" completed tens of millions of yuan of a + round financing and built an integrated intelligent database cloud management platform
Speech signal processing - Fundamentals (V): Fourier transform
The latest collection of arouter problems
100 important knowledge points that SQL must master: join table
相对位置编码Transformer的一个理论缺陷与对策
考研这些“不靠谱”的经验有多害人?
Multiparty cardinality testing for threshold private set-2021: Interpretation
wallys/600VX – 2×2 MIMO 802.11ac Mini PCIe Wi-Fi Module, Dual Band, 2,4GHz / 5GHz QCA 9880
脚本中如何'优雅'避免MySQL登录提示信息
“\“id\“ contains an invalid value“