当前位置:网站首页>Redis (VII) optimization suggestions
Redis (VII) optimization suggestions
2022-07-01 04:00:00 【oneirocritic 】
List of articles
1、 What to do if the cache is inconsistent with the database
Assume that the master-slave structure is adopted 、 Read write separate database .
If a thread A Delete cached data first , Then write the data to the main library , This is the time , The synchronization between master and slave is not complete , Threads B Failed to read data from cache , Read old data from the library , Then update to the cache , This is the time , What's in the cache is the old data .
The reason for this inconsistency is : Data inconsistency between master and slave databases , After adding the cache , The time of inconsistency between master and slave has been lengthened .
Handling ideas : After the data is updated from the library , Update the data in the cache at the same time , That is, when the data is updated from the database , Issue delete to cache , Discard the old data written during this period .
2、 How to solve the inconsistency between master and slave databases
Scene description : For master-slave Libraries , Read / write separation , If there is a time difference between master and slave update synchronization , It will lead to inconsistency between the master and slave databases .
Handling ideas :
- 1、 Ignore this data inconsistency , In the business with low data consistency requirements , Real time consistency is not necessary .
- 2、 Forced read main database , Use a highly available main library , Read and write the database in the main database , Add a cache , Improve the performance of data reading .
- 3、 Read the main library selectively , Add a cache , Used to record data that must be read from the main library , Specify which library to use 、 Which watch 、 Which primary key is cached key, Set the cache expiration time to synchronize the master and slave libraries . If there is this data in the cache , Read the main library directly , If there is no primary key in the cache , Read from the library .
3、Redis Common performance problems and solutions
1、Master It's better not to do persistence work , Such as RDB Memory snapshot and AOF Log files .
2、 If the data is important , Some Slave Turn on AOF Backup , The policy is set to synchronize once per second .
3、 Try to avoid adding slave libraries to the main library with high pressure .
4、 Master-slave replication should not adopt mesh structure , Try to be linear ,Master <— Slave1 <— Slave2 wait .
边栏推荐
- Blueprism registration, download and install -rpa Chapter 1
- 168. excel table column name
- mysql 函数 变量 存储过程
- Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
- 谷粒学院微信扫码登录过程记录以及bug解决
- 【EI会议】2022年国际土木与海洋工程联合会议(JCCME 2022)
- LeetCode 1399. Count the maximum number of groups
- 采购数智化爆发在即,支出宝'3+2'体系助力企业打造核心竞争优势
- Spock单元测试框架介绍及在美团优选的实践___第一章
- Libevent Library Learning
猜你喜欢

整合阿里云短信的问题:无法从静态上下文中引用非静态方法

【TA-霜狼_may-《百人计划》】2.3 常用函数介绍

Blueprism registration, download and install -rpa Chapter 1

NFT: utilisez EIP - 2981 pour commencer un voyage de redevances NFT

TS type gymnastics: illustrating a complex advanced type

“目标检测“+“视觉理解“实现对输入图像的理解
![[ta - Frost Wolf May - 100 people plan] 1.2.1 base vectorielle](/img/94/99090ea91082a385968e071ef3766c.png)
[ta - Frost Wolf May - 100 people plan] 1.2.1 base vectorielle

Error: plug ins declaring extensions or extension points must set the singleton directive to true

The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context

Valentine's Day is nothing.
随机推荐
不同性能测试工具的并发模式
高并发下接口幂等性如何保证?
【TA-霜狼_may-《百人计划》】2.1 色彩空间
[TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation
242. 有效的字母异位词
Volley parsing data shows networking failure
[EI conference] 2022 international joint civil and Offshore Engineering Conference (jccme 2022)
What does ft mean in the data book table
392. 判断子序列
10. regular expression matching
6. Z 字形变换
171. Excel 表列序号
【历史上的今天】6 月 30 日:冯·诺依曼发表第一份草案;九十年代末的半导体大战;CBS 收购 CNET
[TA frost wolf \u may - "hundred people plan"] 2.1 color space
241. 为运算表达式设计优先级
采购数智化爆发在即,支出宝'3+2'体系助力企业打造核心竞争优势
The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context
What happens when a function is called before it is declared in C?
30. Concatenate substrings of all words
NFT:使用 EIP-2981 开启 NFT 版税之旅