The article
“How gzip-compression affects server performance” caused an understandable, but somewhat ambiguous reaction, because it was not clear how much the cost of gzip depends on the degree of compression and how to predict it taking into account all the other parameters. I want to say a special thank you
alfa , which, in fact, raised this question.
So, a new series of tests was aimed at establishing a relationship between compression ratios, processor overhead, and decreasing file size in order to make an
analytical tool for calculating the optimal compression ratio based on this data.
Technique
As before , the server conducted a series of tests with 10,000 iterations each. The gzip runtime was measured at various degrees of compression. Then it was averaged over the series, and the costs of working with the file system were subtracted from it (
for more details about the costs in the previous article ). Also, the achieved reduction in file size was measured.
')
results
For the dependence "processor time - compression ratio" the following graph was obtained. The abscissa axis is the degree of compression, the ordinate is the elapsed time (average over the series):
Figure 1. The cost of gzip on compression ratio
Next, a graph of the effectiveness of the resulting compression (in% of the original file size) on the compression ratio:
Figure 2. Efficiency of various degrees of gzip compression
findings
The main conclusions do not differ from those obtained in the
previous article , however, we managed to clarify it somewhat (due to the fact that when specifying different degrees of compression, processor costs can vary many times). All the findings are applied in the
following tool to calculate the optimal degree of gzip compression for the server (and in general, the rationality of enabling gzip). Parameters that can be varied: CPU 1 processor on the server (for gzip does not parallel), the CPU of the user machine and the characteristic speed of the channel among users. Their various variants cover a rather wide range of possible cases, and the calculation error does not exceed 10%.
A small note: if the size of text files on the server does not exceed 4Kb, the inclusion of gzip will not give a tangible performance gain at all.
Thanks to everyone who read the note. If you have any suggestions for improving this tool, please write them.