Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is gzip compression slower for me?

Why is http://storyfollower.com slower when I use gzip?

Check the data bellow:

With compression: Load time 1.99s Page size 586.2kB Perf. grade 83/100 Archived: http://tools.pingdom.com/fpt/#!/nE0Jnn7Hp/http://storyfollower.com

Without Compression Load time 835ms Page size 756.2kB Perf. grade 79/100 Archived: http://tools.pingdom.com/fpt/#!/nFmp4l3Ez/storyfollower.com

thanks

like image 521
Chriswede Avatar asked Feb 11 '12 12:02

Chriswede


People also ask

Why is gzip so slow?

The reason is that gzip operates on (in terms of CPU speed vs HD seek speed these days) extremely low buffer sizes. It reads a few KB from from the input file, compresses it, and flushes it to the output file. Given the fact that this requires a hard drive seek, only a few operations can be done per seconds.

How can I improve my gzip performance?

You will have a little bit of added programming to do in order to decode the gzip header and perform the integrity check with the gzip trailer. You would then use Inflater with the nowrap option to decompress the raw deflated data after then gzip header and before the trailer.

Is gzip enabled by default?

Gzip Compression is Enabled by Default.

How fast is gzip compression?

gzip compression adds about 0.001 seconds to compress, and 0.0003 seconds to decompress (let's round up and say 0.002 total), but you only have to transmit 16kB, which takes 0.0032 seconds. Add them together, transfer with gzip compression is about twice as fast.


2 Answers

Most of the overhead is waiting for the server to send data. I guess that is the time needed to compress the data.

Using compression for the page under test gains you very little: 587Kb -> 756Kb, so the CPU overhead is greater than what you gain from sending smaller data.

I'd suggest you try with another page which sends more data. If you don't have such pages, then using compression is probably not the best choice.

like image 143
rodion Avatar answered Oct 14 '22 00:10

rodion


A nice way to have both gzip and low cpu overhead is using a cdn and storing the gziped files there

like image 35
Chriswede Avatar answered Oct 13 '22 23:10

Chriswede