Architecture decisions · Performance and scale
Tenants of very different sizes in one system
A few large customers generate most of the load, one heavy job slows everyone, and a prospect asks how their data is kept apart from others'.
01
How it is diagnosed
Find which tenants and which tables carry the load, measure the others' p95 while the heaviest runs its job, and run one query as two tenants to see what comes back.
02
The options, side by side
03
What decides between the options
How unevenly the load is spread, whether any customer requires physical separation, and whether some users work across tenants.
| What decides | A Shared database, rows tagged by tenant | B A database per tenant | C Hybrid: shared by default, a heavy tenant's lines in a database of their own |
|---|---|---|---|
| One tenant's heavy job The other tenants should not feel it. | limited The other tenants' slowest requests get slower: in the lab, their p95 rose almost eightfold. | suits it Isolated: the other tenants do not feel it. | suits it Isolated: once its lines move, the others are back to their baseline. |
| Where the boundary is enforced A security review asks, and the answer should be a test. | needs work Row-level security and a two-tenant test. | suits it Physical: separate databases. | needs work Row-level security in both places, and the same test. |
| Users who work across tenants An accountant with many clients needs one list of deadlines. | suits it One query, as a reviewed exception. | limited One query per database, combined afterwards. | suits it One query in the shared database. |
| What there is to run Every database is one more migration, backup and alert. | suits it One database. | limited One per customer. | needs work Two, and the automation for more. |
One tenant's heavy job A B C
The other tenants should not feel it.
- A · Shared database, rows tagged by tenant limited The other tenants' slowest requests get slower: in the lab, their p95 rose almost eightfold.
- B · A database per tenant suits it Isolated: the other tenants do not feel it.
- C · Hybrid: shared by default, a heavy tenant's lines in a database of their own suits it Isolated: once its lines move, the others are back to their baseline.
Where the boundary is enforced A B C
A security review asks, and the answer should be a test.
- A · Shared database, rows tagged by tenant needs work Row-level security and a two-tenant test.
- B · A database per tenant suits it Physical: separate databases.
- C · Hybrid: shared by default, a heavy tenant's lines in a database of their own needs work Row-level security in both places, and the same test.
Users who work across tenants A B C
An accountant with many clients needs one list of deadlines.
- A · Shared database, rows tagged by tenant suits it One query, as a reviewed exception.
- B · A database per tenant limited One query per database, combined afterwards.
- C · Hybrid: shared by default, a heavy tenant's lines in a database of their own suits it One query in the shared database.
What there is to run A B C
Every database is one more migration, backup and alert.
- A · Shared database, rows tagged by tenant suits it One database.
- B · A database per tenant limited One per customer.
- C · Hybrid: shared by default, a heavy tenant's lines in a database of their own needs work Two, and the automation for more.
04
What the work looks like
The step of the offer where a case like this usually starts:
03
Architecture assessment
Findings, risks, options and next steps, in writing. A good starting point when the scope is not yet clear.
05
Articles that show this
Is this your case?
Send it with this problem already selected; the next page asks which options you considered and a little context. No verdict on your system: that only comes once I understand it.
Or write to me directly at contacto@danielcolaco.pt.