当前位置:网站首页>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 .
边栏推荐
- Idea plug-in backup table
- JMeter login failure, extracting login token, and obtaining token problem solving
- 166. 分数到小数
- 线程常用方法与守护线程
- Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)
- 8. 字符串转换整数 (atoi)
- [TA frost wolf _may - "hundred people plan"] 1.4 introduction to PC mobile phone graphics API
- The problem of integrating Alibaba cloud SMS: non static methods cannot be referenced from the static context
- 高并发下接口幂等性如何保证?
- 409. longest palindrome
猜你喜欢

多次跳槽后,月薪等于老同事的年薪

【TA-霜狼_may-《百人計劃》】2.3 常用函數介紹

The difference between MFC for static libraries and MFC for shared libraries
![[TA frost wolf \u may- hundred people plan] 2.3 introduction to common functions](/img/be/325f78dee744138a865c13d2c20475.png)
[TA frost wolf \u may- hundred people plan] 2.3 introduction to common functions

【TA-霜狼_may-《百人计划》】1.3纹理的秘密
![[TA frost wolf \u may- hundred people plan] 2.4 traditional empirical lighting model](/img/05/85c004e4fbfc8d4984ac04ddb1190b.png)
[TA frost wolf \u may- hundred people plan] 2.4 traditional empirical lighting model

Jenkins自动清理构建历史

基于Unet的环路滤波

【TA-霜狼_may-《百人计划》】1.2.2 矩阵计算

Future of NTF and trends in 2022
随机推荐
Do280 management application deployment --rc
[untitled]
What happens when a function is called before it is declared in C?
How keil displays Chinese annotations (simple with pictures)
187. 重复的DNA序列
创新界,聚势行 | 2022人大金仓“百城巡展”火热开启
[reach out to Party welfare] developer reload system sequence
多次跳槽后,月薪等于老同事的年薪
bootsrap中的栅格系统
205. isomorphic string
PageObject模式解析及案例
SEM of C language_ Tvariable type
242. valid Letter heteronyms
187. repeated DNA sequences
类和对象收尾
214. minimum palindrome string
有效的 @SuppressWarnings 警告名称
171. Excel 表列序号
使用scroll-view实现滑块视图可能遇到的问题及其解决方法
Unexpected token o in JSON at position 1, JSON parsing problem