Why Is Twitter Using A Database In The First Place?
mooseyard.com
mooseyard.com
The cool thing about Brad is that he released that creation as open source -- we can all benefit from his genius, like Facebook already has. Memcached is an amazingly effective way of getting the benefits of SQL storage in a simple, scalable, and reliable way. It's impossible to over-hype how much it kicks ass.
If a class of files requests N>1 copies, at what point after the HTTP PUT can the application be happy that N copies exist? It seems fine to think I've three copies of that file but what if machine failure occurs before MogileFS has created the other two?
Also, it's intended to operate on whole files at a time, although HTTP GET might be usable to fetch a run of bytes. If two web servers both try and write the same filename, doesn't the latest one win?
I can see it's great for certain things, e.g. storing the user's images, but not for the stuff traditionally in the database. Or have I missed something?
Cheers, Ralph.
This arrangement is so much faster and easy to understand/measure/optimize for me that I can't see myself going back.
This can be implemented very simply and has lots of advantages all around.
Cheers, Ralph.
Not so. It's not too hard to check if you have some data and then retrieve it from the db as necessary.
If you're reading data from it whenever you find the data isn't in core then aren't you using the database?
As for the "thread that writes changes back to disk at its leisure", how do you guard against machine failure after accepting data for writing but before it's been written?
Cheers, Ralph.
But can a minimal non-SQL solution provide the basic features that people want and expect from a persistent storage layer: transactions, allowing multiple process concurrent access to the data, relatively foolproof failure recovery procedures, etc?
A decent RDBMS gives you those features out of the box in addition to allowing you great data manipulation flexibility. It is this sweet spot of data manipulation flexibility and fault tolerance that makes SQL/RDBMS such a ubiquitous tool.
I suspect code you're "skipping" is the code that would give you those extra features that help with reliability and fault tolerance.
While it is possible to implement those features without using the RDBMS-crutch it takes real code and real engineering effort to do it. If you are writing "way less code" you are likely not providing replacement features.
Cheers, Ralph.
Check out the whole series.
One of the cases given could fit all the data in core, the other used BerkeleyDB for its smallish "database" data, cutting out SQL, and a GFS-like system for the large amount of BLOB archiving it had to do. It's the doesn't fit in core, and is changing data not archiving, case where it seems harder to use flat files since the DB server is a convenient place for concurrancy controls.
Cheers, Ralph.
One of the bottle necks is the continuous polling on the public timeline and its RSS file. It makes me wonder why they don't charge for the privilege.
'... polling for updates every 15 minutes, 24 hours a day, thats still only about 1,000 hits/sec ...'
try every 0-10 seconds per client per person using such clients. [0] If this was happening in other sites it would be throttled.
Reference
[0] google search, 'twitter updates timeline every seconds'
http://www.google.com/search?q=twitter+updates+timeline+every+seconds
Look at Prevayler and HAppS, two systems that don't use a database at all. In-memory persistence with write-ahead logging, and they handle give-or-take 1000 hits/s on a stock Xeon server.
Terracotta may be a good solution for Java.