I was implementing the server-push content using comet to the client browser.
There should be updates when mysql got insert then something will happen to client, so I’m currently doing by PHP like this:
PHP
while (check database if update is there)
{
usleep(10000);
// do write json
}
It actually working, but what happening to me is my hosting(shared) run out of resource even when I just test with 5 simultaneous clients.
CPU is 40% loading at this moment and cause account disable.
So please someone advise any idea how to trigger php to send out the new update only without looping check.
I think your problem is that you have a slight error regarding
usleep. The parameter should be:Your script currently halts for 0.01 seconds instead of 10 seconds, which, I assume, is not what you wanted.
use:
or: