php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19485 Buffer output even when output_buffering = Off
Submitted: 2002-09-18 19:32 UTC Modified: 2002-09-19 14:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dnordenberg at users dot sourceforge dot net Assigned:
Status: Closed Package: Output Control
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dnordenberg at users dot sourceforge dot net
New email:
PHP Version: OS:

 

 [2002-09-18 19:32 UTC] dnordenberg at users dot sourceforge dot net
I have set output_buffering to Off and tried something as simple as this:
playmp3.php
<?
readfile("mymp3.mp3");
?>
And the entire output is buffered somewhere. I tried to open the url to the playmp3.php file in winamp and my server hdd LED lights up for about 8 seconds, after that winamp shows it is buffring for about 0.2 sec (LAN connection to the server) and then starts playing. Nothing is outputed from the server while the hdd LED is on and my slow server is terrible busy :( Sometimes the buffering takes more then 10 sec and winamp will time out. I'm using Apache 2.0.40 also.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 11:02 UTC] dnordenberg at users dot sourceforge dot net
Maybe I should add that if I try to listen to a mp3 file directly from a URL to my server without using a script like in my example, winamp will immediately start buffering for about 0,2 sec and then start playing, almost like it was from a local harddive so it is not my server that is that slow (p166, SCSI disks). The mp3 file I'm testing with is 6,6Mb, I don't want to think about how my server will suffer when trying to load a 100Mb mp3 :(
 [2002-09-19 14:25 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Since the file is local and your OS supports mmap, PHP will try mapping the file to memory before sending it out. Which, is what is responsible for the delay, if the file is very big or you have little memory this can take a while, since it may need to use swap to load the file. After the file has been loaded, PHP begin sending the file to the browser.
Apache by default does not use mmap, unless you use mmap_static module, so instead it opens the file and begins  to read it in chunks and immidiately send the read chunks to the browser.

In majority of cases using mmap will be faster then reading data in chunks.
 [2002-09-19 17:43 UTC] dnordenberg at users dot sourceforge dot net
Hi, thanks for your answere. So there is really no way of getting around this? Even if I really don't want to use memory mapping? It would be nice to be able to atleast temporary disable it since it is obviusly not suitable for all contents. I don't want to publish my entire mp3 archive online but I want a interface to it so it is accessible by the ones who should, therefor I want to stream the file trough PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC