AW Dev Rethought

✂️ Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away - Antoine de Saint-Exupéry

Architecture Realities: The Hidden Cost of Multi-Tenancy


Multi-tenancy is the default for anything sold as a service, and the reasons are good. One deployment to run. One database to back up. One version of the code. Adding a customer costs almost nothing, which is the whole business model.

The savings arrive on day one and are easy to see. The costs arrive later and are spread across incidents, support tickets and engineering time, so nobody adds them up. Sharing infrastructure between customers means sharing failure, load and risk between them too. The architecture pays for its efficiency in places that don’t show on the cloud bill.


One Tenant’s Bad Day Is Everyone’s

In a shared system, capacity belongs to whoever uses it first. One customer runs a bulk import, fires a badly written report, or gets hit by a traffic spike of their own. Their load lands on the same database, the same queue and the same worker pool as everyone else’s.

The other customers see slow pages and timeouts, and they did nothing to cause it. From their side, your product is unreliable. From your side, the dashboards show a healthy average, with one tenant consuming most of it.

The fix is isolation inside the shared system: per-tenant rate limits, query timeouts, separate queues, fair scheduling. Each one is real engineering work, and none of it was in the plan when “just add a tenant_id column” was the design.


Isolation Depends on Every Query

In the common shared-schema model, all customers’ rows sit in the same tables. The only thing separating them is a WHERE tenant_id = ? clause.

That clause has to be present in every query, in every code path, written by every engineer, for as long as the product lives. Miss it once and one customer sees another customer’s data. There is no partial version of that incident. It triggers breach notifications and tends to end enterprise deals.

In a shared schema, the security boundary between customers is a filter that every query must remember to apply.

The bug is easy to write and hard to catch. A new endpoint, an admin tool, a background job, an analytics export, a cache key that left out the tenant. Tests pass because test data usually has one tenant.

Teams that take this seriously move the check out of application code. Row-level security in the database, a data access layer that refuses unscoped queries, and tests that run with two tenants and assert they can’t see each other. All of that is extra work the single-tenant design never needed.


The Customer Who Outgrows the Model

Shared designs assume tenants are roughly alike. They never are. Sooner or later one customer holds forty percent of the rows and generates half the traffic.

Everything tuned for the average stops fitting. Indexes that work for a thousand small tenants perform badly for one huge one. Queries that were fine become slow for that customer only. Their data makes every migration and every backup longer for everyone.

That customer is also usually your biggest contract, so the pressure to fix it is commercial as well as technical. The usual answer is to move them to dedicated infrastructure. Now you run two architectures, and moving a live tenant between them is a migration project you had not planned to build.


Operations You Can No Longer Do for One Customer

Some of the cost only shows up when a customer asks for something simple.

Restore. A customer deletes their data by mistake and wants yesterday’s version back. Your backup is of the whole database. Restoring it would roll back every other customer too. Restoring one tenant means extracting their rows from a backup and merging them into live tables, by hand or with tooling you have to write.

Delete. A customer leaves and wants their data gone. It is spread through shared tables, indexes, caches, logs, analytics stores and backups that also hold everyone else’s.

Migrate and deploy. Every schema change and every release hits all customers at once. You can’t upgrade one tenant first to see what happens, and a bad deploy is an outage for your whole customer base.

With one tenant per database, these are routine tasks. In a shared one, each becomes a project.


Every Exception Becomes Permanent

Multi-tenancy assumes everyone runs the same product. Sales doesn’t work that way.

One customer needs a different retention period. Another needs their data kept in a specific country. A third wants a feature held back until their audit is done. Each request is reasonable and each becomes a per-tenant flag or configuration value.

Over a few years the flags multiply. The code is full of branches that exist for one customer, and no one can test every combination. You still have one deployment, but it now runs hundreds of slightly different products.

Data residency is the hardest version. A shared database lives in one region, and a customer who must keep data in another can’t be served by a flag. That requirement alone has pushed many products into running regional copies of what was meant to be a single system.


Choose It With the Costs in View

None of this makes multi-tenancy the wrong choice. For most products it is the right one, and running a separate stack per customer has heavier costs of its own.

It does mean deciding early, with the costs counted. A few things are cheap at the start and expensive to retrofit:

  • Enforce tenant scoping below the application code, so a forgotten filter fails closed.
  • Put per-tenant limits on anything shared: queries, queues, API calls.
  • Make tenant placement a routing decision from the first version, so a large customer can be moved without a rewrite.
  • Measure usage per tenant, because you can’t manage a noisy neighbour you can’t identify.
  • Decide how you would restore and delete a single tenant before a customer asks.

The first customer who needs to be treated differently will arrive sooner than expected. The design should already have a place to put them.


50 Machine Learning Algorithms Cheatsheet Most downloaded free PDF 50 Machine Learning Algorithms Cheatsheet Blueprints of Intelligence — 50 ML Algorithms decoded Download free Downloaded 455 times

If this article helped you, you can support my work on AW Dev Rethought.


Rethought Relay:
Link copied!

Enjoyed this post?

Stay in the loop

New posts + weekly digest, straight to your inbox.

or

Create a free account

  • Save posts to your vault
  • Like posts & build history
  • New-post alerts

Comments

Add Your Comment

Comment Added!


Evalora: Collect feedback from your teams & staff
AD

Evalora: Collect feedback from your teams & staff

Evalora lets you build a form, share the link or QR code, and see verified results. For companies, training teams and institutions. Free plan available.

Start free