ID:               41859
 Updated by:       [EMAIL PROTECTED]
 Reported By:      champs dot name at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Performance problem
 Operating System: Windows Server 2003/IIS6
 PHP Version:      5.2.3
 New Comment:

Did you try to reproduce on *nix ?


Previous Comments:
------------------------------------------------------------------------

[2007-06-30 11:58:31] judas dot iscariote at gmail dot com

You have to choose between readfile() and your code, readfile is
"designed" to be fast AND use few memory.

The best way you have to do this is simple. DO NOT serve files through
PHP :) use mod_secdownload and/or X-SendFile with lighttpd...with apache
use mod_auth_token and/or mod_sendfile to make the webserver itself to
serve the file

------------------------------------------------------------------------

[2007-06-29 22:10:08] champs dot name at gmail dot com

Description:
------------
With a client using a 10Mbps connection, it is possible to saturate the
pipe using print(fread(...)) in chunks of 32K or larger, but the
throughput of fpassthru() and readfile() is consistently ~1/3 of that
speed.  On the other side of the coin, a client with sub-Mbit DSL is not
able to complete 100MB downloads at all, unless readfile/fpassthru() is
used.

This has been tested in different orders, at different times of day,
and on different, non-consecutive days.

Reproduce code:
---------------
if ($file = fopen($path, $mode)) {
        $chunk_size = 32;

        while(!feof($file)) {

                print(fread($file, $chunk_size * 1024));
                if (connection_status() == 0) {
                        flush();
                }
                else {
                        break;
                }
        }

        fclose($file);
}


Expected result:
----------------
Similar throughput if while() block is replaced with "fpassthru($file)"
or "readfile($path)".

Actual result:
--------------
File is served at over 900kB/s with fread(), less than 300kB/s with
fpassthru/readfile().


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41859&edit=1

Reply via email to