Darren O'Neill - Blog

grb.im

Project Web

Today I finished working on grb.im – a URL shortening service. The motivation behind building this site was to use a document-orientated database in a real world app. I am by no means supportive of the NoSQL movement as I have used relational databases for years and love the functionality they provide. However I wanted to see what all the fuss was about and decided that a URL shortening service would be an ideal site to test them out on.

I started out using CouchDB but soon gave up as I was plagued by problems. Firstly the Debian binary was an old version. This proved problematic as it seems the documentation and how to approach map/reduce functions in particular has changed considerably since the version I had installed. After then having problems compiling from source I gave up and tried MongoDB.

I am impressed by MongoDB and stuck with it for the site. I like the fact that I can query the database via the command line, there seems to be datasource in CakePHP already and that the documentation on the PHP driver is helpful and contains plenty of examples on PHP.net.

After settling on the database I decided that I would use base 62 encoding on the document ID to generate URL hashes. This ensures that URLs remain small and they are straightforward to decode.

As well as the homepage that shortens URLs the site provides a simple API that not only encodes URLs but provides visitor stats.

Recent

Latest Tweet

Fetching latest tweet...

On the web