Several months back I took my wife and five children on a 7 day Disney cruise (I *HIGHLY* recommend it by the way, and I’m a hard person to please
). Whenever I go on vacation the first thing I take care of is making sure that I have internet access. Thankfully, I was able to use my Verizon MiFi card while in most ports, but while at sea I had to use Disney’s on board satellite internet. It was extremely slow.
This got me thinking of how I could best increase the internet speed for our clients that have slow internet connections at no cost to them. I decided on using mod_deflate. I had used mod_gzip in the past (Almost 10 years ago) so I was familiar with how it all worked and it was simple to set up. Mod_deflate basically takes certain types of files and compresses them at the server level and then sends those smaller files to you. Images, zip files, etc don’t compress well (And so we don’t compress these, but HTML files, javascript files, css files, etc compress very well. Often we see 80% compression levels on those type of files. These files are then decompressed on the client side automatically and used. This is all transparent to the user, except that download/page load times are much faster for the user (10-25% faster).
However, there is a severe problem with using mod_deflate that no one seems to have solved. Using mod_deflate requires *significant* CPU usage on the server to use. The problem is that often CPU resources are maxed out. If you use mod_deflate while the CPU(s) are maxed out then the servers become even slower and all websites on the server will appear very very sluggish. For this reason most web hosting companies don’t use mod_deflate, and for good reason.
However, at Bluehost/Hostmonster we have a great solution for this problem! Some of you may have read a previous blog post where I mention that Bluehost/Hostmonster have a proprietary CPU protection system. Using, this system we track CPU usage in realtime. We then wrote a patch to the Apache web server (This is what serves your websites to your browser) that interfaces with our CPU protection system. This patch checks our CPU usage twice a second and if CPU usage exceeds a certain threshold then we temporarily suspend mod_deflate. When there are unused CPU cycles then it reenables mod_deflate. By implementing it this way we get all the benefits of mod_deflate with none of the detriments of excessive cpu usage causing slowdowns.
The first full day we ran this it lowered our bandwidth consumption about 600 Mbits a second (With very conservative settings). When we run it with aggressive compression we save over 1 Gig/s of sustained bandwidth. That is considerable savings/speedup for something that took about 4 days to develop, test, and deploy!
Now, next time our family goes on a cruise Bluehost/Hostmoner sites will appear much faster!
Thanks,
Matt Heaton / Hosting by Bluehost.com
Hello, Matt!
In your post typo – “a cruise Bluehost/Hostmon[]er”, please fix )
Amazing! I am hosting my site with bluehost for the past couple of years, and the only thing I have to say is that your service rocks! It is really amazing to know that even being (in my opinion) the best out there, it still gets better and better year after year.
Thanks for all your work!
Matt,
?
I came here at your suggestions in an email relating to my site being migrated to a new server. You asked for comments
re: this post – I once had to ftp video files to a client on a carnival cruise – terrible throughput via there satellite inet services – apparently the bandwidth achievable is not so bad, but a lot is reserved for the ship’s private overhead, and then split up 3000 ways for all the passengers from there… and possibly even mobile phone usage is taking bandwidth?
I’m guessing this would help FTP file transfers as well? or would it depend on the nature of the file being moved?
re: site migration: I’m glad my site moved, and the move went smooth as far as I can tell – except – my mail host changed from box289 to box516 and nobody told me… would it be possible in the future to include this information w/ the migration details emailed?
Matt, you’re much like me
or vice versa! we’re both genius’ !! each time I read about your innovations I say – and repeat – ‘he thinks just like me, he thinks just like me, he thinks just like me’
Speed is crucial these days. People want their websites to load as if watching tv, and I personally think thats where the internet is going. Some day, we wont have to worry about bandwidth…
Just another reason why bluehost continues to push the envelope and deliver the goods for their clients…
Bluehost is obviously on the top of the game with these developments deployed. I wondeer how much power CPUs draw after you deployed this. I’m sure it’s a worthy tradeoff financial-wise, but I’m curious.
I’m paranoid about streamlining a website’s efficiency, and this move is great for me!
Matt,
Any suggestions how to reduce the latency between Utah and Luxembourg for your Luxembourg customers?
Yes, you have Luxembourg customers; at least one. Me
Thanks for the good service.
thanks no wonder my hosts dont allow this, theyve asked me to use zend gzip instead.
Hello Matt.
Glad to hear of the improvements that may be coming. But in Portugal, the response time of your servers is very bad. I have an average of more than 200 ms to ping. I hosted in your servers four sites (www.bairradadigital.pt / blog) (www.tecnologias.in) (www.sebentadigital.com) and (www.omelhordoi.com).
I hope that the change come to Portugal, because until now not been informed of anything.
regards
Pedro Costa
These CPU monitoring patches and Apache patches are awesome. I hope that in 3-5 years after you have reaped the competitive advantage, that you will open source them. Some of us in private data centers would love to try them out.
Hi Matt.
Excellent achievement. The beauty of it lies in its simplicity ! and the simpler the solution the more stable it will be. I manage a couple of websites on your server. Thank you for the extra power ……….
OK, I think this explains why my website all of the sudden started experiencing slowdowns although there were no changes to database, code or number of visitors.
Are you sure that your 4 day turnaround from idea to implementation was properly regression tested?
“However, there is a severe problem with using mod_deflate that no one seems to have solved. Using mod_deflate requires *significant* CPU usage on the server to use. The problem is that often CPU resources are maxed out. If you use mod_deflate while the CPU(s) are maxed out then the servers become even slower and all websites on the server will appear very very sluggish. For this reason most web hosting companies don’t use mod_deflate, and for good reason.
However, at Bluehost/Hostmonster we have a great solution for this problem! Some of you may have read a previous blog post where I mention that Bluehost/Hostmonster have a proprietary CPU protection system. Using, this system we track CPU usage in realtime. We then wrote a patch to the Apache web server (This is what serves your websites to your browser) that interfaces with our CPU protection system. This patch checks our CPU usage twice a second and if CPU usage exceeds a certain threshold then we temporarily suspend mod_deflate. When there are unused CPU cycles then it reenables mod_deflate. By implementing it this way we get all the benefits of mod_deflate with none of the detriments of excessive cpu usage causing slowdowns.”
In response to the satellite and the cruses ship – well I am on satellite right now and off your servers my site loads in a few seconds. Why? Because I have set the MTU on my router to the Max size it can transport data over the satellite connection and not having the Operating system calculating it. It is just a simple fix. My latency is about 1200ms 1900ms.
The “cloud computing” Tab are the pages running live from Google Docs. that can be edited live from Wave.
Al
hmm you tied a vacation, the wife and a ships interet access to a webhost serving files -wow you good – and I learned something since I would of never known about how to speed things uplike you did. guess its a good idea when it works.. thanks for sharing
Man I wish I was on vacation. After a few nice days it is supposed to snow again!!! Arrgghhh, when will it end
Hi,
I liked your post a lot and was searching for the mod_gzip and mod_deflate over internet.
I found a very useful utility http://www.whatsmyip.org/http_compression/
This site shows whether your site compression is enabled or not. It is a great tool and Im putting my site in gzip mode.
But when I checked there for http://www.mattheaton.com it showed that the site is not gziped.
I was 200% sure that the site http://www.mattheaton.com must be in compression mode.
Anyways thanks for info man.
Rushikesh
“Bandwidth Compression – This allows our customers to see a 10-25% decrease in site load times.”
HOSTMONSTER is committing the unforgivable sin of re-compressing the compression in jpegs, mp3s, videos, etc. which is FATAL when transmitting files to be used for publication, broadcast, movie effects, etc.. AND HOSTMONSTER DID THIS WITHOUT FOREWARNING THE USERS! We put the highest quality files of our Symphony Orchestra on our server. What was pulled down by PBS and put directly on the air was terrible and blamed on us, and now we have discovered that FATAL recompression is being done by HOSTMONSTER. Here is a part of the file HOSTMONSTER ruined which is permanently archived on National and International Public Radio:
http://www.tavissmileyradio.com/guests10/031910/AllenRobertGross_DavidBendett.html
Actually, we don’t compress JPEGS, mp3ds, or any video codecs. Not sure where you got your information, but you should check before you say we did something that we really didn’t do….
Just a thought.
Matt Heaton
Hey,
That is good to hear, but it also baffled me when suddenly mod_deflate wasn’t working thru my .htaccess configuration, I had to post a ticket to which I got the link of this post of urs.
Anyways, nice work.
I have been recommending our affiliates as well and missionaries to BlueHosts and we are all happy with your services. It would be wonderful that you could provide additional online tutorial for Mod_deflate?
Thanks Matt.
KH
Apache for static files? We use nginx on our 2 servers for static files, works faster than apache. With proper caching settings we save a lots of server recources.
Wow – 4 days of work to save 1 Gig/s in bandwidth? I’d say that was worth it! Bluehost and hostmonster are the same company? I didn’t know that.
Matt,
Sounds like some exciting optimizations, however I’m hungry for more specifics…
When you say Gigs/sec are refering to Gigabits or Gigabytes?
How does running mod_deflate affect your throughput? I was a little unclear if you were increasing how many pages you serve a second or if you were keeping that measurment constant and reducing the number bytes you sent through the pipe.
With my servers (I am, by no means, a pro with server adminstration) I am only able to slightly increase throughput with software compression when I set the compression level to 1 and am only pushing a 1 gigabit of data or less (this is with an i7 machine). When I measure the power per page servered, it is usually much cheaper to turn software compression off. Is this your experience? How much more does it cost you (relatively) via power and heat to use this system?
Also, doesn’t IIS already do this sort compression throttling? Is it similar to what you are doing?
Sorry for all the questions…this just happens to be a topic I am fascinated with.
Dr. D’Lynn Waldron,
Congrats on getting your stuff on NPR! Yeah, I know the current implementation sucks for some reason, but remember, the first time is the hardest.
A couple of things to remember:
#1 You are accusing a freaking kernel hacker of being stupid enough to needlessly burn processor cycles for double compression. This is something along the lines of accusing the first violin of using guitar wire strings to save a buck. Just isn’t credible.
#2 Re-compressing and de-compressing won’t degrade the audio in the slightest. I know, I’ve done it. It just wastes a lot of time. Or are you actually accusing Bluehost.com of automatically re-encoding your audio files to a lower bitrate on the fly?
I listened to your audio. Frankly, it sounds to me like the music was played from the website, as opposed to being downloaded as a file then played locally. The difference is “saving” the file, as opposed to “clicking” the link and just letting it play on the PC’s web browser.
If that is what actually happened, (and I’m certain that it is) then whoever hit “play” from the website instead of running from a local copy on the PC’s hard drive, is the person you ought to go and kick, soundly.
Here’s a tip: Next time (and there will be a next time, because your symphony sounds fantastic) bring at least 2 copies of the music on a flash drive. That way, you won’t get to the studio, do a live broadcast, and get hammered by internet connection issues.
Not to mention, whomever was willing to play streaming music from the web onto live international radio is suicidally stupid, since that file could have been swapped without your knowledge to ANYTHING while you were gone.
I assume it was live radio, because it would have been the work of about 30 seconds for a competent person to download the file and start that section of the recording over. If it was rebroadcast, you should kick whomever was running the show.
Might I also recommend that you take the glitch free recording and post it at
http://www.smsymphony.org/program3.html
I, at least, would very much like to hear the good version of the music. And quite possibly, you could get Travis Smiley to post the file on his website. Maybe even fix the audio in the broadcast and offer the option to his visitors to hear your beautiful music the way it was intended. It’s obvious that your crew is playing as a labor of love.
Good luck in the future, and I’ll see you next time I’m in Santa Monica during one of your concerts.
I am referring to gigabits/second of bandwidth. Mod_deflate lowers my total throughput over our pipe to whatever level we do the compression, but the effective throughput it much higher because of the compression. Does that make sense? We are basically serving the same number of files, but reducing the number of bytes sent over the pipe.
With regards to power, it does increase power to do the compression. It isn’t significant, but it’s there. However, reducing page load times for customers, especially for those customers with slow internet connections more than justifies the extra bandwidth usage in my opinion.
I don’t know about IIS, we don’t run any windows servers at all. Its all Linux 100% of the time
Matt Heaton
I have enabled the mod_deflate option and it works great for our web site. The following is all you need to plug in to your .htaccess file. It is what we use. Be aware that the long line with “no g-zip dont-vary” is one line, not two, and that the two words are separated by a space. That line lists excluded filetypes that are already compressed and would not benefit much from additional gzip compression. They are excluded in order to save the host server some CPU cycles (no point in wasting them).
# Turn on compression for some filetypes
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|jpeg|mp3|mpg|jar|png|zip|rar|gz|bz2|sit|flv|pdf)$ no-gzip dont-vary
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Matt, you’re really genius!! Internet connection is very important even I am on a vacation. This is a great tool Thanks..really thanks for sharing!
[...] And last but not least, I love the fact that Bluehost has a CPU protection system, best described by Matt here: http://www.mattheaton.com/?p=228. [...]
I am in san juan and lines here are unstable.
An oh.. 4 days = 1 Gig! Its unbelievable. I am with hostmonster anyway.. but I am still considering bluehost.. but they are sisters?
I have a few sites and have had problems with my host shutting them down for too much usage, this will really help me out thank you.
you have mentioned that you are using mod_deflate instead of mod_zip. Can you explain why not mod-zip?
I’m asking because Google webmaster Tools urges me to use mod_zip on my site, as the files aren’t compress.
Also, do I have to enable mod_deflate on my site, or is it automatic? I’m using Bluehost.
Website: trivester.com
Thanks in advance.
Not that I think one is better than another. It just worked for what we needed. I have used both in the past.
On our side it is 100% automatic. You don’t need to do anything at all on your end.
Thanks,
Matt