For a long time, the SaaS platform I worked on ran the way many B2B products start out: every customer got their own deployment of the same monolith, with its own configuration and its own data. Around a hundred of them. It was simple to reason about and it gave every tenant perfect isolation, but over the years it became the single biggest drag on the team.
Over two years I was the main backend engineer on the effort to break that monolith up, extracting five business-critical domains into standalone multi-tenant services: Cases & Targets, IAM, Billing, Notifications and Reporting. Each one is deployed once and shared by every tenant. This post is about why we did it, what had to be got right, and what I would tell anyone looking at the same move.
Why one-deployment-per-tenant stops scaling
The problems were never about one deployment. They were about a hundred of them:
- Every release was a hundred releases. Rolling out a fix meant upgrading every tenant, and something was always a version or two behind.
- Configuration drift. Small per-customer tweaks accumulated until no two environments were quite the same, and bugs became “only happens for that one customer”.
- Cost. Most tenants were idle most of the time, but each one still paid for its own baseline of infrastructure.
- Onboarding. A new customer meant provisioning a new stack instead of inserting a row.
Splitting the monolith, not just sharing it
We could have made the monolith itself multi-tenant and kept running it as one big shared deployment. Instead we used the migration to draw proper boundaries. Each business area we extracted (cases and targets, identity and access, billing, notifications and reporting) became its own service with its own data, communicating through events on Kafka rather than shared tables. That made each service small enough for one engineer to own end to end, and let us move and release them independently.
It also meant the migration could happen one service at a time while the old system kept running, with new features still being delivered alongside it.
Tenant isolation is a feature, not an afterthought
The biggest fear in a migration like this is data leaking between customers. Separate deployments gave that isolation for free; in a shared system it has to be designed in. The rules I would insist on:
- Tenant context comes from authentication, never from the request body. Once a request is authenticated, the tenant is fixed for its whole lifetime, including any async work it triggers.
- Scope data access in one place. Filtering by tenant has to be the default behaviour of the data layer, not something every developer remembers to add to every query.
- Events carry the tenant too. In an event-driven system, a message without a tenant identifier is a bug waiting to happen.
- Test for leaks explicitly. Tests that create two tenants and try to read across them catch mistakes long before a customer does.
The data is the hard part
The unglamorous part was the data: years of per-tenant configuration and records that had quietly diverged. A large part of the work was simply understanding and normalising those differences before anything could move.
Watch out for noisy neighbours
Sharing infrastructure means one busy tenant can slow everyone else down. Rate limits, fair handling of background work and metrics broken down by tenant are what turn that from a scary unknown into something you can see and manage.
What I would tell anyone considering it
- Decide your isolation model on day one and enforce it in the framework, not by convention.
- Use the migration to draw service boundaries, not just to share the old code.
- Migrate incrementally, with the old system still running, rather than in one big-bang release.
- Invest early in per-tenant observability; it pays for itself during the migration and long after.
- Expect the data, not the code, to be the hard part.
Extracting those five services from a hundred per-tenant deployments was one of the most rewarding projects of my career. For the extracted services, a release became one event instead of a hundred, and the team could spend more of its time on the product instead of on keeping environments in sync.
0 Comment
-
Be the first to comment