3 ms·
Biggest reason not to run multiple database instances on a single bit of hardware - ram. Say you're running on a VM with 16gb of ram, and one of your clients i
by falcolas 10y ago
Biggest reason not to run multiple database instances on a single bit of hardware - ram.
Say you're running on a VM with 16gb of ram, and one of your clients is particularly active with a 10gb of data and constant usage of that dataset. If you colocate that customer with five other customers using individual processes, at most your star customer will be able to house about 3gb of their dataset in memory.
On the flip side, if you have all five customers in one DB instance, then that one customer can house all 10gb of their data in working memory, making it much more performant.
You're hamstringing your DB processes by running one instance per set of databases. Run them all in one process, and you will get much more bang for your infrastructure buck.
- ec109685 10y agoThe limitation of the approach you are advocating is that all databases would need to replicate from the same master, which isn't always practical.
- falcolas 10y agoGiven the choice between performance and ease of replication, the businesses I worked for always chose performance at scale. Perhaps that skews my expectations, but given how much DB performance affects overall app performance, it trumps most other considerations.
- collyw 10y agoIsn't that one advantage of Docker over VM's is that you have access to all of the RAM in a container while you don't in a VM? (I may well be wrong about that).
- vidarh 10y agoYes, you can. If anything, one of the downsides of Docker is that vs. e.g. OpenVz or full VMs the memory accounting is still much less mature and requires additional work to enable on many distros.
- falcolas 10y agoIt's not Docker that's the issue, it's that well behaved DB software limits its memory usage to a fixed (but configurable) value. Unless you hand-tune the size of the (in this case) InnoDB buffer pools for each DB instance, the memory usage will not be as efficient. Of course, if you're hand-tuning different DB instances, you're already in trouble.
- vidarh 10y agoDoesn't work that way with containers - they can all still have access to all the memory if you are confident you can safely give them access to it (and if you're not, then you certainly can't co-locate them in the same process. But I have yet to deal with a server where adding more RAM was more than a rounding error compared to getting a fast IO subsystem. And running them all on a single server means you need to take down all of them to upgrade any one of them, and are contingent on all of them being able to run on the same database version, and with the same extensions.
- falcolas 10y ago> Doesn't work that way with containers - they can all still have access to all the memory It's not a container problem I'm summing up here, it's a DB problem. Well behaved DB software won't grow to boundless limits to manage the workload, it will grow to it's configured limits. Running multiple instances of a DB server means that each DB is going to be hard-coded to a limit which is some fraction of the available memory. > I have yet to deal with a server where adding more RAM was more than a rounding error There are limits even to this, though. The most memory you can get for any single, broadly available instance in AWS is 244 GiB, and its going to cost you an arm and a leg to run. It's not hard to create a dataset which exceeds 244 GiB in size. > take down all of them to upgrade any one of them Only if you're upgrading the actual DB software. And most time a master switch is sufficient to keep everything online through a DB version upgrade. Not to say that master switches are easy; but even Uber has that pain with their system. > all of them being able to run on the same database version, and with the same extensions. This isn't something I frequently see being an actual problem, within the same corporation.
- vidarh 10y ago> Running multiple instances of a DB server means that each DB is going to be hard-coded to a limit which is some fraction of the available memory. What you are suggesting then, is setting limits in a way that does not guarantee resources for any given database. > There are limits even to this, though. The most memory you can get for any single, broadly available instance in AWS is 244 GiB, and its going to cost you an arm and a leg to run. It's not hard to create a dataset which exceeds 244 GiB in size. Most people don't have databases that large. If you do, perhaps you shouldn't be puting multiple of them in a single instance if you're limited to machines that small. For comparison, I have servers with dozens of databases that fit into memory on machines with 64GB and less. I also have machines with single databases that need far more. If we need to, we'll provision machines with 1TB-2TB of RAM. > This isn't something I frequently see being an actual problem, within the same corporation. It's something I see all the time. Consider that "within the same corporation", people often run databases for a large number of external customers, or need to be able to roll out new versions, or do development and testing on different versions. I have at least 5 different versions of Postgress sitting on production servers right now due to customers with different requirements and different upgrade cycles. I also have several different versions of MySQL.