> Consider a beefy AF bare metal SQL server, see how far that gets you.
Quite far, possibly to millions of users.
Case in point: StackOverflow runs on SQL Server.
Actually it can vary "from not that" far to "all the way" (StackOverflow). It depends very much on the schema and the type of workload. But in general people really underestimate how far an RDBMS can take you.
Yes and no - I think people also underestimate how miserable running a single giant RDBMS can be. Everything gets hard and dangerous - backup/restores, upgrades, online migrations & schema changes. Adding the wrong index can easily brings the whole thing down.
They are complicated beasts that get very fragile at the large end (size+throughput)
Re:How does database sharding work?
by ComodoHacker on Friday April 07, 2023 @01:24PM
(#35484260)
Speaking of backups, how do you get consistent backup of a sharded DB? Not everything is sharded, some data are replicated and should be consistent.
Everything becomes fragile at the large end.
well im comparing it to a natively distributed database, like for eg dynamoDB. I've worked with truly massive dynamodb "instances" and you really dont have to do much, they arent fragile, they just work. I don't necessarily know how their backup system works under the hood, but it backs up to a consistent point in time.
Re:How does database sharding work?
by KptMarchewa on Friday April 07, 2023 @12:28PM
(#35483496)
"millions of users" are vastly different scales with different use cases. StackOverflow is mostly serving cached content.
Re:How does database sharding work?
by GeneralMayhem on Sunday April 09, 2023 @02:20PM
(#35505105)
> Consider a beefy AF bare metal SQL server, see how far that gets you.
Yep, this is of course the default - although you'll at least want replication for availability and disaster recovery, but that's not too bad with PG/RDS.
> they don't just let you drop them in as a scalable replacement for an existing usage pattern, and usually sharding starts first coming up when you're at a huge scale and already have a ton of app code and database design but have grown past what a single db can support
I think once you get beyond what fits on one primary box, you're almost certainly at the point of rethinking your data access models anyway. Manual sharding is disruptive too.
It's a great option, as long as you're aware of the tradeoffs and don't expect it to act (and cost) exactly like a single Postgres server.
My order of ops generally goes:
- Can you get away with pure (or mostly) key/value for your hottest table(s) and mostly avoid queries? Use Dynamo or Google Cloud Datastore, but deeply understand their quirks (e.g. never index a timestamp field on Datastore or you're worse off than a weak-ass SQL server for write-heavy loads). These can scale basically forever with zero effort if you fit their constraints, and are cheap enough
- Can you tolerate the price of Spanner and deal with it not being normal SQL? Go for it, expect some non-trivial migration cost
- If you have to shard/cluster yourself, can you make Redis work? It'll be easier operationally than managing N SQL DBs of any kind. I know, if you could you'd probably have been fine using Dynamo...
- Can you soft-shard, e.g. use different machines for different tables and spread load enough to get each table onto a single server? Do it.
- Can you minimize re-sharding ops? (If you're in a massive growth phase, the answer is no) Ok, fine, do SQL sharding, and make sure you have well-tested code to do it and you mostly use key/value access patterns.
- Consider a beefy AF bare metal SQL server, see how far that gets you.
- If none of this applies, re-evaluate the cost ($ and time) of Spanner, you're paying a big price one way or another
- Only bad ideas from this point on, just do sharding but it'll suck...
Nowhere on my list: running your own cluster for Cassandra, Mongo, or anything similar, it's such an ops nightmare and there are hosted services that are better in every way but cost.
If you do end up writing your own sharding layer, best of luck, I have yet to see any reasonably production-ready ones that work well with pretty much any web framework or ORM. And writing these is so tough, so many edge cases to consider...not something I hope to ever do again.