I'm using comet polling in Joomla (PHP) application on shared hosting. I can't use either WebSockets or Node.js, as they might not be available on client's server.
I managed to maintain only one request throughout to reduce the space it will take up in Apache. However it still makes my PC very very slow. In my friend's MacBook even MySQL crashed when my app was running.
I know that PHP and Apache are not the right choice for real-time stuff but I've no choice.
How to use Comet polling without taking up Apache space?
The while loop checks for new data constantly and only return to client when there's new data.
while ($currentmodif == $lastmodif) {
// sleep 10ms to unload the CPU
usleep(10000);
clearstatcache();
$currentmodif = $model->totalNoficationComet($userId);//checks new data
}