Urgent.News

What's breaking now, across thousands of outlets.

Tech

Multi-Tenant SaaS: Shared Database or One Per Tenant?

If you are building a SaaS product for more than one customer, you will have to answer one early question: how do you separate each customer's data? The choice between a shared database and a database per tenant shapes security, cost, performance and how painful your first enterprise customer will be. I make this decision with founders as part of SaaS development work. This guide explains the…

Building a multi-tenant SaaS means carefully deciding how to isolate each customer's data. The three main approaches are:

1. Shared database with a shared schema – All tenants use the same tables, differentiated by a tenant_id column. Pros include low cost and simplicity, but cons involve the risk of accidental data exposure, difficulty backing up individual tenants, and performance degradation when one tenant dominates traffic.

2. Shared database with separate schemas per tenant – Tenants share the same database but have their own set of tables (schemas). This offers stronger data separation for backups and migrations, yet introduces complexity in managing migration and connection handling across many tenants.

3. Separate database for each tenant – Every customer gets its own database. This provides the strongest isolation for security and compliance reasons, but comes with the highest cost and operational overhead, especially as the number of tenants grows.

Key considerations when choosing:

- Customer size and nature: Many small customers often fit a shared model, while a few large or regulated customers may require separate databases.

- Compliance expectations: Some customers demand strong data separation that a shared schema can't guarantee.

- Tenant size disparity: If one tenant could be a hundred times larger than average, building in isolation from the start avoids future pain points.

- Team size: Smaller teams should opt for the simplest model that meets requirements, rather than adding unnecessary complexity.

- Growth plans: Designing for future scaling—allowing large customers to move to dedicated databases—is valuable even if the initial choice seems simpler.

For early-stage products, starting with a shared database and explicitly managing tenant_id filters is a pragmatic approach. This minimizes upfront costs and complexity while still establishing safeguards against cross-tenant data leakage. Implementations can include:

- Global scope or middleware enforcing the tenant filter automatically.

- Database-level protection like PostgreSQL's row-level security.

- Comprehensive tests to catch bugs that might bypass filters.

- Context in logs and background jobs to ensure tenant-specific operations are properly tracked.

Common pitfalls include neglecting background jobs to include tenant context, allowing shared resources (caches, indexes, files) to lack tenant-specific identifiers, and overlooking unique constraints that ignore tenant identifiers. Super-admin access must also be carefully managed and audited.

Microsoft's guidance on tenancy models highlights the balance between isolation, cost, and operational effort, making it a useful resource to accompany this decision-making process.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Kandinsky 6.0 in a pipeline: offload, the untimed default and what to measure

Say your product manager wants "generate a short video with sound" in the app. Kandinsky 6.0, which Kandinsky Lab put on GitHub on 6 October under MIT for both code and weights, is a candidate: text…

  • Kandinsky 6.0 generates short videos with sound from text or text+images.
  • Two model sizes: Lite (3B params) and Pro (29B params).
  • Lite requires much memory, Pro takes 561s for 5s clip.

Who Should Own a Client's Domain and Hosting? A Handover Checklist

If you build sites for clients, this is the setup I use on every project, and the one I'd want any client to insist on from any developer.

  • Domain name should be registered to client's business
  • Hosting should be in client's name and billed to their credit card
  • Client should have control over email, analytics, and Google Business Profile accounts

Make generation quotas safe to retry

Any web action that calls a slower service has to handle a familiar failure: the server may finish the work, but the response can disappear before the browser receives it.

  • Assign unique idempotency key to each operation to prevent duplicate work on retries.
  • Server records operation state (reserved, completed, failed) before resource-intensive tasks.
  • Timeout does not always mean no work; verify if original operation can be safely retried.

Add a skip link (Web HIG tip #11)

Load your site, click the address bar, and press Tab. Count how many presses it takes to reach the first thing in the main content.

  • Add "Skip to main content" link as first tabbable element
  • Point link to id of main content, visible on focus
  • Landmarks, headings, IDs needed for link functionality

My Free n8n Workflow Stops at the Hook. My $29 One Starts There: An Honest Diff

My Free n8n Workflow Stops at the Hook. My $29 One Starts There: An Honest Diff Part of my build-in-public series on running LLM workflows in n8n in production.

  • Free n8n workflow generates five hooks from a single topic using LLM branches
  • Paid Repurposing Engine workflow creates seven-day staggered content calendar
  • Paid workflow includes platform-specific nodes for character limits and content structure

ERA5 is already gzipped. I still made it 47% smaller — losslessly.

ERA5 is already gzipped. I still made it 47% smaller — losslessly. First, the two baselines The easiest mistake to make when you write a compressor is to quote a flattering baseline while talking…

  • ERA5 data files already compressed with gzip
  • Researcher compresses ERA5 files 47% smaller losslessly
  • Compression achieves 1.87× reduction in file size

More from Saturday 17 October →