Greetings!
I'm exploring how to implement a separate database per tenant, as outlined in the following article: https://success.outsystems.com/documentation/11/app_architecture/designing_the_architecture_of_your_outsystems_applications/designing_scalable_multi_tenant_applications/#physical-segregation-of-tenants
Do you have any suggestions or best practices for achieving this?
My initial thought is to maintain an entity that stores each tenant's database connection string and switch to the corresponding database upon authentication. I'd appreciate any insights or recommendations you might have.
Thank you!
Multitenancy feature is already offered by outsystems. My making an application 'multi-tenant' you can achieve your goal. The data will be on same database, but it will behave like they are on different databases.You just need to make your modules and application 'multitenant' (Just select module/application from the right-top pane (data-tab), then you will see an option 'Is-Multitenant' in bottom right (properties pane)).For more details you can visit-: https://success.outsystems.com/documentation/how_to_guides/development/how_to_build_a_multi_tenant_application/
Hi @Arnold Ayaoan Jr
Considering Outsystems 11’s strong built-in multi-tenant support, one should only use separate databases per tenant if you have non-negotiable requirements like data residency, compliance, or enterprise SLAs. Else, the platform’s logical isolation is simpler and safer to maintain.
If you decide to proceed with per-tenant DBs, one should architect a central catalog with session-based connection switching mechanism. Also, automate provisioning and migrations.
hi @Arnold Ayaoan Jr,OutSystems does not natively support using a separate physical database per tenant within a single multi-tenant application. The platform’s built-in multi-tenancy is based on logical data isolation using TenantId and is the recommended, fully supported approach. Although it’s technically possible to switch database connections at runtime by storing tenant-specific connection strings and using platform APIs, this is considered a non-standard pattern and introduces significant complexity around deployments, schema management, and supportability. If physical data isolation is required for compliance or residency reasons, a more robust approach is to deploy separate application environments per tenant or region while sharing the same codebase
I'm agree with Jayapraksah,i also believe outSystems does not natively allow for fully dynamic DB switching at runtime.typically, you would need a separate extension for each database, or a DB-per-tenant architecture implemented through code or configuration.
@Arnold Ayaoan Jr : It is possible to store tenant data in separate external databases (one DB per tenant), but additional logic is required to route requests to the correct database at runtime.
You can use DatabaseConnection_SetConnectionStringForSession from the Platform Runtime API to override the connection string of a named external Database Connection (this does not affect the OutSystems platform/catalog database). Queries against External Entities can then run against the tenant DB as long as the override is applied before the query executes.
In Mobile/Reactive apps, this usually means setting the connection string on every request, and avoiding Screen Aggregates that execute automatically before your logic runs.
References
@Mandar Deshpande , please don't revive old questions.
Appreciate the feedback @Dorine Boudry. Since the question didn’t have an accepted answer, I thought it would be useful to add a response for future readers who may encounter the same problem.