Posts tagged with "octopress"

Octopress versus Drupal performance

One of the main advantages of a statically generated blog (like Octopress) over a blogging platform that uses a database (WordPress, Drupal) is performance.

My humble blog doesn't get enough traffic for performance to be a consideration and I thought I wouldn't be able to discern any improvement.

Webmaster Crawl Stats

This graph is from Google Webmaster Tools. Can you guess when the blog migration from Drupal to Octopress was done ? Yes - that's right - the middle of September (17th to be precise).

Undeniably, the performance is much better (fastest response time of 128 milliseconds) and reliable since the move to Octopress. Unfortunately, this 'before' and 'after' comparison isn't ideal. Previously, the blog was running Drupal 7, configured with a small number of modules using MySQL and hosted on cheap ($6 a month) shared hosting with Bluehost.

The performance spikes (high of 2.5 seconds to access a page !) are probably related to high usage of the Linux server my blog was co-hosted on (rather than a specific Drupal performance problem).

When I migrated to Octopress, I also moved the blog to Amazon S3 storage so it's not entirely clear how much S3 has contributed to the relatively stable and fast response times of the blog since mid-September.

With hindsight, I really wish I had phased the migration by deploying Octopress for a month on the same Bluehost hosting (using rsync) and then moved to Amazon S3. Still, it's a but late for that now.

However, it looks like I am ready for the SlashDot effect.

speeding up Octopress generation

My site has 966 posts and 70 categories.

By default, Octopress re-generates the entire site - every single post, all the category pages, the archive pages

On my Acer Aspire One (Intel Atom 1.66GHz) netbook, the regeneration takes around 10 minutes.

There are a couple of options that can significantly reduce this time and make the write/preview/edit iterative process more tolerable.

Firstly, you can use 'rake isolate' to move all other posts into a 'stash' directory and simply process the newly created post.

    $ rake isolate['speeding']
    $ ls source/_posts/
    2012-09-20-speeding-up-octopress-generation.markdown

This reduces the generation time significantly to 18 seconds.

    $ time rake generate
    ## Generating Site with Jekyll
    unchanged sass/screen.scss
    Configuration from /home/andy/blog/octopress/_config.yml
    Building site: source -> public
    Successfully generated site: source -> public

    real    0m18.192s
    user    0m14.369s
    sys     0m1.368s

This is helpful for previewing the post as it will work on the site and fixing typos but still the time consuming site generation needs be to done prior to deployment.

    $ rake integrate
    $ rake generate

The second method is to use 'jekyll --limit-posts '. I added a new Rake task as follows:

    desc "Generate jekyll site (last 5 posts)"
    task :fastgen do
      raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
      puts "## Generating Site with Jekyll (last 5 posts)"
      system "compass compile --css-dir #{source_dir}/stylesheets"
      system "jekyll --limit_posts 5"
    end

This also significantly reduced the site generation time

    $ time rake fastgen
    ## Generating Site with Jekyll (last 5 posts)
    unchanged sass/screen.scss
    Configuration from /home/andy/blog/octopress/_config.yml
    Building site: source -> public
    Successfully generated site: source -> public

    real    0m59.061s
    user    0m40.995s
    sys     0m6.956s

Out of interest, I converted my content into Hyde (a static site generator written in Python).

Hyde generated the entire site in 9 mins 17 seconds. However, Hyde also supports incremental builds (which took just 34 seconds for a single new post).

I also tried raw Jekyll using the default Tom Preston-Werner theme. This took 2 minutes to generate the site in its entirety.