How to configure the server to quickly run my PHP script?

I have a PHP script that runs in a loop for x times. The code is very minimal and performs checks. Some loops will work for 1 second apart and vary. Some cycles will work with a delay of up to 8 seconds.

How or what can I configure / configure on the server (or instruct the manager of my dedicated server) to reduce the time between cycles to milliseconds (or as quickly as possible), and not from 1 to 8 seconds?

Thank!

Php code

<style type="text/css">
#check { font: Arial, Helvetica, sans-serif; font-size: 12px; margin-bottom: 40px; }
.red { color: #C00; }
.green { color: #060; }
</style>

<?php        date_default_timezone_set('Australia/Brisbane');   $var1 = "variable";     $var2 = 1;      $var3=="no";
                while ($var2 <= 50)     {

                        $sApiUrl = "https://www.apiurl.com/";

                        $aParams = Array(
                                    'uid'     => "user",   
                                    'pw'      => "key",    
                                    'command' => "command",     
                                    'sld'     => "main",        
                                    'tld'     => "ext");         


                        $oCurl = curl_init();
                        curl_setopt($oCurl, CURLOPT_URL, $sApiUrl);
                        curl_setopt($oCurl, CURLOPT_POST, 1);
                        curl_setopt($oCurl, CURLOPT_POSTFIELDS, $aParams);
                        curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
                        $sResponse = curl_exec($oCurl);
                        curl_close($oCurl);


                        $oOutput = new SimpleXmlElement($sResponse);


                        foreach ($oOutput as $v1)
                          {  
                             foreach ($v1 as $v2)
                             { 
                                foreach ($v2 as $v3)
                                {
                                    foreach ($v3 as $v4=>$temp)
                                    {
                                         if($v4=="text")
                                            $var4 = $temp;
                                             if($var4=="true")
                                              {                                         
                                                    $aParams = Array(
                                                    'uid'     => "user",   
                                                    'pw'      => "key",  
                                                    'command' => "command",   
                                                    'sld'     => "main",       
                                                    'tld'     => "ext",
                                                    'dosomething' => "yes");    


                                                    $oCurl = curl_init();
                                                    curl_setopt($oCurl, CURLOPT_URL, $sApiUrl);
                                                    curl_setopt($oCurl, CURLOPT_POST, 1);
                                                    curl_setopt($oCurl, CURLOPT_POSTFIELDS, $aParams);
                                                    curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
                                                    curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false);
                                                    $sResponse = curl_exec($oCurl);
                                                    curl_close($oCurl); 

                                                    $var3=="yes";   
                                              }                           
                                    }
                                }
                             }
                          }         $checktime = date('h:i:s A');                           echo "<div id=\"check\">$checktime, checked $var1<br>";         if ($var4=="true")          echo "<div class=\"green\"> $var4";         else            echo "<div class=\"red\"> $var4";
                if ($var3=="yes")           echo " and yes";    echo "</div></div>";        $var3=="no";    $loops++;   }        ?>

Processor info

Processor # 1 Supplier: GenuineIntel Processor # 1 Name: Intel (R) Xeon (R) CPU E5405 @ 2.00 GHz Processor speed 1: 1995.120 MHz Processor cache size No. 1: 6144

# 2 : GenuineIntel # 2 : Intel (R) Xeon (R) E5405 @2,00 2: 1995.120 β„–2: 6144

β„–3 : GenuineIntel # 3 : Intel (R) Xeon (R) CPU E5405 @2,00 3: 1995.120 β„–3: ​​6144

# 4 : GenuineIntel # 4 : Intel (R) Xeon (R) CPU E5405 @2,00 # 4: 1995.120 # 4: 6144

β„– 5 : GenuineIntel # 5 : Intel (R) Xeon (R) CPU E5405 @2,00 # 5: 1995.120 # 5: 6144

# 6 : GenuineIntel # 6 : Intel (R) Xeon (R) CPU E5405 @2,00 # 6: 1995.120 # 6: 6144

# 7 : GenuineIntel # 7 : Intel (R) Xeon (R) CPU E5405 @2,00 # 7: 1995.120 # 7: 6144

# 8 : GenuineIntel # 8 : Intel (R) Xeon (R) CPU E5405 @2,00 # 8: 1995.120 # 8: 6144

( 0x0 0x0) : 8302344k/9175040k ( 2176k, 80272k, 901k, 228k init, 7466304k highmem)

Linux server.myserver.com 2.6.18-194.17.1.el5PAE # 1 SMP Wed Sep 29 13:31:51 EDT 2010 i686 i686 i386 GNU/Linux

SCSI sda: 1952448512 512- hdwr (999654 ) sda: sda: : 03 00 00 08 SCSI sda: : SCSI- sda: 1952448512 512- hdwr (999654 ) sda: sda: : 03 00 00 08 SCSI sda: : sd 0: 1: 0: 0: scsi sda sd 4: 0: 0: 0: scsi sdb sd 0: 1: 0: 0: scsi generic sg4 0 sd 4: 0: 0: 0: scsi generic sg7 0

         total       used       free     shared    buffers     cached

Mem: 8306672 7887632 419040 0 508076 6496876 -/+ /: 882680 7423992 : 4095992 428 4095564 : 12402664 7888060 4514604

% /DEV/Mapper/VolGroup 00-LogVol00                     898G 200G 653G 24%/ /dev/sda 1 99M 19M 76M 20%/boot 4.0G 0 4.0G 0%/dev/shm /var/tmpMnt 4.0G 161M 3.6G 5%/tmp

-1
2

, , - ? , PHP script .

, Xdebug, script . (, ) .

+1

, , curl_multi * stuff PHP - .

. http://php.net/manual/en/function.curl-multi-init.php

HTTP- . AFAIK curl_multi_ * .

+1

Source: https://habr.com/ru/post/1782868/


All Articles