241 points · by ksec · 3y ago · 120 comments
That's like 10 tall servers for their peak QPS? (500k QPS on slide 19)
Lots of natural sharding points here too: company, game, usage of data, etc.
This is assuming you avoid or go light on expensive features like foreign keys (as Vitess already does).
The "scale magic" in Spanner (Big Table) inspired DB's are just hidden automation of traditional sharding-
CockroachDB: Sharded indexes, then runs map reduce for you.
Scylla/Cassanda: Sharded indexes again, but more limitations for speedups: Eventually consistent. You don't have fast delete- only update (discord uses tombstones). JOIN's are "in app" only.
Vitess: Proxy that dismantles/routes your query to the correct server. This scales, but is eventually consistent. JOIN's on co-located data, or "in app".... in simple terms, Vitess is like an externally managed "in app" query parser/router.
In theory a distributed SQL database can be a huge developer win because of this. Of course there are usually other tradeoffs to consider as well.
In my experience me this isn't close to being possible with a single Postgres box. There is no way around sharding this workload.
Vitess has different consistency models, it's not as eventually consistent as you describe.
Which is a huge downside.
> But so what, at least it's fast
So is an RDBMS for most read/write workloads. Few will see an overall benefit from Cassandra and the labor needed to replicate the conveniences offered by an RDBMS.
> it's about storing data
It's not about storing data, it's about using data to accomplish business objectives with the promises that entails. You opt for something like Cassandra/Scylla because it solves a technical challenge otherwise untenable or more expensive, but it's a poor choice if your problem is reasonably solved with what Postgres can offer.
The main issue I've run into is deployment. It's just very rough compared to CockroachDB or Postgres, which are single binary or very close to it.
If ScyllaDB became as easy to set up as CockroachDB (or close-ish), they'd have a lot more users, I think.
You can make Postgres setup this easy: https://gist.github.com/gnat/cfe3754c3dc817c7fb8b2225ef4db62...
CockroachDB, also dead easy: https://www.cockroachlabs.com/docs/v22.2/start-a-local-clust...
ScyllaDB is an enormous mess of daemons and ports: https://university.scylladb.com/courses/scylla-operations/le...
There is a middle ground, storage systems/databases that both scale and provide strong consistency. FoundationDB, Citus, etc.
SQL databases are not only easier to query, but also enforce data consistency. While querying is their core job, it's hardly the only one.
That’s a pretty big one. If you know you need the scale, the trade off might be worth it. But I’m 99% of projects, Postgres is more than adequate and has great flexibility.
* Low volume, complicated queries
* High volume, simple queries
In the rare case that I've seen high volume, complicated queries it generally involves a lot of pre-indexing, denormalization, and exotic data structures.
Postgres really shines in the first case, which is probably the dominant case for "data important enough to pay people to work on".
Data is divided into chunks and the routers route queries based on where your query lands on chunk ranges.
It is amazing what Vitess / PS will help you accomplish but they don't talk a lot about tradeoffs you make to get there (which are similar to what you face with sharding MySQL without additional tooling).
For example, a multi-tenant application could have a tenants table with PK id, and an orders table with PK (tenant_id, id), and a FK from orders(tenant_id) to tenants(id). Then CockroachDB would keep the orders with tenant_id = 123 in the same machine where the tenant with id = 123 was.
I have the impression they deprecated interleaved tables, but I can't find more info about it.
https://github.com/cockroachdb/cockroach/issues/52009
Not only deprecated, but completely removed a few years ago as seen in:
I stumbled upon your DB service several times, and considered it several times suggesting it as the DB of choice for my customers (uxwizz.com), but the pricing is a bit confusing/hard to estimate in my case, which makes it hard for me to recommend it. Any suggestions?
Now that Vitess has native schema change tools it's more reasonable to revisit user-friendly, out-of-the-box foreign key support.
I'm also going to disagree with you a little, again on the issue of reading, if you have foreign keys then you can do optimisations like cutting out chunks of joins. Adding constraints means you know more which you can feed to the optimiser which means often you can get better performance (read performance, that is).
As to why you can't really have foreign keys, basically, sharding schemes like this sit at an intermediate layer between the application and the various DB clusters that are the shards. You CAN have strong data consistency (and useful foreign keys) within a shard because it's all inside a single database; however across shards, you CAN NOT. The sharding layer doesn't perform checks for you, so if you have two logical tables that are partitioned differently across the shards, you can't have a foreign key that will be enforced correctly as the foreign key of a given row in one table may live on a different shard in the other table. The local database within the shard would reject the insert. Transactions across shards can also be tricky to impossible.
You're conflating the concept of a normalized database with insanely slow DB-enforced referential integrity/foreign keys.
Toy example? Sure. Take a well-formed 3NF schema and disable foreign key constraints.
I think it's good practice to enforce consistency rules both in the DB and in code. If you make a mistake in your code, the DB won't allow it, and vice versa.
Plus, relational databases don't just sit under a single application. There's usually multiple applications/services talking to them. Worse, humans connect to them an do all sorts of things they shouldn't do. That's the whole point of managing referential integrity in the DBMS, since you can only control "just write good code" across so many application domains.
Of course whether the performance tradeoff is worth it is a complicated decision for many of the reasons people have mentioned. But in 20 years of working with relational databases at big companies, I've seen few examples where the performance win exceeded the business risk.
> ● SQL query compatibility
> ● Minimal changes to the application
> ● Runs MySQL in backend
> ● Kubernetes native
> ● Provides Kubernetes operator
> We evaluated multiple candidates and chose Vitess
https://github.com/vitessio/vitessBut it's very light on numbers and doesn't show trade-offs or anything.
Would love to hear more about this implementation
Just trying to do basic scaling or other simple tasks sounded like an utter nightmare on their old system. Having autonomic computing at their back seems like an obvious win. Tell it your desired state & let the controller do the job.
The new paradigm for computer operations is so wonderful.
To me this is validation that going the SQL route in almost 99% of new apps is the right way to go. It will be a rare case that you won't be able to scale out given how mature some of these technologies are.
There are very few things that structured NoSql can't do if you ignore reporting. Once you scale out traditional SQL, you aren't going to be using it for reporting either way though.
Automating master failover on MySQL without a human in the loop - in the topology GitHub used back then - is risky.
0: https://github.blog/2018-10-30-oct21-post-incident-analysis/
* How did you tune Vitess for resiliency? What were the tradeoffs and how was the performance?
* How did you migrate from shared in app config to single DB endpoint? (this is an issue we are facing right now)
* What do you mean by some queries being too shard aware? How did you optimize queries for efficient routing with Vitess?
At 30 TBs the hot data set is huge an there is a long tail of queries not loaded into memory.
Plus they were saying 10k+ connections per server. So we are probably looking st 500k+ connections.
There is also a regular influx on unoptimized / badly written queries as people add features/games etc. Plus you can end up with random spikes.
This setup is likely optimized for high read availability. The slides mention the mental overhead of failovers. This is a thing. Try to explain and help each team understand how to do those safely. Downtime are also not an option.
So there is quite some information and context (likely) missing. I used to manage a similar scale zoo of MySQL (similar peak QPS, less total data iirc). I am not sure I would subscribe so much on the Vitess as solution side though. Galera and Group Replication can give you hassle free failovers, add some read replicas and you have a really nice DB setup that can scale horizontally amd vertically until you hit the write limitations per server.
But I think the industry are being pushed hard and dont have much time to produce content for our reading interest.
I would have liked a bit more specifics on their manual sharing solution, and how the vitess implementation differs.
I do feel safe in saying though that the login queues are _definitely_ not hype.
They're designed to constrain a quite-complex distributed system to a login rate that has been load-tested thoroughly, e.g. they know it'll work at that rate.
Those queues are usually the result of intentional capacity planning. Overprovisioning is expensive.
I'd imagine they could spin up new servers on demand.
I always found disabling FK checks weird, as in, once you disable them, isn't the integrity permanently lost? Or does it check again the integrity once it's reactivated?
So it's a story of people who used Kubernetes and MySQL and continued to use Kubernetes and MySQL. The end.
We had no way to have that kind of confidence about migrating off MySQL to an entirely different database (like TiDB). If we'd been addressing a new storage use case from scratch instead of migrating an existing one, the case for using something other than MySQL might have been stronger.
Thanks for the list (and the graph), very interesting!