NoDB is the new NoSQL

July 23, 2013

NoSQL was all the rage a few years ago. You could shove stuff into it with no schema and maybe have an index or two to speed queries. That simplified application design in some cases. To simplify even more consider using the NoDB pattern where there is no database!

An example of a NoDB app from a few years back was a Twitter proxy we used for caching Twitter feeds and setting up security to allow Flash access. We code named it “Twoxy.” The only input was a Twitter URL and there wasn’t a need for a database. Caching was done with memcached or a file cache and we disabled the DB in Rails with “frameworks -= ‘activerecord'”.


Another example of NoDB is this Sinatra app that let’s you play 1-4-24 online. The entire state of the game is stored in the session which is an encrypted cookie. No database is required to store the odds used by the AI. Initially the odds were cached-as-you-go in memory using some memoizing but are now loaded at startup.

This NoDB pattern is wonderfully simple but there are downsides. One problem can occur when storing the state in a cookie. If the app makes synchronous requests then one request may change state simply to have the state reversed by a competing request. To prevent this make serial requests or do not change cookies when they aren’t needed. Putting session state in memcached could also prevent this problem.

Another downside is there is no history or audit trail. Another downside is there’s no way to aggregate sessions e.g. a high score list. (I lied, 1-4-24 actually has a database for this purpose: Amazon’s DynamoDB. I thought DynamoDB would be super easy to setup since it has a lightweight API. However, I needed some features not available in v1 of the Ruby API and the v2 API hasn’t been streamlined too well yet. It took longer than expected but now I know more than I need to about DynamoDB).

The end result turns out to be very scalable. For gameplay I can spin up as many Heroku dynamos as needed and there will be no contention on a database. DynamoDB claims to be very  scalable so writing or reading high scores should be fine as well.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: