Al3x on Twitter Architecture

Alex Payne, a Twitter developer, talks about its architecture and scalability issue.

Twitter is, fundamentally, a messaging system. Twitter was not architected as a messaging system, however. For expediency's sake, Twitter was built with technologies and practises that are more appropriate to a content management system. Over the last year and a half we've tried to make our system behave like a messaging system as much as possible, but that's introduced a great deal of complexity and unpredictability.

Twitter Downtime The fundamental problem of the Twitter architecture is trying to massage a state-less request/response system that is most suitable for read-intensive applications, to a write-intensive message-based system. Basically -- getting Ruby on Rails to do what Jabber/XMPP Server was designed to do -- something is not right! Twitter not being able to scale is not that they haven't thrown in enough boxes, or they haven't cached the right content in the right place, or they haven't implemented a right cluster solution for the database. Not even because RoR is slow, in the way Tech Crunch puts it. It does not scale because it was not architectured to what it was supposed to do. A paradigm shift is required. Maybe they should have started with an Erlang backend in the beginning, like what Facebook did with their chat system.

Re-architecture an existing system is never fun though. Not many can afford a second team doing a rewrite. Rewriting component by component is not really optimal, especially if the original design was not well componentised (for scalability's sake, it's often not!) At work we have also been talking about rewriting the backends (to increase scalability + server utilisation) and frontends (employ various RIA techniques), and it has been very frustrating when you lay it out "what needs to be done", but management's asking "can it be done bit by bit?" or "does it add any functionality?" (mind you that our SaaS product is maybe 500x more complicated than Twitter although requiring only 1/100000's scalability). Yes. Frustrating.

Anyway. Good luck to Twitter because I really want to use it. Except it is not working right now. Message via Jabber is broken...