News for hackers. Stuff that matters.
Re:How Discord Stores Billions of Messages Using Cassandra by niftich on Thursday January 19, 2017 @08:01PM (#13440935)
These kinds of write-ups offer valuable insight into a popular project's requirements and decision-making, and are some of the most instructive resources one can find: these show not only the kinds of challenges one has to face at scale, but also how architectural choices are made.

It's far more valuable to understand why Discord uses Cassandra than to merely be aware they do.

Out of curiosity, did you consider HBase and Riak? Did you entertain going fully hosted with Bigtable? If so, what criteria resulted in Cassandra winning out?

Re:How Discord Stores Billions of Messages Using Cassandra by Vishnevskiy on Thursday January 19, 2017 @08:08PM (#13440961)
Let me take a stab at that.

Riak is not a good model since its more a blob store and we wanted to simply range scan through messages rather than sharding blobs (Cassandra is REALLY good at this).

HBase would have been fine for this model, but the open source version of HBase has much lower adoption than Cassandra so that was a big factor. We also don't care about consistency and HBase is a CP database, we prefer AP for this use case. As far as using GCP's BigTable (HBase compat), we made this decision before we moved to GCP, but we are also not fans of using platform lock-in. While BigTable has the same API as HBase we would hate to go to an less widely adopted version where we have a hard time getting community support if we decided to leave GCP.

Hope that helps.

Re:How Discord Stores Billions of Messages Using Cassandra by runeks on Thursday January 19, 2017 @11:47PM (#13441789)
> As far as using GCP's BigTable (HBase compat), we made this decision before we moved to GCP, but we are also not fans of using platform lock-in.

Did you consider GCP Datastore as well?

It has strong consistency for a single "entity group", but eventual consistency for queries on multiple entity groups.

So by storing data only relevant to a single user in an entity group, you can have strongly consistent, atomic transactions on that group (albeit limited to 1 tx/s), and at the same time do global queries on all user data with eventual consistency.

Re:How Discord Stores Billions of Messages Using Cassandra by Vishnevskiy on Friday January 20, 2017 @12:11AM (#13441847)
The pricing model does not fit our needs, and that is even more locked in than the BigTable variant.
Re:How Discord Stores Billions of Messages Using Cassandra by runeks on Friday January 20, 2017 @03:41AM (#13442438)
I'm happy to hear you dropped it for non-technical reasons, since I'm asking because I've chosen Datastore for an app because I care less about vendor lock-in than ease of operation, and it fits my pricing model perfectly, due to the app in question receiving (Bitcoin) payments that are charged a fee on a per-request/payment basis.

Hint: if you have technical reasons for avoiding GCP Datastore I'd be very interested in hearing about them

Re:How Discord Stores Billions of Messages Using Cassandra by threeseed on Friday January 20, 2017 @05:01AM (#13442691)
Google Cloud is the least geo-distributed provider around. Which is a major problem if your use case has requirements around (a) latency and (b) data locality due to legal requirements.

In 2017 they will finally have datacenters in Sydney, London, Singapore, Frankfurt etc.

Re:How Discord Stores Billions of Messages Using Cassandra by manigandham on Friday January 20, 2017 @04:47PM (#13447227)
This is one area where Azure is leading with both Azure SQL and DocumentDB supporting geo-replication.
Re:How Discord Stores Billions of Messages Using Cassandra by merb on Saturday January 21, 2017 @04:36AM (#13449502)
nope since azure is extremly expensive and also you need several accounts for different regions. i.e. you can't create servers in germany with a whole new account / credits / support.
Re:How Discord Stores Billions of Messages Using Cassandra by manigandham on Saturday January 21, 2017 @03:56PM (#13452106)
This is about capabilities, not price. Azure Germany is the only one that requires a different account due to German legal issues. The rest of the datacenters are all connected from the same account.
Re:How Discord Stores Billions of Messages Using Cassandra by germanier on Saturday January 21, 2017 @11:36AM (#13450771)
That's because Azure in Germany is not offered by Microsoft but T-Systems. Microsoft just supplies the tech. For the other regions one account suffices (I'm not sure about China where they also use a partner).
Re:How Discord Stores Billions of Messages Using Cassandra by k_bx on Friday January 20, 2017 @09:11AM (#13443832)
> Riak is not a good model since its more a blob store and we wanted to simply range scan through messages rather than sharding blobs (Cassandra is REALLY good at this).

Can you tell a little bit more please? Range scan is done by using secondary indexes (index by timestamp) in our system. I'm not sure I understood the part about blobs or some things specific to Cassandra. Reply is highly appreciated.

Re:How Discord Stores Billions of Messages Using Cassandra by manigandham on Saturday January 21, 2017 @05:01PM (#13452373)
Cassandra uses consistent hashing. A segment of data that is addressed by a key is called partition, found by the partition key. Partitions can contain just 1 "row" if you only use a single column as the key, or you can create a compound key with a part dedicated to finding the partition and the rest to finding several rows within that partition.

If you use a compound keys (multiple rows), these rows are all stored in the same partition (which all lives on the single node which owns or replicates that partition in the consistent hash ring), so scanning those rows is very fast and efficient.

Re:How Discord Stores Billions of Messages Using Cassandra by espeed on Saturday January 21, 2017 @02:51AM (#13449298)
Did you consider Scylladb (http://www.scylladb.com), a Cassandra-compatible DB written in C++ by the guys behind the KVM?
Re:How Discord Stores Billions of Messages Using Cassandra by bsg75 on Friday January 20, 2017 @11:09AM (#13444755)
> the open source version of HBase has much lower adoption than Cassandra so that was a big factor

Is this due to the availability of experienced developers or another factor?

PostgreSQL has a lower adoption rate than MySQL, but we chose it due to its suitability to the tasks at hand. As long as the adoption rate is not low enough to give concern about the longevity of a tool, I'm less concerned about it than other factors.

Re:How Discord Stores Billions of Messages Using Cassandra by gedrap on Friday January 20, 2017 @12:59PM (#13445563)
Well, relatively speaking Postgre might have lower adoption than MySQL, although I am not too sure about it. However, if you look at the absolute numbers, Postgre has huge adoption, even if it is smaller than MySQL's. So it doesn't really matter as chances are, you will able to find an experienced developer. Can't say the same about HBase, etc since there are significantly fewer projects requiring it compared to MySQL/Postgre.
Re:How Discord Stores Billions of Messages Using Cassandra by yawn on Thursday January 19, 2017 @08:38PM (#13441108)
> These kinds of write-ups offer valuable insight

I agree completely. It is frustrating that no decent books have been written regarding scaling architectures/strategies with current tooling. One has to scavenge various blog posts to try and discover ideas that might help solve their growth issues. I would love to see a book that covers scaling for app servers, RDBMSes, NoSql dbs, using queues/messaging effectively, etc. Failing that, I'd like to see something like Scalers at Work (a la Coders at Work) which would interview different devs who had to solve scaling issues.

Re:How Discord Stores Billions of Messages Using Cassandra by jjirsa on Thursday January 19, 2017 @11:04PM (#13441667)
Look for local meetups - in Seattle there's "Seattle Scalability" which is great for this sort of thing (and highscalability used to be great for this, too).
Re:How Discord Stores Billions of Messages Using Cassandra by roastbeef on Friday January 20, 2017 @06:06AM (#13442923)
is discord in seattle?
Re:How Discord Stores Billions of Messages Using Cassandra by jjirsa on Friday January 20, 2017 @11:55AM (#13445080)
No, but it's where I live, and I was using it as an example of a non-silicon-valley city where you can find scalability related meetups.
Re:How Discord Stores Billions of Messages Using Cassandra by wsh91 on Thursday January 19, 2017 @10:47PM (#13441609)
This isn't exactly what you want, but you might find both of the following books helpful.

With respect to using queues/messaging: http://www.enterpriseintegrationpatterns.com/

And with respect to understanding this stuff in general: http://dataintensive.net/

Re:How Discord Stores Billions of Messages Using Cassandra by niftich on Thursday January 19, 2017 @11:25PM (#13441720)
Not the parent, but the linked material is more foundational than the subject matter raised in the post. There is in fact an appreciable lack of good, battle-tested, non-secret, sometimes-but-not-necessarily anecdotal public info about the part of the design process where you have a working system doing fairly okay, but you know you're inches away from a very unpleasant wall. On fire [1].

It doesn't help that distributed systems are a dark art, that many open source and free-to-use tools that developers have access to gate the HA/clustering features behind steep pricing (though I sympathize it's one of the few effective ways to make money in open source), and that expertise with scaling is very often a competitive advantage.

[1] http://www.slideshare.net/iammutex/scaling-instagram/25-404i...

Re:How Discord Stores Billions of Messages Using Cassandra by wsh91 on Thursday January 19, 2017 @11:30PM (#13441739)
Totally fair. :) Parent just mentioned using queues/messaging effectively, and EIP is arguably the gold standard for that.
Re:How Discord Stores Billions of Messages Using Cassandra by di4na on Friday January 20, 2017 @02:20AM (#13442206)
http://shop.oreilly.com/product/mobile/0636920024149.do

The first part is mainly about erlang and the choices they made. But the last part is not at all specific to erlang and walk you all the way through all decisions to take to build that type of architecture.

Re:How Discord Stores Billions of Messages Using Cassandra by threeseed on Friday January 20, 2017 @05:10AM (#13442715)
I've always subscribed to the HighScalability RSS feed: http://highscalability.com