While designing a web application facebook application to be precise. Which can spike and increase rapidly because of it vitality and is right intensive.

What point should one keep in mind while designing the DB. For example what things should I leave room for if I need to shard or have a Master/Slave combination later (with memcache)

Considering I use Relational Database with mySQL

2 Answers 2


beyond the usual 'shared nothing' at the app layer, the first thing i'd think is to 'go immutable'. That means that you should try to (almost) never modify a record, instead write a new one (with a new ID. you're using ID on all tables, right?). That way, you don't have to bother with deprecating cache entries. simply make them keyed on the same IDs and let them expire when not used anymore.

  • So if I'm not updating things, wouldn't I have to search for the latest record everytime I do a lookup? Wouldn't that me more costly? Secondly, I never got the answer that should my server be stateless or not. Secondly can I have a server which is stateless and still communicate to facebook? Jun 17, 2010 at 7:00
  • @Fahim Akhter: no, you store a link to the 'current' versin. of course, that means changing the record that links to that, so it's another copy... and so on upwards on the inverted tree. when you reach the 'tip' you can actually modify the record, or add another table just for storing this version, and optimize the hell out of it as you grow (probably you'll end with a sharded, on RAM, noSQL db; but only for this record. the 'meat' of your data can stay on SQL)
    – Javier
    Jun 17, 2010 at 14:18
  • @Fahim Akhter: stateless is usually good. in fact, it's the easiest way to get 'shared nothing' servers (and the DB is on another tier). Note that statelessness doesn't limit what functionalities you offer, so facebook has no say on that.
    – Javier
    Jun 17, 2010 at 14:19

The book Scalable Internet Architectures has a great discussion and breakdown on the considerations of scaling databases (and Internet infrastructure in general). It should be required reading for anyone who develops web applications and databases which need to scale across servers.

  • I've gone through all of it, my issue is perticularly with facebook. I want a stateless server. But if I communicate with facebook can I still have a stateless server? Jun 17, 2010 at 7:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .