ID:               41859
 User updated by:  champs dot name at gmail dot com
-Summary:          Low throughput with readfile/fpassthru
 Reported By:      champs dot name at gmail dot com
-Status:           Feedback
+Status:           Open
 Bug Type:         Performance problem
 Operating System: Windows Server 2003/IIS6
 PHP Version:      5.2.3
 New Comment:

This does not appear to be a problem with Apache 2 + PHP5 + Linux,
performance numbers are within 5% of eachother.

While I cannot test the Apache + Win32 combination, I can look at the
PHP source to say that it does not appear to be something in the
ISAPI-specific code, although it may have something to do with the
affected code's interaction with IIS.


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

[2007-07-03 06:54:54] [EMAIL PROTECTED]

Did you try to reproduce on *nix ?

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

[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