Skip to Content
ArchitectureMulti-Tenancy

Multi-Tenancy

IOTA SDK implements multi-tenancy to serve multiple organizations (tenants) from a single deployment while maintaining complete data isolation.

Architecture Overview

Tenant Identification

Subdomain-Based Routing

Tenants are identified by subdomain:

tenant-a.iota-sdk.com → Tenant A tenant-b.iota-sdk.com → Tenant B tenant-c.iota-sdk.com → Tenant C

Tenant Resolution Flow

Data Isolation

Row-Level Isolation

The platform uses a shared database schema with row-level isolation via tenant_id. All tenant-scoped tables include a tenant_id column, and queries add WHERE tenant_id = ? so each tenant only sees their own data. There are no per-tenant PostgreSQL schemas or SET search_path switching.

Automatic Query Filtering

All database queries automatically include tenant filters:

Tenant Context

Context Propagation

Tenant ID flows through the request context:

Context Safety

Tenant context is:

  • Set once per request
  • Immutable after setting
  • Passed to all layers
  • Used in all queries

Shared Resources

Cross-Tenant Services

Some services operate across tenants:

Shared Entities

Certain entities are shared across tenants:

EntitySharingPurpose
CurrencyGlobalISO standard codes
Settings SchemaTemplateDefault settings structure
PermissionsTemplateRBAC definitions

Tenant Lifecycle

Creating a Tenant

Tenant Operations

OperationEffectAccess
CreateNew tenant record, data isolation via tenant_idSuperadmin only
SuspendBlock all accessSuperadmin only
DeleteRemove tenant data (row-level)Superadmin only
BackupExport tenant dataSuperadmin only
SettingsConfigure tenantTenant admin

Security Considerations

Data Leakage Prevention

Security Layers

  1. Authentication - Valid session/token required
  2. Tenant Assignment - User belongs to tenant
  3. Permission Check - User has required permission
  4. Query Filtering - All queries scoped to tenant

Tenant-Aware Features

Localization

Each tenant can have different defaults:

SettingScopeExample
LanguageTenantEnglish, Russian, Uzbek
CurrencyTenantUSD, UZS, EUR
TimezoneTenantUTC+5, UTC+3

Customization

Tenants can customize:

  • Branding (logos, colors)
  • Feature flags (enable/disable modules)
  • Default settings (date formats, number formats)
  • Custom fields (extend entities)

Implementation Details

Database and Migrations

The implementation uses a single shared schema and one connection pool. Isolation is row-level only (all tenant-scoped tables have tenant_id; queries use WHERE tenant_id = ?). There is no per-tenant schema switching or SET search_path. Migrations are applied once to the shared schema; a single migration history table tracks applied versions.

Performance Considerations

Connection Pooling

  • Single shared pool across all tenants
  • No per-tenant connection or schema context

Query Optimization

  • Include tenant_id in indexes for tenant-scoped tables
  • Consider partitioning by tenant_id for tables that exceed measurable thresholds (for example, more than 100 million rows or 100GB) or when per-tenant query/maintenance latency degrades beyond acceptable limits

Best Practices

  1. Never Bypass Tenant Context - Always use middleware and include tenant_id in WHERE clauses
  2. Test with Multiple Tenants - Ensure isolation in tests
  3. Monitor Per-Tenant - Track usage and performance per tenant where needed

Next Steps

Last updated on