I want to the php file output 1 line per second.
see my code first:
<?php
ob_implicit_flush(true);
for ($i = 0; $i < 5; $i++) {
echo "test $i";
sleep(1);
}
?>
OR
<?php
ob_end_clean();
for ($i = 0; $i < 5; $i++) {
echo "test $i";
flush();
sleep(1);
}
?>
Both not work, they output all the content after 5 seconds. NOT 1 second
1 line.
I tried to change nginx.conf
gzip on; AND gzip off;
and it still NOT 1 second 1 line.
and I also tried to change php.ini
output_buffering = 4096
AND
output_buffering = 0
and it still NOT 1 second 1 line.
HOW CAN I FIX IT ?
SOS!!!
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,52531,52531#msg-52531
on 2010-02-09 09:29
on 2010-02-09 17:07
On 02/09/2010 10:29 AM, 21andy wrote: > ?> > ?> > output_buffering = 0 > nginx@nginx.org > http://nginx.org/mailman/listinfo/nginx > Hi, Try ob_end_flush() instead of ob_end_clean(). /gh
on 2010-02-09 17:53
It doesn't matter as I believe NginX buffers fastcgi responses and then sends to the client once the request is completed. V/r Rob Sent from my iPhone On Feb 9, 2010, at 10:06 AM, Georgi Hristozov <georgi@forkbomb.nl>
on 2010-02-11 10:18
21andy wrote:
> I want to the php file output 1 line per second.
I know it's not an answer to your question, but you should re-evaluate
your application architecture. If you need progress report on lengthy
operations you can use separate batch processes, messaging queues,
databases, Ajax, and all sorts of tools.
The reason nginx buffers all output is because, most of the times,
generating the response is a much faster operation than transferring it
to the client. Therefore, by buffering it, nginx frees the backend
worker (the php child process) sooner and the system is able to serve
more requests per unit of time, for a given amount of ram. Which is one
of the main aims of server optimization.
Hope this explains the logic behind it.
Tobia
on 2010-02-15 11:40
Hi, > I want to the php file output 1 line per second. take a look at the fastcgi buffer settings: http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_buffers Cheers, Daniel You wrote: > OR > Both not work, they output all the content after 5 seconds. NOT 1 second 1 line. > > HOW CAN I FIX IT ? > SOS!!! -- http://daniel.hahler.de/
on 2010-02-15 18:35
On Feb 15, 2010, at 4:39 AM, Daniel Hahler wrote: > Hi, > >> I want to the php file output 1 line per second. > > take a look at the fastcgi buffer settings: > http://wiki.nginx.org/NginxHttpFcgiModule#fastcgi_buffers That won't help since if the buffer's are too small then NginX will just buffer it to a tmp file on the disk until the request is completed from the fastcgi process. V/r, Rob
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.