Mysql bug test, tested for high concurrency
This test is a local apache test
D:\WAMP\Apache\bin\ab.exe -c 200 -n 200 www.php1100.com/mysql.php (This URL is your own test URL, the code inside is as follows)
error_reporting(0); echo '<pre class="brush:php;toolbar:false">'; mysql_connect('127.0.0.1','root','root'); mysql_select_db('jsshop'); $rel=mysql_query('select id from gg'); $id=mysql_result($rel,0,0); //求得下面表内的第一个数据 if($id>0){ $id--; //减一运算 mysql_query('update gg set id='.$id); //499 }
//The table is as shown in the picture
So mysql cannot be used when performing high concurrency of mysql.
Solution,
①Don’t use mysql, use redis. When the user comes in, first save it in the redis linked list, store the user’s id in the linked list, and then the activity ends
②Cut out as many prizes as you want from the linked list. Prizes are distributed and orders are usually grabbed concurrently. The winning list is announced after a few minutes.
The above is the method for this article. Thank you. focus on.
【Related Recommendations】
1. Special Recommendation:"php Programmer Toolbox" V0.1 version Download
2. Free mysql online video tutorial
3. Those things about database design
The above is the detailed content of Mysql bug testing--testing for high concurrency. For more information, please follow other related articles on the PHP Chinese website!