Home  >  Article  >  Database  >  Mysql bug testing--testing for high concurrency

Mysql bug testing--testing for high concurrency

零下一度
零下一度Original
2017-05-13 16:22:371441browse

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 &#39;<pre class="brush:php;toolbar:false">&#39;;
mysql_connect(&#39;127.0.0.1&#39;,&#39;root&#39;,&#39;root&#39;);
mysql_select_db(&#39;jsshop&#39;);
$rel=mysql_query(&#39;select id from gg&#39;);
$id=mysql_result($rel,0,0);
   //求得下面表内的第一个数据
if($id>0){
    $id--;
       //减一运算
    mysql_query(&#39;update gg set id=&#39;.$id);
//499
}

//The table is as shown in the picture

Mysql bug testing--testing for high concurrency

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn