0

The objective of the following scripts are to send an Asynchronous PHP-Curl Request to a Server. I've been using the "fire and forget" technique in where a CURL request is sent to the server itself with a TIMEOUT_MS set to 100. The mainProcess.php will proceed as is with a delay of only 100 milliseconds and the sendMe.php will send a Curl to server C without delaying the execution of the mainProcess.php script.

I used another script (benchMarking.php) to print the execution time of firing the overall procedures.

benchMarking.php

$time_start = microtime(true);
PHP-Curl Post to Server B (mainProcess.php)
$time_end = microtime(true);
$time = $time_end - $time_start;
echo $time;

Initially, the $time is low. But as I continuously fire the benchMarking.php the $time increases. Resetting the Apache Server (Server B) is the only option in order to decrease the $time variable again. Hence, it must have something to do with the resources or connection handling of PHP. Any suggestions or workaround will be appreciated with regards to the problem.

Illustration of the Procedures. enter image description here

References for the Fire and Forget Techniques:

http://www.tsartsaris.gr/how-to-make-asynchronous-post-with-php

http://www.paul-norman.co.uk/2009/06/asynchronous-curl-requests

tangol100
  • 21
  • 4
  • What do you mean by continuously firing? One request per second or as fast as it can for a minute or so? – Ja͢ck Mar 17 '15 at 05:59
  • One request per second. – tangol100 Mar 17 '15 at 06:16
  • It *seems* that the processes on B keep accumulating. – Ja͢ck Mar 17 '15 at 06:17
  • yup seems like that. Currently im working on a workaround in this situation. Alternative: http://stackoverflow.com/questions/14587514/php-fire-and-forget-post-request – tangol100 Mar 17 '15 at 06:24
  • I believe that if you fire the next cURL before the 100ms end period then you will have a problem as processes are getting in the queue. Fire and forget does not mean that you can have as many as you want simultaneously. Add a sleep of 99 ms before the next fire-and-forget curl call and monitor the results. If you are after multithreading fire-and-forgets for several calls then you should post some code as well. – SotirisTsartsaris Mar 18 '15 at 19:36

0 Answers0