Poor HTTP performance - time to first byte

10 posts / 0 new
Last post
#1 Fri, 11/26/2010 - 09:09
konstant

Poor HTTP performance - time to first byte

Hi everyone, I've been running Virtualmin on 10.04 LTS for a couple of weeks now and have been pleasantly surprised by its stability and functionality. I hope to move all my sites over to Virtualmin in the near future.

However, I've noticed that pages feel a little sluggish. Having done some testing with waterfall graphs etc the cuplrit appears to be the time between establishing a connection and the first byte being downloaded.

I've tested pages on my Virtualmin VPS and my older, inferior VPS and am consistently getting better performance on the old one.

Could the solution to this be simply some tweaking of Apache settings? Is there a possibility it could be a DNS issue? The page being loaded is being handled by PHP, but is very lightweight and doesn't have any queries etc.

The green bars are the things I'm talking about. Advice would be greatly appreciated.

http://i53.tinypic.com/s2gy1k.png

Fri, 11/26/2010 - 14:58
Locutus

Oh yeah, performance comparisons and benchmarking is a whole topic of its own. :) It depends on many factors. First, to rule out network connectivity issues in general, I'd test the ping response times and transfer speed between the server and client.

Does the old VPS have the same hardware specs as the new one (CPU, RAM, disk performance, 32 vs. 64 bit)?

Then test the retrieving that web page from different sources if possible. And test both plain HTTP and PHP pages to have a comparison.

Next step, check the CPU load and memory usage using atop while queries are made. In which mode are you calling PHP? Apache module, CGI or FastCGI? Are you using a PHP cache?

What is the domain in question?

Sat, 11/27/2010 - 20:09
konstant

Connectivity looks ok, no packet loss and speeds are fine. Both are VPSs hosted in UK datacentres. I've done tests at different times of day and nothing seems to change

The new VPS is a 512MB Linode, and is superior with regards to CPU, RAM, IO and is Xen vs OpenVZ. Both are 32bit, but the Linode (running Virtualmin) is on 10.04LTS and my other VPS is CentOS 5.5.

Load is all over the place on the new server. I believe this is normal given the the cronjobs that Virtualmin runs. However when it's not running a cronjob load is 0.00 or 0.01 so I think that's ok.

PHP is not the culprit. I've tested with plain HTML pages. Perhaps Apache is not allowing enough connections to open with the client? Should this be a problem with default settings?

http://i54.tinypic.com/4jqs8p.png

I'm not a performance nazi by any means, but am concerned that a fresh install of Virtualmin is so much slower than a crumbling Plesk VPS hosted on inferior hardware with inferior connectivity.

Sat, 11/27/2010 - 09:01
andreychek

Howdy,

Yeah, I sometimes tweak some of the cronjobs when running on a VPS. The bandwidth checks running every hour can really cause the load to spike on that sort of system.

What if your bandwidth checks ran, say, once a day rather than once an hour? If someone were to surpass their bandwidth limit, that'd just mean that they'd have to wait a few more hours before Virtualmin notices.

Similar with status collection... none of those are hugely important to have running as frequently as they do.

It's "nice", it keeps your graphs and statistics all up to date, but I'd vote that your performance is more important than all that :-)

If you go into System Settings -> Virtualmin Configuration -> Status Collection, you can set "Interval between status collection job runs" to something much higher than the default of "30". This changes your status collection interval, which is what "collectinfo.pl" is.

For bandwidth monitoring, you can go into System Settings -> Bandwidth Monitoring, and set "Hours between collection" to something higher as well. It defaults to once an hour.

-Eric

Sat, 11/27/2010 - 13:21
konstant

Thanks Eric. Bandwidth monitoring was already disabled and status updates have been set to every hour. The default value is 5 minutes!

To give an idea of how bad the performance of my site is, have a look at these two graphs. It's a comparison of my Old Plesk VPS and my new Linode. They are both loading the same content.

CentOS Plesk VPS (unixbench score ~250) http://postimage.org/image/xvimpi1w/

10.04LTS Virtualmin Linode (unixbench score ~950) http://postimage.org/image/xv5eeq3o/

Sat, 11/27/2010 - 15:31
Locutus

Well, I fetched the site in my browser, and from my home place, performance looks all okay. Frontpage is about 1.2 MB in size and loads in about 3 seconds for me. I got DSL 2000 and the 240 kB/s bandwidth are fully used. Response time and refresh time also looks very good. Will do a test from a 100 MBit connected system in a bit.

Sat, 11/27/2010 - 15:35
Locutus

On my root server with 100 MBit connection the site loads in less than one second.

Are you pointing the domain to the old host at the moment?

Sat, 11/27/2010 - 20:59
konstant

Locutus, I really appreciate you taking the time to do that. In the end I just did a fresh install of Ubuntu/Virtualmin and I'm pleased to say things seem to have improved :)

It seems either something got corrupted somewhere or I just did something stupid. Thanks for the help guys.

I've just noticed that Apache isn't gzipping my .js files by default. If I want to enable gzip for .js files globally, is there a correct/GUI way to do it or should I dive in and edit httpd.conf?

Sun, 11/28/2010 - 04:14
Locutus

Okay then, good that it works as expected now. :)

I don't think Vmin/Webmin have GUI settings to configure mod_deflate (I suppose that's what you meant with "Apache gzipping .js files".)

It's easy though, you just need to edit the config file /etc/apache2/mods-available/deflate.conf and add the appropriate MIME types. It would seem that in my installtion, Javascript is already included. Here's my file:

<IfModule mod_deflate.c>
          # these are known to be safe with MSIE 6
          AddOutputFilterByType DEFLATE text/html text/plain text/xml
 
          # everything else may cause problems with MSIE 6
          AddOutputFilterByType DEFLATE text/css
          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
          AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
Sun, 11/28/2010 - 07:25
konstant

Yes I was referring to mod_deflate or mod_gzip which essentially do the same thing. Deflate.conf was just what I was looking for.

Thanks again :)

Topic locked