Site malicious concurrent attacks, the first step to solve the problem, their first simulation concurrency, test
Note: Session login state, we need to set the cookie API login state, we generally need to set Bearer Token 1. Postman Bench - Error AB(Apache Bench) - Postman Bench - Error AB(Apache Bench) Ab (Apache Bench) command explanation and pressure test simulation JMeter - Apache at https://blog.csdn.net/jiajiren11/article/details/79486967 JMeter is developed based on Java Apache organization stress test tool reference: use JMeter to conduct stress tests https://www.cnblogs.com/stulzq/p/8971531.html other tools, no. Reference: 10 mainstream pressure test tool https://blog.csdn.net/langzitianya/article/details/81479422 nine Web server performance testing tools https://blog.csdn.net/qq_33440246/article/details/80591070 2. 1> Use guzzlehttp \Client; use GuzzleHttp\Promise; use Psr\Http\Message\ResponseInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\ServerException; / * * * hair red envelope simulation - asynchronous concurrent * / public function mockSendRedPacketConcurrent ($token) {$client = new client ([' base_uri '= > 'http://xxx/api/', ]); $promises = []; for($i = 0; $i < 20; $i++){ $promise = $client->postAsync('red/sent', [ 'headers' => [ 'Accept' => 'application/json', HTTP: // http_forwarded-For => @address_forwarded-for (); HTTP: // http_forwarded-for (); HTTP: // http_forwarded-for (); 'query' = > [' red_money '= > 100,' red_type '= > 1,' red_group '= > 184,' red_num '= > 1,' red_title '= >' kung hei fat choi,],]); $promises[] = $promise; } $results = Promise\unwrap($promises); foreach($results as $result){ $body = $result->getBody(); $content = $body->getContents(); dump($content); }} 2 > use curl concurrent requests https://www.cnblogs.com/52fhy/p/8908315.html https://www.oschina.net/question/54100_58279 / * * * simulation hair red envelopes Public function mockSendRedPacketCurl() {$token = ""; $urls = []; for($i = 0; $i < 600; $i++){ $urls[] = 'http://xxx/api/red/sent'; } $responses = $this->rolling_curl($urls, $token, 30); dd($responses); $queue = curl_multi_init(); $queue = curl_multi_init(); $queue = curl_multi_init(); $map = array(); foreach ($urls as $i => $url) { $ch = curl_init(); $header = ['Accept' => 'application/json', / / to simulate different virtual IP 'X - Forwarded - For' = > '168.1.1.'. $I,]; $params = [ 'red_money' => 1, 'red_type' => 2, 'red_group' => '201910270025455db473899d72f', 'red_num' => 1, 'red_title' => 'concurrent test ',]; // $params = [ // 'red_money' => 100, // 'red_type' => 1, // 'red_group' => 184, // 'red_num' => 1, // 'red_title' => 'gong xi fa fa ', //]; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_NOSIGNAL, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_multi_add_handle($queue, $ch); $map[(string) $ch] = $url; } $responses = array(); do { while (($code = curl_multi_exec($queue, $active)) == CURLM_CALL_MULTI_PERFORM) ; if ($code ! = CURLM_OK) { break; } // a request was just completed -- find out which one while ($done = curl_multi_info_read($queue)) { // get the info and content returned on the request $info = curl_getinfo($done['handle']); $error = curl_error($done['handle']); $content = curl_multi_getcontent($done['handle']); // $results = callback(curl_multi_getcontent($done['handle']), $delay); // $responses[$map[(string) $done['handle']]] = compact('info', 'error', 'results'); $responses[] = [ 'info' => $info, 'error' => $error, 'content' => $content, ]; // remove the curl handle that just completed curl_multi_remove_handle($queue, $done['handle']); curl_close($done['handle']); } // Block for data in / output; Error handling is done by curl_multi_exec if ($active > 0) {curl_multi_select($queue, 0.5); } } while ($active); curl_multi_close($queue); return $responses; } Reference article: Analog IP can be https://blog.csdn.net/intel80586/article/details/8906779 but laravel IP () like detection more accurate use guzzlehttp to implement concurrent requests: https://segmentfault.com/q/1010000007683839 use guzzle send an asynchronous request to return to the promise of call then method won't be executed immediately, Curl curl curl curl curl curl curl curl curl curl curl https://www.cnblogs.com/52fhy/p/8908315.html https://www.oschina.net/question/54100_58279Copy the code