News for hackers. Stuff that matters.
Re:Moving from PHP to C saved my web startup. by toolate on Friday October 22, 2010 @07:10PM (#1821891)
Why don't you use long polling rather than sending a request a second?

You could even incorporate the timer into a single request.

    do {
        sleep(1);
        $seconds_remaining = fetch_auction_time_from_memcache();
        echo "<script>updateActionTime($seconds_remaining);</script>";
        flush();
    } while ($seconds_remaining > 0);
Re:Moving from PHP to C saved my web startup. by BuckToBid on Friday October 22, 2010 @09:26PM (#1822204)
This is interesting. Would this work if I was on the site for say an hour? Or is there some limit to the amount of time you can send data like this? I have never tried anything like this. What is the overhead like?
Re:Moving from PHP to C saved my web startup. by toolate on Friday October 22, 2010 @10:05PM (#1822289)
I've only used it on smaller projects. Facebook use it on their frontpage for progressive loading (check the source for `<script>big_pipe.onPageletArrive(..);</script>`).

Longer running connections are a little more problematic, but some client side code should be able to handle the connection being closed. You just need to make sure your web server can handle the number of connections your are expecting. Apache is particularly bad for this. Something like nginx should perform better.

Re:Moving from PHP to C saved my web startup. by gcr on Friday October 22, 2010 @09:39PM (#1822233)
Not hard. The client could notice if the connection dies (JQuery has AJAX failure callbacks, for example) and then attempt to reconnect; that's the important thing.
Re:Moving from PHP to C saved my web startup. by wanderr on Saturday October 23, 2010 @12:08AM (#1822600)
I was going to suggest long polling as well. Seems to make way more sense than normal polling for this application.