当前位置:网站首页>Optimization ideas from ordinary query commodities to highly concurrent query commodities
Optimization ideas from ordinary query commodities to highly concurrent query commodities
2022-07-28 06:44:00 【yfyh2021】
- version 0( The initial release )

problem 1: More and more goods ,redis Carrying more and more
- version 1

problem 1 Solutions : Set timeout
problem 2: We usually initialize at startup redis Product inventory of , If set like this , A large number of cache failures may occur at the same time .
- version 2

problem 2 Solutions : take redis The effective time of changes from fixed time to variable time .
problem 3: For popular products, no one has browsed them for half a year , Can this pair reduce us redis What about your storage
- version 3

problem 3 Solutions : Every time we go from redis The products we get are all popular products , So we postpone reading ( In the red frame ), In this way, we can simply realize a cold and hot separation .
problem 4: If users or hackers keep accessing non-existent products ( Cache penetration problem ), In addition to the use of Bronx filters , What can we do in the back-end code .
- version 4

problem 4 Solution : Since there are empty products found , Then let's return to the front end with an empty product ,redis Set a shorter effective time in , With Bloom filter , It can effectively prevent cache penetration .
problem 5: If you encounter a sudden explosion ( Hotspot reconstruction ), In an instant, tens of thousands of visits hit our database , It directly leads to the downtime of our database ( Cache breakdown ), What do I do .
- version 5

Will be taken from redis Get the code of the product, extract it and package it , Or a little messy . The following is the version 5 The optimization of the .
problem 5 Solution : Realize with lock , Here I also use double check (DCL) To guarantee .
problem 6: For production environment , When the concurrency is particularly high, it is still very easy to have double write inconsistencies , What do I do .
- version 6

problem 6 Solution : Database query and redis Set this step in locking , To try to ensure that our double writing is consistent .
problem 7: Two locks have been added , Whether locks can be optimized .
- version 7


problem 7 Solutions : We can use read-write lock for this situation of reading more and writing less , Ensure that threads can execute in parallel when reading , Increase throughput .
summary , When using the cache, you basically need to lock , If the concurrency is so large that this framework can't bear it now, it can be used more guava perhaps ehcache Wait for the local caching framework .
边栏推荐
猜你喜欢

Leetcode brush question diary sword finger offer II 055. binary search tree iterator

Everything you don't know about time complexity is here

2022-05-24 use of spiel

Leetcode skimming diary sword finger offer II 050. sum of downward path nodes

Icc2 (IV) routing and postroute optimization

valgrind工具

什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐

C语言的动态内存管理函数

redis缓存设计与性能优化

RayMarching realizes volume light rendering
随机推荐
What's a good gift for your girlfriend on the Chinese Valentine's day in 2022? Practical and beautiful gift recommendation
js 变量等于0也等也' '问题
战疫杯--我的账本
SSAO by computer shader (I)
OJ 1089 Spring Festival travel
[C note] data type and storage
AQS之countDownLatch源码分析
准备开始写博客了
Treasure plan TPC system development DAPP construction
OJ 1284 counting problem
@PostConstruct注解及用处示例
江中ACM新生10月26日习题题解
Dynamic planning -- multi-step stair climbing (advanced version of stair climbing)
Battle plague Cup -- my account book
【详解如何一步步实现三子棋】
什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐
Leetcode brush question diary sword finger offer II 048. serialization and deserialization binary tree
[dynamic planning -- the best period for buying and selling stocks series 3]
[c语言]--一步一步实现扫雷小游戏
2022-06-07 responsebodyadvice caused the spring frame problem in swagger