当前位置:网站首页>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 .
边栏推荐
- 多次跳槽后,月薪等于老同事的年薪
- [TA frost wolf \u may- hundred talents plan] 1.2.2 matrix calculation
- MFC窗口滚动条用法
- [ta - Frost Wolf May - 100 people plan] 2.3 Introduction aux fonctions communes
- Class and object finalization
- 【TA-霜狼_may-《百人计划》】1.2.3 MVP矩阵运算
- 使用selenium自动化测试工具爬取高考相关院校专业招生分数线及排名情况
- 10. 正则表达式匹配
- 166. fractions to decimals
- 使用scroll-view实现滑块视图可能遇到的问题及其解决方法
猜你喜欢

Network metering - application layer

The programmer's girlfriend gave me a fatigue driving test
![Online public network security case nanny level tutorial [reaching out for Party welfare]](/img/66/d9c848a7888e547b7cb28d84aabc24.png)
Online public network security case nanny level tutorial [reaching out for Party welfare]
![[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

线程常用方法与守护线程

Access denied for user ‘ODBC‘@‘localhost‘ (using password: NO)

JMeter login failure, extracting login token, and obtaining token problem solving

Quickly filter data such as clock in time and date: Excel filter to find whether a certain time point is within a certain time period

Valentine's Day is nothing.

Libevent Library Learning
随机推荐
[EI conference] the Third International Conference on nanomaterials and nanotechnology in 2022 (nanomt 2022)
使用scroll-view实现滑块视图可能遇到的问题及其解决方法
Qt开发经验小技巧226-230
【TA-霜狼_may-《百人计划》】2.2 模型与材质空间
Spock单元测试框架介绍及在美团优选的实践___第一章
LeetCode 1828. Count the number of points in a circle
283.移动零
NFT: utilisez EIP - 2981 pour commencer un voyage de redevances NFT
Appium fundamentals of automated testing - basic principles of appium
Idea plug-in backup table
Grid system in bootstrap
How keil displays Chinese annotations (simple with pictures)
MFC window scroll bar usage
使用selenium自动化测试工具爬取高考相关院校专业招生分数线及排名情况
Do280 management application deployment --rc
Valentine's Day is nothing.
Jeecgboot output log, how to use @slf4j
431. 将 N 叉树编码为二叉树 DFS
25.K个一组翻转链表
Huawei simulator ENSP - hcip - Hybrid Experiment 2