SUBSTANTIAL speed improvement by enabling compression

SUBSTANTIAL speed improvement by enabling compression

by Gary Anderson -
Number of replies: 4
I did some experimenting today and found an incredible increase in speed by enabling compression for Moodle pages on our Apache servers.  Increases in speed are on the order of of being 30% better to almost 2.5 times as fast to load pages, depending on the size of the page and the speed of the server's processor, etc.  I found little speed improvement, on the other hand , for compression of files or pictures.

I am using the standard distribution of Moodle 1.6 using the Windows XAMPP distribution found on download.moodle.org.  To enable compression, make the following two changes to the file httpd.conf found at C:\moodle\apache\conf. 

  1. Un-comment the line:
    LoadModule deflate_module modules/mod_deflate.so
        
  2. Add the line:
    AddOutputFilterByType DEFLATE text/html text/plain text/xml

Save and restart Apache.

A couple of notes:
  1. If you want to compress all files, change the AddOutputFilterByType line to:
    SetOutputFilter DEFLATE
  2. Some very old browsers don't like compression, so for this and other reasons, you may want to read http://httpd.apache.org/docs/2.0/mod/mod_deflate.html for more information.

My experiments, with 10 page loads each on a large home page with many courses was:
  • Without compression:  2.51 seconds
  • With html files compressed:  1.04 seconds
  • With all files compressed:  1.11 seconds

For things other than simple page loads, there was a 10% improvement when downloading lots of pictures such as at a at /userpix or for uncompressed .exe file or movies, but I decided that page load time and keeping the processor available was more important which is why I just compress HTML pages.

This was with a fast server (dual XEON processors); I got about a 30% improvement in speed with an out-of-date processor with a satellite connection on a server in Africa and a smaller home page:  still significant, but not as impressive as the above.

Hope this helps.

--Gary
Moodle Master and Math Department Head
Seattle Academy
Average of ratings: -
In reply to Gary Anderson

Re: SUBSTANTIAL speed improvement by enabling compression

by Rory Allford -

For compressing dynamic content you may actually get better performance by using the ZLib or ob_gzhandler output buffer within PHP, with a reduced memory overhead for one, especially given that CPU power. There are also some issues with mod_deflate compression regarding a bug in the old moodle 1.5 filelib.php bloating memory usage when downloading large files.

Perhaps you could put your findings in the moodle docs wiki... smile

In reply to Rory Allford

Re: SUBSTANTIAL speed improvement by enabling compression

by Joan Codina Filba -
One of the drawbacks of doing compression is CPU time in the server, for a single process you increase performance, but if you have many page requests in parallel then CPU is your bottleneck, not your network
This can thus be used in a pipelined parallel system, where there is a server that gets the requests, and sends them to a cluster of moodle/mysql servers, then he gets the answer compresses and sends it compressed.
Joan
In reply to Joan Codina Filba

Re: SUBSTANTIAL speed improvement by enabling compression

by Genner Cerna -
ya, notice the drawback too since we are using the deflate... the tendency the server hangs.
In reply to Genner Cerna

Re: SUBSTANTIAL speed improvement by enabling compression

by N Hansen -
One of my students in the UK told me that my upgrading to 1.6 had made the loading time of the Moodle pages significantly faster for him.

On the other hand, it times out a lot more often for me. As long as the students are happy...