<?php
while (true) {
    runParalel(10);
}


function runParalel($n) {
    // create both cURL resources
    for ($i = 1; $i < $n; $i++) {
        ${'$ch' . $i} = curl_init();
        
        // set URL and other appropriate options
        curl_setopt(${'$ch' . $i}, CURLOPT_URL, "http://127.0.0.1/galera-test/galera-stability.php");
        curl_setopt(${'$ch' . $i}, CURLOPT_HEADER, 0);
    }

    //create the multiple cURL handle
    $mh = curl_multi_init();
    
    //add the two handles
    for ($i = 1; $i < $n; $i++) {
        curl_multi_add_handle($mh, ${'$ch' . $i});
        
    }
    
    //execute the multi handle
    do {
        $status = curl_multi_exec($mh, $active);
        if ($active) {
            curl_multi_select($mh);
        }
    } while ($active && $status == CURLM_OK);
    
    //close the handles
    for ($i = 1; $i < $n; $i++) {
        curl_multi_remove_handle($mh, ${'$ch' . $i});
    }
    curl_multi_close($mh);    
}
?>