当前位置:网站首页>Linux server development, MySQL cache strategy
Linux server development, MySQL cache strategy
2022-07-07 07:55:00 【Tuen Mun pheasant calls me chicken】
Recommend a free open course of zero sound College , Personally, I think the teacher spoke well , Share with you :Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK, Streaming media ,CDN,P2P,K8S,Docker,TCP/IP, coroutines ,DPDK Etc , Learn now
MySql What are the ways to improve read and write performance ?
- Connection pool Blocking io+ Thread pool
- Asynchronous connection Non blocking io
- sql Execute punishment : Carry out in a timely manner + Precompile execution
- Read / write separation
- Cache scheme
Master-slave replication solves the problem of single point of failure .
Reading strategy
- First look at cache There's no data in it , There is a direct return .
- without , Go again MySql Take the data from the library .
- If MySql There are data in it. , The cache to cache
- without , That is, there is no
Final consistency and strong consistency .
Write strategy
- Delete first cache, And then delete MySql
- Delete first cache, Revise MySql. Modify cache directly after improvement , Set expiration time , modify MySql Remove the expiration time .
- Delete first cache, Add again MySql. Modify cache directly after improvement , Set expiration time , modify MySql Remove the expiration time .
Asynchronous operation is compared with synchronous operation , It mainly saves the time of network transmission .
Cache penetration
redis and MySql None of them exist ,redis No data will always be requested MySql, and MySql There is nothing but to return . When a large number of requests accumulate to MySql, Finally, I was overwhelmed .、
Solution :
- Find out MySql non-existent , take redis Set up <key,nil> Set expiration time , The next visit is not visit MySql, It is easy to cause many invalid redis Cache data .
- Set up the bloon filter , The non-existent hotspot data is directly filtered out .
Cache breakdown
redis No, ,MySql There's data . When there are a large number of concurrent requests , Request to pile up MySql Too big . One of them Key A lot of requests .
- Lock , Operate with lock , Sleep without lock .
- Will be a lot hot key Set not to expire .
Cache avalanche
redis Downtime , All data are empty , Cause collapse MySql. Multiple Key A lot of advice .
- Highly available cluster solutions , Like sentinel mode ,cluster Pattern .
- Set the random period value or other mechanism to stagger the expiration time .
- redis Turn on persistence .
边栏推荐
猜你喜欢
[mathematical notes] radian
2022年茶艺师(中级)考试试题及模拟考试
[SUCTF 2019]Game
测试周期被压缩?教你9个方法去应对
今日现货白银操作建议
2022 recurrent training question bank and answers of refrigeration and air conditioning equipment operation
【p2p】本地抓包
Most elements
Linux server development, SQL statements, indexes, views, stored procedures, triggers
[webrtc] m98 Screen and Window Collection
随机推荐
2022-07-06:以下go语言代码是否会panic?A:会;B:不会。 package main import “C“ func main() { var ch chan struct
Six methods of flattening arrays with JS
Detailed explanation of Kalman filter for motion state estimation
[mathematical notes] radian
这5个摸鱼神器太火了!程序员:知道了快删!
面试结束后,被面试官在朋友圈吐槽了......
2022制冷与空调设备运行操作复训题库及答案
Common method signatures and meanings of Iterable, collection and list
What are the positions of communication equipment manufacturers?
Button wizard script learning - about tmall grabbing red envelopes
CentOS7下安装PostgreSQL11数据库
The configuration that needs to be modified when switching between high and low versions of MySQL 5-8 (take aicode as an example here)
微博发布案例
Pytorch parameter initialization
2022年全国最新消防设施操作员(初级消防设施操作员)模拟题及答案
Info | webrtc M97 update
[webrtc] M98 screen and window acquisition
Leanote private cloud note building
Resource create package method
芯片资料 网站 易特创芯