Answer the question
In order to leave comments, you need to log in
Possible parallel execution of php?
task
1) get the time of the previous request
2) store the start time of the current request
3) execute the request (2-10 seconds download via http)
$id = 0
$time = $this->cache->get('vk_obj_start_time'.$id);
echo '<br>loaded_time'.$time. ' '. date('d.m.Y H:i:s',$time);
$parameters = array(
'q' => $this->search_word[$id],
'count' => 100,
'start_time'=> $time
);
echo '<br>now '.time();
$this->cache->save('vk_obj_start_time'.$id, time(), 30000);
return file_get_contents($url);;
Answer the question
In order to leave comments, you need to log in
solution: requests to the script were made through google chrome (browser preloading)
localhost/cron/vk/load_real/2
localhost/cron/vk/load_real/3
localhost/cron/vk/load_real/4
when you manually change the id, chrome loads the page preview again before the transition.
that is:
1) in the address bar was localhost/cron/vk/load_real/2
2) delete 2 (press backspace) localhost/cron/vk/load_real
3) write 3 (do not press enter yet) localhost/cron/vk/load_real /3
and chrome infection has already loaded the page localhost/cron/vk/load_real/3
4) press enter (to get the page localhost/cron/vk/load_real/3)
As a result, I get a downed time counter. the script is processed sequentially as required. and as a result I see the page time () + 1 and a false feeling of parallel execution is created.
Perhaps this library will be useful:
ko-process
If you need exactly parallel execution
I advise you to add verbose logging to the file in several places in your code. Log microtime, process id, current request ID and variable values. This will help you figure out what's going on.
PS The title of the question is extremely unfortunate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question