خرید بک لینک

Vote count: 0

I have following instances

  • mysql : 1 instance (8gb RAM)
  • nginx : 4 instances

I am assigning jobs to 4 nginx instances from mysql instance using curl POST request. In this case mysql cpu usage is got increased. I dont want any cpu load to mysql. Mysql should not wait for response from nginxes.

Mysql Script to assign jobs :

$query =  "SELECT id from tablename is_active = '1'";
$result = mysql_query($query);
$total_jobs = mysql_num_rows($result); 
if($total_jobs > 0)
{
    $counter = 0;
    while ($row = mysql_fetch_array($result)) {

        // Assign next job 
        // Update job_last_pulled_at_for_processing for picked ids
        $now = date("Y-m-d H:i:s");

        $job_id_url = urlencode($row['id']);
        $passwd_comm = urlencode(base64_encode("noteasytouse!3333"));
        $data_part="job_id=".$job_id_url."&passwd_comm=".$passwd_comm;

        $ssh_cmd ="curl -k POST --silent --max-time 3 --data '".$data_part."' http://".$nginx_instance.":8080/admin-alert.php > /dev/null &";
        echo "nExecuting => CURLn";
        exec($ssh_cmd);

        $counter++;
        sleep(5);
        if($counter>=12)  {
            GOTO ENDCASE; // If more 12 jobs every min then all of them will not get calculated every min.
        }
    } 
} else {
    echo "nNo Job Eligible to assign";
}

Nginx script to execute job:

$input_data = $_POST;
$job_id = urldecode($input_data['job_id']);
$passwd_post = base64_decode(urldecode($input_data['passwd_comm']));

if($passwd_post != "noteasytouse!3333"){
        echo " Wrong Params "; exit;
}

if(!empty($job_id)) {
        exec("php /var/www/cron_files/update_master_value_cron.php ".$job_id." > /dev/null & "); 
}
echo " Completed "; exit;

If I send wrong password (noteasytouse!1111) from CURL request mysql cpu not increasing. But for correct password ie. to complete jobs at nginx, then Mysql cpu increases to 100%.

Why Mysql cpu increasing if jobs executed by nginxes ?

asked 53 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 15 مرداد 1395 ساعت: 14:38

صفحه بندی