Does enabling gzip compression in the nginx configuration have the potential to save 5.7k tons of CO2?
That was my initial question as I noticed that the default configuration of Nginx is turned off. Read about the calculation in this article. I posted about that on LinkedIn and got some valuable feedback. And it shows this question is something people resonates with.
Of course this is not a black-and-white answer. There a many factors to consider. However one of the things that got mentioned most in the discussion was that the compression cost additional energy on client and server that might outweigh the savings coming from reduced data transfer.
That is a very interesting question that I would like to answer.
Within this repository I want to create a transparent measurement setting to bring more light into this question, and of course, to learn more about measurements.
My plan:
Use [Green Metrics Tool] for Tests on Hosted Service To make this happen the following things must be done:
- Use docker image with a slim Nginx Setup
- Use "stress" image with a wrk installed to stress the server
- Create testdata to be served by the server.
- Create a
usage_scenario.yml
file with flow to stress Nginx by loading this test files. - Run the tests in different configuration (compression enabled/disabled)
There are three different types of data in different sizes (1kB, 10kB, 100kB, 1MB, 10MB):
- Textfiles with repetitive content (easily compressible)
- Textfiles with random content (poorly compressible)
- Textfiles with binary content (e.g. JPEG)
Testdata can be (re)generated with
sh ./generate-testdata.sh
Wer misst misst Mist
A german saying that states that often measurements lead to confusion as the are probably done wrong.
That's true and that is the reason why I want to be transparent on the process here.
Here is a short history of different measurement settings and (probably wrong findings).
First measurement. Result only shows that measurement setting is wrong.
Too much load on the sever. Can not seen any difference whether I load small, large or compressed or uncompressed files. wrk seems to put the server under heavy load. Server is at 100% no matter what phase in test.
Conclusion: Find a better setting. I want to be able to see a difference in workload between sending a uncompressed 1KB file and a compressed 10MB file.