URGENT - PHP - Why in the world don't the flush() and usleep() functions work here?

software development


I recently signed up with Dreamhost and everything has been pretty good so far. I did, however, come across an error with one of my PHP scripts while running it on their servers. I’ve opted to get a VPS through Dreamhost and it’s a shame that I’ll have to cancel it if they can’t get this resolved. I know they’ve tried everything through support but at this point it’s turning into a circle with the last conclusion of being ‘check the forum’. The forum, in my attempts to search similar users with the same problem, weren’t promising. A lot of them are left with the final post as “still not being resolved”. I hope that’s not the case here.

[size=medium]The Problem: [/size]
I program in PHP and need a script to gently push out the buffer to a users page. I use two different functions to do this: ‘usleep’ and ‘flush’. If I’ve lost you then just understand that these are very common features with the PHP scripting language.

[size=medium]This is What I Need: [/size]

…you’ll notice how the buffer is gently placed out according to very common php commands using ‘flush’ and ‘usleep’.

[size=medium]This is what I get:[/size]

…the page waits until everything is loaded before returning the buffer to the user.

The only somewhat resolvable solution here (based on a search of old forum responses) is to disable gzip. Dreamhost support has assured me that it’s been disabled. However, at this point, I don’t think they can solve this issue.

[size=medium]ANY help would be greatly appreciate. [/size]

[size=medium]ATTN: Dreamhost Support and Staff.[/size] The sort of problem with a delay is very common in PHP. I sure wasn’t the first with this issue and I know I won’t be the last. Perhaps someone in the support group could take this a step higher to a professional behind the servers to have a look? Unfortunately, this is an absolute for script and although I love your service so far I’ll have to look for another provider (don’t make me do that!!!).



12 hours later - no reply from support and no response to this thread (after almost 300 views) my solution was to find another hosting provider. My advice to DreamHost is to get some more technical staff on your side to deal with issues like these. I can see, browsing through threads here, I’m not the only one that was left hanging.


That kind of effects are better achieved using JavaScript, IMHO.


^ Agreed.

flush()ing data via PHP was always more a gimmick than a “common” function to use. It would even be better to use session flags and script reloads with case() stepping than to rely on such an inept function. If something goes awry during that demo then Apache is left sitting there with an unclosed connection doing nothing. Hardly graceful. And any program in any language that uses any form of a sleep()ing unless it’s specifically trying to not hog cycles is, well, just doing it wrong.

My advice to anyone relying on flush() is to rethink their methodology.