6 ms·
Looking into the future with Cassandra
- mcav 17y agoWow: > For this feature, the fully denormalized Cassandra dataset weighs in at 3 terabytes and 76 billion columns.
- breck 17y agoWhat's amazing is that 3 terabyes costs about $300 nowadays. Include good components, power, redundancy, maintenance, and it probably comes to $1,000 per year. So this feature is actually pretty cheap to do, unless I'm missing something.
- SwellJoe 17y agoEvery time I read "terabyte", I have to pause, because my brain goes "That's gigantic!" and then a little voice says, "It's the same size as the hard disk in my desktop...it cost $89." I have the same sort of weird mental disconnect with SD cards. It's just hard to fathom 32GB of data fitting into something about the size of a quarter.
- imajes 17y agoalso note that WD (?) have managed to make a terabyte 2.5" disk. Expect high-end laptops to ship with that soon enough. :)
- willy1234x1 17y agoHey, I know the feeling, it's weird to adjust to but I still haven't filled my 5 Terabytes of space yet so I'm happy. Soon I'm going to offload all my files to a file-server I'm building with an exorbitant amount of HDD space.
- jbellis 17y agoServing up thousands of requests per seconds from 3 TB (while continually adding and updating more data!) is a lot different from just archiving it. A _lot_. :) To put it in perspective, 100GB is pretty much the limit of what you can serve from a single mysql machine, for instance. This will vary depending on exact workload but that is a reasonable ball park number.
- SwellJoe 17y agoOf course, in a relational database you wouldn't (generally) be storing the vast majority of the data in question...you'd be querying for it. That's not to trivialize the improvement in performance here, just to point out that this probably would be 100GB in a MySQL database.
- ntoshev 17y agoAny idea how much per machine can you serve when you use a bigtable/cassandra/dynamo/pnuts-like system instead of MySQL?
- ntoshev 17y agohttp://wiki.apache.org/cassandra/PoweredBy http://wiki.apache.org/cassandra/PoweredBy 330GB per machine for Facebook's Cassandra cluster.
- joechung 17y ago3 TB of disk is easy. 3 TB flowing quickly from disk to RAM to CPU cache and back out again is another story.
- rbanffy 17y agoI am most of the time disappointed by x86s, but i5/i7 looks more promising: http://arstechnica.com/hardware/news/2009/09/intel-launches-all-new-pc-architecture-with-core-i5i7-cpus.ars http://arstechnica.com/hardware/news/2009/09/intel-launches-...
- pgebhard 17y agoI was thinking "WOW", as well, but breck's right. This shouldn't really be that surprising any more given the price of disk storage these days.
- fr33bird 17y agonosql....its like the first two weeks of dating but then the bloom comes off the rose and suddenly precomputing all of your results gets tired, particularly when they all propogate changes into each other's records lets boil it down: the sql model stores data and computes answers with the query facility the key-value model stores answers. there's no magic here, you could hypothetically jigger mysql et al in the same way...just dispense with any decomposition of data, any features of the query language, and turn it into a key->answer system. throw caching in front of it and you've pretty much rebuilt cassandra, but with more robust pieces
- rarrrrrr 17y agoIn SQL systems, you can easily shift the computation cost from at read time to at write time. That's what triggers are for. When new data comes in that changes a result you know you need quickly, a trigger can automatically add to a work queue to update a result table. Since the trigger has automatic access to the contents of the new data (and old data in case of an update or delete) the computation to update the results table can often be made much faster. Every situation is different of course, but it's overreaching to say that SQL systems have no options beyond read-time computation of results.
- staunch 17y agoThis was my first thought too. Why not just denormalize the data in MySQL? What benefit is Cassandra really offering here over that option?
- jbellis 17y agoCassandra gives you two benefits. First, Cassandra uses a disk layout similar to the one described in the Bigtable paper (http://labs.google.com/papers/bigtable.html http://labs.google.com/papers/bigtable.html sections 5.3 and 5.4); in particular it does no random writes. Relational databases like mysql pretty much all use btree-based storage which was great 20 years ago but is terrible today when seeks are your bottleneck. I was talking to some people today who are struggling to get mysql to do ~100 insert/update operations per second. Cassandra will easily give you 10x that -- _per node_. The second benefit is that Cassandra gives you real, scalable partitioning, invisible to the app, for when you do need to add nodes. When you have more than a handful of machines, not having to babysit replication + partitioning is a huge, huge deal.
- aaronblohowiak 17y ago"I was talking to some people today who are struggling to get mysql to do ~100 insert/update operations per second." I apologize for being flippant, but.. Were they running MySQL on an EeePC ? They are probably Doing Something Wrong if they are struggling to do >100 insert/updates a second on even modest hardware.
- gcv 17y agoI read in several blog posts that Cassandra has its share of data-corrupting bugs. http://blog.evanweaver.com/articles/2009/07/06/up-and-running-with-cassandra/ http://blog.evanweaver.com/articles/2009/07/06/up-and-runnin... mentioned that even Facebook does not use it as a system of record. Wonder how Digg deals with that.
- jbellis 17y agoWhat that article says is if you do something analogous to backing up a live mysql database with dumb cp, Bad Things Happen. Yes, we do plan to make it harder to shoot yourself in the foot, but this isn't a data-corrupting bug of the kind you meant.
- imajes 17y agoNote that they're using cassandra for _computed_ data- the original components still exist elsewhere.
- justin_vanw 17y agoSELECT `digdate`, `id` FROM `Diggs` WHERE `userid` IN (59, 9006, 15989, 16045, 29183, 30220, 62511, 75212, 79006) AND itemid = 13084479 ORDER BY `digdate` DESC, `id` DESC LIMIT 4; Ok, how do we optimize this query? Step 1: Keep all dugg items in memcached for the last N days, where N is determined by when you run out of memory. Then, your query becomes: SELECT `digdate`, `id` FROM `Diggs` WHERE `userid` IN (59, 9006, 15989, 16045, 29183, 30220, 62511, 75212, 79006) AND digdate < now() - interval '5 days' AND itemid = 13084479 ORDER BY `digdate` DESC, `id` DESC LIMIT 4; /* Excuse the postgresql syntax / If your database is properly clustered, this will mean you are only running the query against partitions holding old dugs, which is probably not as hot as the more recent stuff. Additionally, I strongly suspect that you see more recent articles more than old ones, if the article is less than 5 days old you need no SQL at all, just the memcache lookup. For example, if you are looking at the homepage, and there are 15 articles on it, you have to do a single memcached get request for all the pairs like (article_id, friend_id), so if you have 100 friends that is 100 15 keys to request. This is large, but who cares, you can add memcached servers and webservers until you puke and this will keep scaling without limit. When browsing old articles the db will get hit heavily, but only the partitions holding old data, and I would guess that this is a very very small fraction of their overall use. Step 2: When a user is activly using the site, like they have viewed 2 pages in the last 10 minutes or something, shove all their old (article_id, friend_id) pairs into memcached as well. Once a user has reached the 'activity threshhold' and the cache is filled, no sql is necessary to find all their friend's dug articles. As a bonus, no weirdo software like 'cassandra' which may or may not continue to exist in 1 year is necessary. For step 1 you need very little effort, just put a key into memcached every time a user digs something, and put a 5 day timeout on that key. This is 1 line of code in whatever code handles the http request representing a 'dig'. Then you have to build up the list of friends and keep it somewhere when a user logs in to the site (or returns with a cookie that has them logged in). This would take one memcache request when the user logs in/comes back to see if their friends list is in memcached, one sql statement if it is not, and a line in the are that handles adding friends to spoil the key if their friends list changes (you could try updating it, but why, just let it be regenerated on their next http request). Finally, you have to generate the keys for the (article_id, friend_id) pairs on each page view, and do a multi_get from memcached. Step 2 would require an asynchronous process, so would be more complex. I could implement step 1 in an hour or so if familiar with the digg codebase, and step 2 in perhaps 2 days, however if they have other async processes that occur when a user logs in that you could integrate this with it could take as little as an hour or two as well, since the logic is dead simple, it is the mechanics of running a process to do it that is time consuming. Finally, you would have to figure out how much memory you would need to store N days of digs (users with no friends do not count in this). I believe it would not be very much.
- mikeryan 17y agoThis is weird to me. "We started thinking seriously about deploying Cassandra in production around three weeks ago. After looking at the site for something that would be a good fit, we settled on green badges." It seems completely baffling to me that someone would go out and compare different db solutions, pick one and THEN try to find a way to fit it on their site architecture.
- jbellis 17y agoI read that as, "which feature is easiest to port from the existing mysql solution?" Which is a reasonable question to ask, given how different the two databases are.
- mikeryan 17y agoMy process would be this. 1. Decide that mysql (or other RDB) is problematic. 2. Decide which features cause the most pain (List them with the most painful on top) 3. Discover which alternative db solutions would do the best in alleviating the top issues.
- jbellis 17y ago4. Start implementing, starting with the most-improvement-for-least-effort. I'm saying the two lists are not mutually exclusive. :)
- imajes 17y agoAnyone from digg here? I'd love to know how long it took to build that dataset the first time. In other words: what's the recovery window like to reset that size dataset?
- Quarrelsome 17y agoBut surely that's broken. If I dig something but then add a friend AFTERWARDS, they wont see the shield as the bucket for my digg didn't contain their user id at write time. Am I missing something?
- by 17y agoWhy does the first step "Query Friends for all my friends" take 1.5 seconds? I am struggling to understand this. If this simple table of say 100,000,000 rows is indexed on userid and we are only reading and returning say 200 rows for a particular userid what makes it so slow?