<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: PecRodrigues</title>
    <description>The latest articles on DEV Community by PecRodrigues (@pecrodrigues).</description>
    <link>https://dev.to/pecrodrigues</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3927292%2F3926554c-756d-4e1f-bf74-ad970b222fdc.jpg</url>
      <title>DEV Community: PecRodrigues</title>
      <link>https://dev.to/pecrodrigues</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pecrodrigues"/>
    <language>en</language>
    <item>
      <title>Why tenant isolation should not live only in application code</title>
      <dc:creator>PecRodrigues</dc:creator>
      <pubDate>Tue, 12 May 2026 15:40:04 +0000</pubDate>
      <link>https://dev.to/pecrodrigues/why-tenant-isolation-should-not-live-only-in-application-code-1i6b</link>
      <guid>https://dev.to/pecrodrigues/why-tenant-isolation-should-not-live-only-in-application-code-1i6b</guid>
      <description>&lt;p&gt;Most SaaS applications start with a simple and familiar multi-tenant model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;one shared backend&lt;/li&gt;
&lt;li&gt;one shared runtime&lt;/li&gt;
&lt;li&gt;one shared process&lt;/li&gt;
&lt;li&gt;tenant separation handled mostly by application code&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;tenant_id&lt;/code&gt; column or some equivalent logical boundary&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This model works well in many cases, especially at the beginning.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is simple.
&lt;/li&gt;
&lt;li&gt;It is cheap.
&lt;/li&gt;
&lt;li&gt;It is fast to build.
&lt;/li&gt;
&lt;li&gt;It fits naturally into most web frameworks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But as a SaaS product grows, especially when it becomes white-label, extensible, or customer-specific, this approach can become fragile.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A bug in one tenant can affect others.
&lt;/li&gt;
&lt;li&gt;A bad customization can break the whole service.
&lt;/li&gt;
&lt;li&gt;A plugin or custom app can access more than it should.
&lt;/li&gt;
&lt;li&gt;A single shared process can increase the blast radius of failures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At some point, tenant isolation stops being only an application concern. It becomes an operational concern too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Logical multi-tenancy is not enough for every case
&lt;/h2&gt;

&lt;p&gt;Logical multi-tenancy usually means that the application is responsible for keeping tenants separated. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;single backend process
 └── all tenants
     ├── tenant A
     ├── tenant B
     └── tenant C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application checks the current tenant, filters data, applies permissions, and makes sure one customer does not access another customer's resources.&lt;/p&gt;

&lt;p&gt;That is a valid architecture. But it depends heavily on the correctness of the application code.&lt;/p&gt;

&lt;p&gt;If the code forgets a tenant filter, exposes the wrong file path, shares state incorrectly, or loads unsafe custom behavior, the runtime itself does not provide many additional boundaries.&lt;/p&gt;

&lt;p&gt;The tenants are logically separated, but operationally close.&lt;/p&gt;

&lt;h2&gt;
  
  
  The blast radius problem
&lt;/h2&gt;

&lt;p&gt;In infrastructure and security discussions, "blast radius" means the amount of damage a failure or compromise can cause. In a traditional shared-runtime SaaS setup, the blast radius can be large:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;one process fails
 └── every tenant may be affected
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is not always a problem. For small systems, internal tools, or products with limited customization, a shared process can be perfectly reasonable.&lt;/p&gt;

&lt;p&gt;But for SaaS platforms with white-label clients, tenant-specific apps, plugins, custom domains, or stronger isolation needs, the model starts to feel risky.&lt;/p&gt;

&lt;p&gt;The question becomes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Should tenant isolation live only inside the application code?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I do not think it always should.&lt;/p&gt;

&lt;h2&gt;
  
  
  Runtime-level tenant isolation
&lt;/h2&gt;

&lt;p&gt;An alternative approach is to move part of tenant isolation into the runtime layer.&lt;/p&gt;

&lt;p&gt;Instead of running all tenants inside the same process, each tenant can have stronger runtime boundaries. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;runtime supervisor
 ├── tenant A process
 │   └── isolated app workers
 ├── tenant B process
 │   └── isolated app workers
 └── tenant C process
     └── isolated app workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This does not mean replacing application-level security.&lt;/p&gt;

&lt;p&gt;You still need authentication, authorization, input validation, database permissions, and good software design.&lt;/p&gt;

&lt;p&gt;But the runtime can help reduce the consequences of mistakes. A tenant can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;its own process&lt;/li&gt;
&lt;li&gt;its own restricted system user&lt;/li&gt;
&lt;li&gt;its own filesystem boundary&lt;/li&gt;
&lt;li&gt;its own domain configuration&lt;/li&gt;
&lt;li&gt;its own network access rules&lt;/li&gt;
&lt;li&gt;isolated app workers inside the tenant&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This creates a second layer of protection.&lt;/p&gt;

&lt;p&gt;The application still knows about tenants, but the operating environment does too.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this is not
&lt;/h2&gt;

&lt;p&gt;This is not the same as saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Everyone should stop using shared multi-tenancy."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That would be wrong.&lt;/p&gt;

&lt;p&gt;Shared multi-tenancy is useful, efficient, and appropriate for many SaaS products.&lt;/p&gt;

&lt;p&gt;This is also not a claim that process-level isolation replaces containers, VMs, Kubernetes, or cloud-native infrastructure.&lt;/p&gt;

&lt;p&gt;A well-configured container or VM setup can provide stronger isolation boundaries.&lt;/p&gt;

&lt;p&gt;The goal here is different:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;reduce operational risk and provide stronger default boundaries for multi-tenant SaaS applications without forcing every project to start with a full container orchestration stack.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It is a middle layer between simple application-only tenancy and heavier infrastructure isolation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this matters for white-label SaaS
&lt;/h2&gt;

&lt;p&gt;White-label SaaS products often need more than basic tenant separation.&lt;/p&gt;

&lt;p&gt;Each customer may need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a custom domain&lt;/li&gt;
&lt;li&gt;different branding&lt;/li&gt;
&lt;li&gt;custom configuration&lt;/li&gt;
&lt;li&gt;specific integrations&lt;/li&gt;
&lt;li&gt;isolated extensions or apps&lt;/li&gt;
&lt;li&gt;safer failure boundaries&lt;/li&gt;
&lt;li&gt;controlled access to external resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In these cases, the tenant is not just a row in the database.&lt;/p&gt;

&lt;p&gt;The tenant starts to look more like an operating environment.&lt;/p&gt;

&lt;p&gt;That is the kind of scenario where runtime-level isolation becomes interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I am building
&lt;/h2&gt;

&lt;p&gt;I am building an open-source project called &lt;strong&gt;Ehecoatl&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Ehecoatl is a backend runtime for multi-tenant and white-label SaaS applications.&lt;/p&gt;

&lt;p&gt;The goal is to make tenant isolation more structural, not only logical.&lt;/p&gt;

&lt;p&gt;As an early proof of concept, the Ehecoatl website, the documentation site, and the newsletter system are already running on top of this runtime.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(That does not mean the project is production-ready for every use case yet, but it helps validate the core idea in a real environment: serving public pages, routing domains, loading app configuration, and operating small isolated app contexts.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of treating multi-tenancy only as something the application framework must handle, Ehecoatl treats it as a runtime and operational concern too.&lt;/p&gt;

&lt;p&gt;The current direction includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tenant process supervision&lt;/li&gt;
&lt;li&gt;filesystem isolation&lt;/li&gt;
&lt;li&gt;restricted system users&lt;/li&gt;
&lt;li&gt;tenant and app configuration scanning&lt;/li&gt;
&lt;li&gt;multi-domain routing&lt;/li&gt;
&lt;li&gt;isolated app workers&lt;/li&gt;
&lt;li&gt;safer defaults for SaaS and white-label environments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The experience I am aiming for is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;less friction to provision, operate, and monitor tenants; more safety to experiment with customizations without increasing the blast radius too much.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  A simplified mental model
&lt;/h2&gt;

&lt;p&gt;Instead of thinking about a SaaS app like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;application
 └── tenants separated only by app logic
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ehecoatl tries to move toward this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;runtime
 ├── tenant environment
 │   └── app workers
 ├── tenant environment
 │   └── app workers
 └── tenant environment
     └── app workers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The runtime becomes responsible for part of the isolation model.&lt;/p&gt;

&lt;p&gt;The application still handles business logic.&lt;/p&gt;

&lt;p&gt;The infrastructure still handles machine-level security.&lt;/p&gt;

&lt;p&gt;But the tenant boundary becomes more explicit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just use containers?
&lt;/h2&gt;

&lt;p&gt;Containers are a very reasonable answer.&lt;/p&gt;

&lt;p&gt;For many teams, they are the right answer.&lt;/p&gt;

&lt;p&gt;But they also introduce operational complexity, especially for small teams, solo builders, agencies, and early-stage SaaS products.&lt;/p&gt;

&lt;p&gt;The idea behind Ehecoatl is not to compete directly with container orchestration.&lt;/p&gt;

&lt;p&gt;It is to provide a simpler runtime model for cases where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;full orchestration feels too heavy&lt;/li&gt;
&lt;li&gt;app-only isolation feels too weak&lt;/li&gt;
&lt;li&gt;tenants need stronger operational boundaries&lt;/li&gt;
&lt;li&gt;white-label environments need easier provisioning&lt;/li&gt;
&lt;li&gt;custom apps or extensions need safer execution boundaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is a trade-off.&lt;/p&gt;

&lt;p&gt;This approach is not perfect isolation.&lt;/p&gt;

&lt;p&gt;But it can be a practical improvement over putting every tenant inside one shared process with only logical checks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Current status
&lt;/h2&gt;

&lt;p&gt;Ehecoatl is still early, but it is not only a design document.&lt;/p&gt;

&lt;p&gt;The project is already being used to serve:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the main Ehecoatl website&lt;/li&gt;
&lt;li&gt;the documentation site&lt;/li&gt;
&lt;li&gt;the newsletter system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is currently my first proof of concept and experimentation environment.&lt;/p&gt;

&lt;p&gt;It allows me to test the runtime with real routing, real domains, real static and dynamic pages, app configuration loading, and operational behavior outside of a purely local demo.&lt;/p&gt;

&lt;p&gt;There is still a lot to harden before I would describe it as generally production-ready, especially around security review, documentation, installation flow, and broader testing.&lt;/p&gt;

&lt;p&gt;But the core runtime is already serving the project around it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open questions
&lt;/h2&gt;

&lt;p&gt;I would love feedback from other developers and SaaS builders.&lt;/p&gt;

&lt;p&gt;Some questions I am thinking about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Would you use process-level tenant isolation in a multi-tenant SaaS project?&lt;/li&gt;
&lt;li&gt;In which scenarios does this model make sense?&lt;/li&gt;
&lt;li&gt;At what point would you prefer containers, VMs, or Kubernetes instead?&lt;/li&gt;
&lt;li&gt;What would you expect from a multi-tenant runtime before trusting it?&lt;/li&gt;
&lt;li&gt;Should this kind of tool be a standalone runtime, a framework companion, or a deployment layer?&lt;/li&gt;
&lt;li&gt;Where do you think this approach can fail?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/ehecoatl/core" rel="noopener noreferrer"&gt;https://github.com/ehecoatl/core&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docs:&lt;/strong&gt; &lt;a href="https://docs.ehecoatl.com.br" rel="noopener noreferrer"&gt;https://docs.ehecoatl.com.br&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://ehecoatl.com.br" rel="noopener noreferrer"&gt;https://ehecoatl.com.br&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final thought
&lt;/h2&gt;

&lt;p&gt;Application-level tenant checks are necessary.&lt;/p&gt;

&lt;p&gt;But for some SaaS products, they are not enough.&lt;/p&gt;

&lt;p&gt;As soon as tenants start needing custom behavior, custom domains, isolated apps, or stronger operational guarantees, it becomes worth asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;what should the runtime know about tenancy?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the question I am exploring with Ehecoatl.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>saas</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
