PDA

View Full Version : PHP output buffering & Gzip


buster
Sat 25th May '02, 2:39pm
I had some problems getting Gzip to work after a recent server change.

Red Hat 7.3, PHP 4.12, Apache 1.23-11, My SQL 3.23-49, dual p3 -550, 1 gig ram.

The server was not in any way heavily loaded (have two forums hosted on vBulletin 2.25 with average 15 users & one vBB2 forum with average 10 users atr any given time + some regular web sites & a bit of FTP on the server.

95% of the traffic is the two forums.

Its running on a dedicated 512kbit line (duplex).

Anyway several users were complaining page load was significantly slower. I turned on gzip in the forum and tried to install php accelerator.

php accelerator however killed the web server (not sure why, from what I can see I followed procedure exactly, but thats another point anyway). In the process of trying to sort it all out I ended up removing php accelerator installing mod gzip and disabling the forums own gzip option. Still slow.

Then I from checking around zeroed in on the php.ini settings. To be honest I am not 100% if it was me that disabled php out buffering in the process of trying to make the accelerator run or if it was so by default - anyway once turned on it zip started zipping & the forum speeded up remarkably. Instantly noticeable.

I had also installed Eva2000's recommended my.conf which I can see helps on query time but zip was the big one.

Afterwards I installed zend optimizer which also seems to help though not in anyway revolutionary as Gzip.

The reason I wanted mod_gzip rather than Vbb's gzip option is that mod_gzip is site wide not only for Vbulletin.

Anyway here comes my questions:

1) Am I correct in my assumption that php output buffering must be on for zip to work and that it is default off (at least the generic php.ini script that comes with zend optimizer also has it off) ?

1a) Is there any advantage in increasing output buffering beyond the 4k it defaults to when on?

2) I had to rely on user reports to zero in on where the troubles lay (think back from described symtom to possible cause). Are there some tools someone can recommend to test page creation time.

3) Any experience on what the time needs to be for users to feel they have a pretty much instant page? (Like 15 secs will be slow but whether its a quarter of a second or one and a half might not matter so much).

4) The load stats in top - what is the point where onwe should start worrying about server load?

5) Any other recommendations?

eva2000
Sun 26th May '02, 4:10am
php output buffering needs to be turned off /disabled if you use gzip or mod_gzip

you can only use phpaccelerator or zend optimiser exclusively, you can't use both at the same time

try this post your phpinfo page url

1. php output buffering = off
2. php accelerator 1.3.1 installed for the correct php and glibc version of your PHP and server
3. remove zend optimiser
4. turn on vB's gzip set to level 1 and no higher (what was it set at before ?)

buster
Sun 26th May '02, 12:03pm
I see - I am a bit surprised as mod_gzip seems to be working well with the output buffer on which it was not before (may be some other change made at the same time though).

phpinfo can be found at www.civgaming.net/phpinfo.php (for a while I will leave it there).

Just want to verify some points - as I am running mod_gzip (and prefer this to vBulletins Gzip option as it enables me to compress all the sites on the server-9 would turning on Gzip in vBulletin not just introduce additional overhead with little extra gain?

I used to have it at 1 (on the old setup)

Second - I only installed zend optimizer as I could not get php accelerator to work and only after giving up on php accelerator - so the problem is not due to using them at the same timre. I did not try to run them at the same time.

The problem is possibly that there is no version that exactly matches (I use php 4.12 & glibc 2.2.5). I tried the accelerator for php 4.11 & glicb2.2.4 but the site instantly died. The I tried some other combinations (php 4.07 glibc 2.2, glibc 2.2.4 php 4.2) all same result the moment I enable php accelerator & restart apache I instantly get "page not found errors" no matter what I ask for.

I tried installing it both before & after installing mod_gzip and both with and without the output buffer. So I don't reckon that is the problem either. Unless some new idea of why it fails - I will wait for a new version.

I would very much like to use it and happily ditch the zend optimizer for php accelerator but I reckon zend optimizer is still better than nothing. Zends own is too expensive & the other I found, ABC, had so little documention it seemed somewhat adventurous to try.

eva2000
Sun 26th May '02, 12:10pm
well zend optimiser is not the same as PHP Accelerator - PHPA does alot more than optimiser does

you don't need vb gzip enabled nor do you need output buffering on if you use mod_gzip - if you turn those on it's like wasting extra resources

if you read PHPA site PHP for 4.07RC3 is the one you use for php 4.1.1 and 4.1.2 ;)


Please note that downloads for 4.0.7RC3, 4.1.1 and 4.1.2 will work with any of those PHP versions. So if you're running PHP 4.1.2 but there's only a PHPA build for PHP 4.1.1 then just use that as it will be compatible.

buster
Sun 26th May '02, 12:23pm
Indded your right - I turned off output buffering & mod_gzip still works. Must have been some other coincidence.

Will give php accelerator another shot

eva2000
Sun 26th May '02, 12:44pm
Originally posted by buster
Indded your right - I turned off output buffering & mod_gzip still works. Must have been some other coincidence.

Will give php accelerator another shot of course i am right :)

i wrote up a phpaccelerator install guide at http://i4net.tv/marticle/get.php?action=getarticle&articleid=31 :)

buster
Sun 26th May '02, 1:00pm
Great it works - (installed the php accelerator 1.3.0 for php 4.0.7rc3 & glibc 2.2.4) now I am getting all mystified why I got the problem in the first place. :o

Possibly some typo when doing the php.ini settings originally combined with me first trying to use a precompiled version of mod_gzip that did not fit my server & then getting all sidetracked and drawing wrong conclusions about what was going on.

Anyway thanks a lot.

One last question - I remember some people having posted data like "page creation time = blabla".

How does one get this information?

eva2000
Sun 26th May '02, 1:12pm
i hope you meant phpa 1.3.1 and not 1.3.0 since 1.3.0 has a few issues and is slower than 1.2p4

buster
Sun 26th May '02, 1:18pm
On the download page there is only 1.3.0 & 1.3.1 (a pre release) for linux, so I took the 1.3.0.

Will try the 1.3.1 pre3.

eva2000
Sun 26th May '02, 1:25pm
Originally posted by buster
On the download page there is only 1.3.0 & 1.3.1 (a pre release) for linux, so I took the 1.3.0.

Will try the 1.3.1 pre3. you're right.. hmm i swear it was listed as 1.3.1 and not 1.3.1 pre3 *** scratches head ***