当前位置:网站首页>How PHP solves the problem of high concurrency
How PHP solves the problem of high concurrency
2022-07-03 11:24:00 【dj1540225203】
- Pessimistic locking , Put the inventory field number Field set to unsigned, When the stock is 0 when , Because fields cannot be negative , Will return false, When high concurrency comes , It may cause the number of connections to run out , The system database crashed
- Use for update , Lock the row of the action
- FIFO, Use Redis fifo , But this kind of turns into the shadow of single thread , If there is not enough memory, it will still be abnormal
- File lock , When file locks are used in key methods , Only after this operation can the lock be released .
- Optimism lock , Add one more version Field to determine whether it has been updated , However, if there is a delay in using master-slave, you should force reading the master database .
- Use redis Of watch
<?php
$redis = new redis();
$result = $redis->connect('127.0.0.1', 6379);
echo $mywatchkey = $redis->get("mywatchkey");
echo " Panic buying !<br/>";
echo " The remaining quantity :".($rob_total-$mywatchkey-1)."<br/>";
echo " User list :<pre>";
var_dump($mywatchlist);
}else{
$redis->hSet("watchkeylist","user_".mt_rand(1, 9999),'meiqiangdao');
echo " Bad luck , Buy again !";exit;
}
}
?>php How to solve the problem of high concurrency - big data - Billion speed
PHP High concurrent programming _ Strive to be an interesting person's blog -CSDN Blog _php Concurrent programming
边栏推荐
- 读书笔记:《心若菩提》 曹德旺
- Internet socket (non) blocking write/read n bytes
- 帝国cms 无缩略图 灵动标签(e:loop)判断有无标题图片(titlepic)的两种写法
- 00后抛弃互联网: 毕业不想进大厂,要去搞最潮Web3
- 在腾讯云容器服务Node上执行 kubectl
- How to become a senior digital IC Design Engineer (1-4) Verilog coding syntax: expression
- Probability theory: application of convolution in calculating moving average
- 数据库增量备份 - DB INCR DB FULL
- Google Earth Engine(GEE)——当我们前后影像来弥补插值效果得时候,没有效果怎么办?
- Expandablelistview that can expand and shrink (imitating the list page of professional selection of Zhilian recruitment)
猜你喜欢

面试题总结(2) IO模型,集合,NIO 原理,缓存穿透,击穿雪崩

FL Studio 20无限试用版水果编曲下载
![[OBS] configFile in ini format of OBS](/img/b2/0b130cee6ea884557a30e4b408f49e.png)
[OBS] configFile in ini format of OBS

11. Provider service registration of Nacos service registration source code analysis

Google Earth engine (GEE) - ghsl global population grid dataset 250 meter resolution

面試題總結(2) IO模型,集合,NIO 原理,緩存穿透,擊穿雪崩

ASP.NET-酒店管理系统

Solve undefined reference to`__ aeabi_ Uidivmod 'and undefined reference to`__ aeabi_ Uidiv 'error

My understanding of testing (summarized by senior testers)

进程与线程
随机推荐
线性表的双链表
使用onvif协议操作设备
JGG专刊征稿:时空组学
How to become a senior digital IC Design Engineer (1-2) Verilog coding syntax: Verilog 1995, 2001, 2005 standards
[VTK] vtkPolydataToImageStencil 源码解读
线性表顺序表综合应用题P18
IIS does not take effect after modifying the configuration information
1. Hal driven development
程序员的创业陷阱:接私活
(2) Base
ASP.NET-酒店管理系统
Software testing e-commerce projects that can be written into your resume, don't you come in and get it?
How to clean up v$rman_ backup_ job_ Details view reports error ora-02030
How can UI automated testing get out of trouble? How to embody the value?
Google Earth Engine(GEE)——当我们前后影像来弥补插值效果得时候,没有效果怎么办?
CSRF
11. Provider service registration of Nacos service registration source code analysis
行业唯一!法大大电子合同上榜36氪硬核科技企业
Incremental database backup - DB incr DB full
Internet Socket (非)阻塞write/read n个字节