当前位置:网站首页>Cache penetration, cache breakdown, cache avalanche and Solutions
Cache penetration, cache breakdown, cache avalanche and Solutions
2022-07-29 05:07:00 【Doghead Intern】
redis It's a kind of NoSql High speed slow K-V Save the database , Can achieve fast access .
redis More suitable for storage Session Information 、 cache 、 Ranking List 、 Message queue 、 Friends and counters
redis Cache penetration
redis Cache penetration refers to querying data that must not exist , But there is no such data in the cache , You need to query from the database , And there is no such data in the database , So it will not be written to redis in , This leads to querying the database every time you access the nonexistent data , This leads to cache penetration .
terms of settlement :
Cache null values , If the data cannot be queried from the database , We can set a null value with a short expiration time to be stored in redis in
Using interceptors , Judge the accessed data , Shield the data that must not exist .
Use of Blum filter , Use a larger bitmap To filter key.
The bloon filter
The working principle of Bloom filter is well understood , Is to store objects in a hash table , To judge whether the object exists . In order to improve judgment , Multiple hash functions can be used for hash distribution .
Collective implementation method of Bloom filter , Pass an object through multiple hash functions , Get different hash values , And then bitmap The position in is determined by 0 Set as 1, For example, one Tom There may be three hash functions , Exist in sixteen spaces bitmap in , Location may be 3,5,15.
The reason why objects need to be hashed many times is , Different objects , After the same hash function , The hash value may be the same , That is to say Hash collision , So we need to try to reduce this possibility .
So to sum up , If we want to judge whether an object exists , You need to pass the object through the hash function in turn , Calculate the hash value , As long as bitmap There is a position in 0, Then the object must not exist . If all positions of the object are 1, Then the object may exist ( Hash collision may cause us to misjudge ).
redis Cache breakdown
Cache breakdown is a special case of cache avalanche , It refers to a hot data , At the moment the cache expires , There are a lot of requests to access this data , Cause breakdown to DB, cause DB Too much pressure on me .
resolvent
Use synchronized+ Double check mechanism , Take data from DB Is written to the cache , reduce DB pressure .
Never expired data settings
Redis Cache avalanche
Cache avalanche means that the cache concentration disappears within a period of time , Cause a lot of cache breakdown , thus DB Too much pressure load .
resolvent
Use synchronized+ Double check mechanism , Control the number of reads from the database and writes to the cache by locking , Some key Only one thread is allowed to query and write to the cache , Other threads wait .
Add a random value to the cache expiration time , Reduces cache expiration at the same time .
Cache preheating , Avoid projects starting , The cache is empty , Cause a lot of requests to DB, Load the data into the cache in advance .
边栏推荐
- 缓存穿透、缓存击穿、缓存雪崩以及解决方法
- SparkSql批量插入或更新,保存数据到Mysql中
- Go memory model for concurrency
- 传奇如何一台服务器配置多个版本微端更新
- 如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
- On prepayment of house purchase
- Solution | get the relevant information about the current employees' highest salary in each department |
- Quick start JDBC
- How to install Office2010 installation package? How to install Office2010 installation package on computer
- Conv1d of torch
猜你喜欢

学习数据库的第一个程序

力扣------对奇偶下标分别排序

Quick start JDBC

How to set row height and column width in excel? The method of setting row height and column width in Excel

Traffic flow prediction pit climbing record (I): traffic flow data set, original data

Five correlation analysis, one of the most important skills of data analysts

Torch.nn.crossentropyloss() details

Use openmap and ArcGIS to draw maps and transportation networks of any region, and convert OMS data into SHP format

ODOO开发教程之透视表

Sparksql inserts or updates in batches and saves data to MySQL
随机推荐
AttributeError: ‘module‘ object has no attribute ‘create_connection‘
传奇开区网站如何添加流量统计代码
金达威董秘回复:公司看好NMN产品的市场前景,已推出系列产品
Huawei ilearning AI mathematics foundation course notes
Double type nullpointexception in Flink flow calculation
2021-10-11
Torch.nn.crossentropyloss() details
Introduction of JDBC preparestatement+ database connection pool
Sguard64.exe ace guard client exe: frequent disk reading and writing, game jamming, and Solutions
那个准时上下班,从不愿意加班加点的人,在我前面升职了...
How does WPS take quick screenshots? WPS quick screenshot method
The most comprehensive promotion plan for the launch of new products
Google GTEST event mechanism
On prepayment of house purchase
How to set row height and column width in excel? The method of setting row height and column width in Excel
EMI interference troubleshooting with near-field probe and current probe
开源汇智创未来 | 2022开放原子全球开源峰会 openEuler 分论坛圆满召开
Glory 2023 push, push code ambubk
JDBC statement + resultset introduction
P2181 diagonal