Questions about concurrent curl

I use curl_multi_init and a series of related methods to implement concurrent stress testing of the interface. The curl code is placed on the a server and the tested interface is placed on the b server. The two servers are intranets.
my test code is roughly as follows

$chlist = [];
    foreach($requestList as $k=>$v){// 500
        $chlist[$k]=curl_init();
        curl_setopt($chlist[$k], CURLOPT_URL, $sysConfig["apiUrl"]);// 
        curl_setopt($chlist[$k], CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($chlist[$k], CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($chlist[$k], CURLOPT_HTTPHEADER, array("Accept-Encoding:gzip"));
        curl_setopt($chlist[$k], CURLOPT_ENCODING, "gzip");
        curl_setopt($chlist[$k], CURLOPT_HTTPHEADER, array (
            "Content-Type: application/x-www-form-urlencoded; charset=gbk", 
        ));
        // 
        $reqXml = "<Req funcid="9999"><![CDATA[".parameHandle($v["params"],$apilist[$v["api"]]["paramsType"])."]]></Req>";
        $seKey = getRndString();
        $dateKey = getDateString();
        $strPost = encode($reqXml, $sysConfig["key"], $sysConfig["version"], $sysConfig["chan_code"], $seKey, $dateKey);// 
        curl_setopt ( $chlist[$k], CURLOPT_POSTFIELDS, $strPost );
        curl_setopt($chlist[$k], CURLOPT_TIMEOUT,120);   
    }

    $mh = curl_multi_init();

    foreach($chlist as $k=>$v) {
        curl_multi_add_handle($mh,$v);
    }
    $active = null;
    $start=time();
    var_dump($start);// 
    // 
    do {
        $mrc = curl_multi_exec($mh, $active);
    } while ($mrc == CURLM_CALL_MULTI_PERFORM);

    while ($active && $mrc == CURLM_OK) {
        if (curl_multi_select($mh) != -1) {
            do {
                $mrc = curl_multi_exec($mh, $active);
            } while ($mrc == CURLM_CALL_MULTI_PERFORM);
        }
    }
    $end = time();
    var_dump($end);// 
    var_dump($end - $start);// 

    //4.curl
    foreach($chlist as $val){
        curl_multi_remove_handle($mh, $val);
        $response[] = curl_multi_getcontent($val);
    }
    //5.curl
    curl_multi_close($mh);
    //var_dump($response);
    return $response;

but I doubt whether such a test is accurate. I have seen that when the test program is running, the top, usage of a server is not full, but the result of my test takes at least ten seconds, while the developer of the interface uses apache jmeter to test 500concurrency, only 5 seconds. What is the reason for this?

I tried again. Before I opened the test code, I used the browser to access the code address, but now it is executed on the command line, and the speed is obviously shorter, almost or even a little faster than apache jmeter, so it is the reason why the browser remote access takes up the network speed?

Php
Mar.25,2021

browser access will be a little slower, but it shouldn't be that much slower. It is even more impossible to occupy the speed of the Internet. If you want to know, you can use xhprof to try this

Menu