当前位置:网站首页>Redis (IX) - enterprise level solution (II)
Redis (IX) - enterprise level solution (II)
2022-06-30 18:03:00 【Zhaoliwen is a pig】
Redis( Nine )—— Enterprise solutions ( Two )
List of articles
3、 Cache breakdown
Database server crash (2)
- During the smooth operation of the system
- Number of database connections An instant surge
- Redis There's not a lot of servers key Be overdue
- Redis Memory smooth , No fluctuations
- Redis The server CPU normal
- Database crash
Troubleshoot problems
- Redis in Some key Be overdue , The key There's a lot of traffic
- Multiple data requests are pressed directly from the server to Redis after , All miss
- Redis A large number of accesses to the same data in the database are initiated in a short time
Problem analysis
- Single key High heat data
- key Be overdue
Solution ( Technique )
Preset
Take e-commerce for example , Each business according to the store level , Specify a number of key products , During the Shopping Festival , enlarge Such information key Of Expiration time
Be careful : Shopping day is not just about the day , And the next few days , The peak value of access is gradually decreasing
On site adjustment
- Monitoring traffic , Extend the expiration time or set to permanent for data with natural traffic surge key
Background refresh data
- Start timing task , Before the peak , Refresh data validity period , Make sure you don't lose
Second level cache
- Set different failure times , It's not going to be eliminated at the same time
Lock Distributed lock , To prevent breakdown , But it's also a performance bottleneck , Be careful !
summary
Cache breakdown is The moment when a single hot data expires , Large amount of data access , Not hit redis after , Initiated a large number of database queries on the same data , Causing pressure on the database server . Coping strategies should be in business data analysis and prevention , Cooperate with operation monitoring test and real-time adjustment strategy , After all, single key It's difficult to monitor the overdue data , Combined with avalanche treatment strategy
4、 Cache penetration
Malicious request
The primary keys in our database are from 0 At the beginning , Even if we put all the data in the database into the cache . When someone uses id=-1 To happen Malicious request when , because redis There's no data in , Will directly access the database , This is called cache penetration
terms of settlement
- Check the validity of data in the program , If it's illegal, go back
- Use The bloon filter
Brief introduction of bloon filter
Want to avoid cache penetration as much as possible , One way is to... The data Pre calibration , In the face of Redis Before operating with the database ,** First check whether the data exists , If it doesn't exist, go straight back .** If we want to query whether an element exists , To ensure query efficiency , You can choose HashSet, But if there is 10 Billion data , Use both HashSet For storage , Memory must not be able to hold . Then you need a bloom filter
The bloon filter ( English :Bloom Filter) yes 1970 Proposed by bron in . It's actually a very long binary vector (bit Array ) And a series of random mapping functions (hash). The bloom filter can be used to retrieve whether an element is in a collection
Because it's based on Digit group and hash function Of , So it's advantage yes Space efficiency and query The time is much longer than the general algorithm . but shortcoming Is also evident , That is, there is a certain false recognition rate and deletion difficulty . But by increasing the size of the digit group and increasing hash Number of functions to Reduce False recognition rate ( Can only lower , Can't be avoided )
Put in the process
After the bloom filter is initialized , The values in the digit group are 0. When a variable is going to be put into the bloom filter , Will pass through multiple hash Function maps to each bit of the bit group , then Set the corresponding position to 1
The query process
The query is still through multiple hash Function maps to each bit of the bit group , If each bit is 1, Describe the element Possible , Note that there may be !!. But if through mapping , The digit group corresponds to the upper digit Not for 1, Then the element must not exist
Put in the process diagram
For example, one of our Bloom filters 8 The number group of bits , And there are 3 individual hash function Calculate the elements , Map to each bit in the array
We will string ”Nyima” Put it in a bloom filter
Next, the string ”Cpower” Put it in a bloom filter
Query process diagram
For example, we need to query the string ”Cpower” Whether there is , adopt 3 individual hash The function maps to three positions of the digit group , All three positions are 1, Then the String may exist
For example, we need to query the string ”SWPU” Whether there is , adopt 3 individual hash The function maps to the three positions of the digit group , Found a location that is not 1, Then the The string must not exist
For example, we need to query the string ”Hulu” Whether there is , adopt 3 individual hash The function maps to the three positions of the digit group , Found that all locations are 1, But we didn't put the string ”Hulu” Put it in a bloom filter , So here There was a miscarriage of justice
Increase the size and size of the digit group hash The number of functions can reduce the misjudgment rate , But there is no way to avoid misjudgment
边栏推荐
- Flutter custom component
- Building a basic buildreoot file system
- IEEE TBD SCI影响因子提升至4.271,位列Q1区!
- 腾讯云安装mysql数据库
- [bjdctf2020]the mystery of ip|[ciscn2019 southeast China division]web11|ssti injection
- Exploration and practice of "flow batch integration" in JD
- MySQL reports that the column timestamp field cannot be null
- Fragmentary knowledge points of MySQL
- Animesr: learnable degradation operator and new real world animation VSR dataset
- Daily interview 1 question - basic interview question of blue team - emergency response (1) basic idea process of emergency response +windows intrusion screening idea
猜你喜欢

Plane intersection and plane equation

6 张图带你搞懂 TCP 为什么是三次握手?

Six pictures show you why TCP has three handshakes?

Splitting. JS text title slow loading JS effect
![Ten thousand volumes - list sorting [01]](/img/d4/124101b919a4d8163a32fc0f158efa.png)
Ten thousand volumes - list sorting [01]

Rexroth hydraulic control check valve z2s10-1-3x/

Design and principle of tubes responsive data system

Simulation of campus network design based on ENSP

零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示

Course design for the end of the semester: product sales management system based on SSM
随机推荐
MIT science and Technology Review released the list of innovators under the age of 35 in 2022, including alphafold authors, etc
元宇宙带来的游戏变革会是怎样的?
Apache 解析漏洞(CVE-2017-15715)_漏洞复现
Animesr: learnable degradation operator and new real world animation VSR dataset
Exploration and practice of "flow batch integration" in JD
Post penetration file system + uploading and downloading files
Building a basic buildreoot file system
Exch:完整性检查 Database Integrity Checking
Small tools (3) integration knife4j3.0.3 interface document
【网易云信】播放demo构建:无法将参数 1 从“AsyncModalRunner *”转换为“std::nullptr_t”**
NFT铸造交易平台开发详情
Develop those things: how to add text watermarks to videos?
MySQL reports that the column timestamp field cannot be null
Daily question brushing record (IX)
Redis (I) - data type
Tencent cloud installs MySQL database
联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
Word中添加代码块(转载)
Exch:exchange server 2013 is about to end support
ABAP-发布Restful服务




