When using long polling in PHP, e.g.
$start_time = time();
while ((time() - $start_time) < 30) {
if ($db->getNewStuff()->rows > 0) {
$response = "new stuff!";
break;
}
usleep(1000000);
}
echo $response;
How do you evaluate, how "long" you "poll"? In this example, I chose 30 seconds, because... well, I can't even tell why.
What are the impacts when using even longer polls, several minutes or alike? Will Apache crash? Will my application get laggy / stuck / decrease performance?
Furthermore: How long should the process usleep
?
You should really look into using Node and Socket.io. :)