Archive for the 'Sysadmin' Category

Ghost

June 23rd, 2009 by pyrat

Ghost is a nice way to configure your development machine for subdomain based application access.

Using mod_expires to speed up serving pages with apache

May 21st, 2009 by pyrat

This is rails specific to a certain extend and involves setting the expires header on static asset to make browsers cache. This can be dangerous so is best used with timestamped css and javascript assets.

By default: rails helpers will add a timestamp onto the end of the asset so when you redeploy the file the browsers will recache the file because the timestamp has changed.

eg.

  <script src="/javascripts/all.js?1242919746" type="text/javascript"></script>

To setup mod_expires apache on debian based:

  sudo a2enmod expires

Then in your config

  ExpiresActive On
  <FilesMatch "\.(js|css)$">
    ExpiresDefault "access plus 1 year"
  </FilesMatch>

You can easily add image types to this as well but often css loads images and designer often forget to use these helper methods. So in the real world just doing it with js and css makes it safer to do with maximum performance gain.

Turning on mod_deflate to speed up apache

May 20th, 2009 by pyrat

When doing some performance tuning for iformis I have noticed a lot of HTTP overhead in serving pages in modern web applications. This is often due to image heavy designs, large javascript libraries and since the average connection speed of clients has increased, asset number and size are being pushed to the background.

By default apache does not perform gzip compression. I recently turned this on and along with a small increase in load I noticed a large performance increase from the client side.

To turn it on (debian / ubuntu)

  sudo a2enmod deflate

Now im not a fan of copy and paste configs but included below is the mod_deflate config I am currently using. At least read it before using. (Doesnt gzip certain file type and turns off some gzipping for older browsers.)

  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ \
      no-gzip dont-vary
  SetEnvIfNoCase Request_URI \
      \.(?:exe|t?gz|zip|bz2|sit|rar)$ \
      no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
 
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Upgrading monit on ubuntu dapper

April 20th, 2009 by pyrat

Monit in the ubuntu dapper repositories is a bit old. I found the following to work
for me.

  sudo apt-get install libssl-dev build-essential bison flex
  wget http://mmonit.com/monit/dist/old/monit-4.9.tar.gz
  tar xvzf monit-4.9.tar.gz
  cd monit-4.9/
  ./configure && make && sudo make install