Sunday, September 21, 2008

Sharded Counters Take Too Much Time

The purpose of sharded counters is to reduce contention for a single entity on serialized writes.  The concept is to create multiple sub-counters that are added together to create a single counter with the sub-counter that is incremented selected at random.  This seemed ideal for TCP3 since we need to count pretty much everything.  We count clicks, previews, clicks per day, previews per day, etc. 

The problem is that sharded counters take too long.  I'm still profiling, but i'm getting quota warnings on even the memcached sharded counter implementation suggested in one of the Google I/O briefings.  Updating the sharded counters takes 3.5 seconds in my application.  My problem is that i'm not sure if this is a performance problem for appengine or a bug in my code.

I'm going to have to consider an alternate implementation.  I'll post details as soon as I come up with something that works.

Wednesday, September 10, 2008

An AppEngine URL Shortener

Any application that needs to scale needs to designed to do so from the beginning.  Or at least that's what I used to think.  Even when Amazon introduced EC2 and S3 there were still design requirements that you needed to consider.  In fact, I actually started this project with S3 as the back-end.  The idea was to store the URLs on S3 which had very quick response times and use quick scalable hosting (I hadn't decided which hosting service at that time) with round-robin DNS to scale the front-end.  It was a simple architecture but it would have worked.  But...before I was able to go very far with the project, Google launched AppEngine.  AppEngine took an entirely different approach to scalability.  Use their SDK and platform and don't even bother with scalability.   So, I decided to switch over and give it a try.

This project is the ongoing development effort based on that decision.   I will describe and write about design decisions, feature plans and problems and roadblocks caused by the AppEngine platform.

Oh, and feel free to comment.  I will approve any and all constructive comments both postitive and negative.