At rainmeter.net, we serve over 500000 pages per day. To handle the load on our cheap VPS with 512MB of RAM, we decided to make the jump to nginx. The switch from Apache alone was a great improvement. To further improve performance, we harnessed the excellent static cache provided by the nginx HttpFcgi module. The relevant section of the configuration file is below:

fastcgi_cache_path /tmp/nginx levels=1:2 keys_zone=main:64m inactive=5m;

server {
    # ...

    location ~ \.php$ {
        set $no_cache "";
        if ($cookie_DRUPAL_UID != "") {
            set $no_cache "1";
        }

        set $forum "";
        if ($cookie_phpbb3_7726s_u != "") {
            set $forum "1";
        }

        if ($cookie_phpbb3_7726s_u != "1") {
            set $forum "${forum}1";
        }

        if ($forum = "11") {
            set $no_cache "1";
        }

        fastcgi_cache_key "$host$request_uri";
        fastcgi_cache main;
        fastcgi_no_cache $no_cache;
        fastcgi_cache_bypass $no_cache;
        fastcgi_cache_valid 200 302 5m;
        fastcgi_cache_min_uses 2;
        fastcgi_ignore_headers Expires Cache-Control;
        # more fastcgi stuff ...
    }
}

In order to serve dynamic content, caching has to be disabled for authenticated users. For Drupal, this is as simple as checking for the existence of the DRUPAL_UID cookie. For phpBB, caching is disabled when the phpbb3_7726s_u cookie exists and is not set to 1. The cookie names will likely differ in your set-up.

Since the vast majority of our traffic is from anonymous users, nginx is able to serve most of the pages directly from the cache without interaction with PHP and MySQL. The overall improvement was massive — the initial load time was reduced from over 4 seconds (with Apache) to just 1 second at best (with nginx).

I decided to join the GitHub bandwagon yesterday. TortoiseGit (and msysGit) for Windows seemed to work as advertised until I tried to push my changes into GitHub. I was confronted with the following error message:

No supported authentication methods available (server sent: publickey)

I spent an hour scouring Google and troubleshooting with no avail. Right before ripping my hair out, I discovered that problem was in my configuration of PuTTY, not msysGit or TortoiseGit as I initially assumed. After resetting PuTTY’s default settings by removing the HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings key with regedit, pushing through TortoiseGit worked without a hitch.

Recently, I have found myself with things to share, but without a means to do so. I intend to gather my thoughts, ideas, tips, and guides on various subjects here.

I have decided not to enable comments. Why? Read Matt Gemmell’s arguments against comments. If you want to leave feedback or get in touch, please do so through other means.

This blog is powered by Second Crack. The design is based on Bootstrap. Thanks, Marco and Twitter!