Lurker News
A common way of deploying a web application database at scale is to setup a MySQL or Postgres server, create one table for all customers, and have an account_id or owner_if field and let the application code handle security. This makes it easier to run database migrations and upgrade code per customer all at once.

I’m curious if anybody has taken the approach of provisioning one database per account? This means you’d have to run migrations per account and keep track of all the migration versions and statuses somewhere. Additionally, if an application has custom fields or columns, the differences would have to be tracked somehow and name space collisions managed.
Has anybody done this? Particularly with Rails? What kinda of tools or processes did you learn when you did it? Would you do it again? What are some interesting trade offs between the two approaches?

Comments (258) 117 threads

Show all comments

Showing thread 42 of 117

wheelerwj2 replies#
Seems pretty odd. The closest example I can think of would be maybe salesforce? Which basically, as far as I can tell, launches a whole new instance of the application (hosted by heroku?) for each client. I'm not a 100% sure about this, but i think this is how it works.
snuxoll1 reply#
Not at all how Salesforce works, they take a lot of pride in their multi-tenant setup (for better or worse). Every org on a given instance shares the same application servers and Oracle cluster.

If I were to make a Salesforce competitor that’s one thing I would do differently, with tools like Kubernetes it’s a lot easier to just give every customer their own instances. Yes, it can take up more resources - but I cannot imagine the security nightmare involved with letting multiple customers execute code (even if it’s theoretically sandboxed) in the same process, plus the headache that is their database schema.

nitwit0051 reply#
Salesforce has a lot of trial or developer orgs, which would be quite expensive if you tried to host them all as some sort of VM in a cloud hosting companies.

I assume most of them end up as a few rows in some set of DBs, which is far cheaper.

snuxoll1 reply#
Salesforce charges and arm and a leg for extra sandbox instances anyway, and at that scale you aren’t paying Amazon for compute either.

A full-copy sandbox past the included one for Unlimited Edition orgs is something like 30% your annual spend.

nitwit005#
You can fill out a form and cause a free org to exist on their main site, so hundreds or thousands probably get created a day. It looks like they expire in 30 days, so if you spun up an app and DB for each it would get expensive quick.