trac performance

There are suggestions for improving performance at http://trac.edgewall.org/wiki/TracPerformance. With my existing configuration I had it typical page loads are taking 4 to 5 seconds, after making the changes below typical page loads are around a second, some faster some slower (loading the first page takes longer).

<Directory /var/trac/cgi-bin> WSGIApplicationGroup %{GLOBAL} Order deny,allow Allow from all

</Directory>

Restart Apache

sudo /etc/init.d/apache2 restart

I then tested trac and it was still functioning as before 🙂

Mapping Static Resources

By default static resources like style sheets and images are served by trac itself, it is more efficient to have Apache serve these directly rather than get trac to serve them.

First extract the static resources and delete the ones we do not want (I don’t want cgi-bin as I’ve already configured it, and I don’t want htdocs/site because I will directly reference the files in the trac install).

sudo trac-admin /var/trac/projects/play deploy /var/trac/static

sudo rm -rf /var/trac/static/cgi-bin/

sudo rm -rf /var/trac/static/htdocs/site/

sudo chown www-data:www-data -R /var/trac/static

Now configure Apache to directly serve the static resources

sudo vi /etc/apache2/sites-enabled/000-default

Add the following after the last </Directory> element

Alias /trac/play/chrome/common /var/trac/static/htdocs/common

Alias /trac/play/chrome/site /var/trac/projects/play/htdocs/

<Directory “/var/trac/static/htdocs/common“> Order allow,deny
Allow from all</Directory><Directory “/var/trac/projects/play/htdocs/“> Order allow,deny Allow from all</Directory>