> ## Content Index
> Fetch the complete content index at: https://www.stirup.si/llms.txt
> Use this file to discover other available public pages before exploring further.

# LokaDB's Architecture for Data Isolation in SaaS Environments
- URL: https://www.stirup.si/lokadb-s-architecture-for-data-isolation-in-saas-environments-7c3eab03/
- Published: 2026-11-03T13:10:03.000Z
- Updated: 2026-11-03T13:10:03.000Z
- Description: LokaDB isolates SaaS client data by storing each organization's rows in separate Postgres databases, reducing overhead and enhancing security through partitioned tables and secure tunneling.
- Author: Satish Das
- Tags: Community, News, Stirup Research

## LokaDB's Architecture and Functionality

LokaDB's architecture is designed to isolate data by organization, ensuring that each SaaS client's rows are stored in a separate Postgres database. This approach allows organizations to maintain control over their data while reducing the overhead of managing a monolithic database. According to LokaDB, the system converts selected tables from your cloud database into partitioned tables, organized by organization, without duplicating rows. This method preserves data integrity and minimizes storage usage. For organizations located far from the cloud, LokaDB's proxy can route database statements directly to the organization's local Postgres instance through a secure tunnel, bypassing the need for additional round trips typically required by postgres\_fdw. This optimization enhances performance and reduces latency for distributed teams. The system leaves all other data in the original cloud database, ensuring that only the necessary information is moved and managed separately.

## Implementation and Usage Scenarios

LokaDB is implemented as a relay and agent system that works with any application using Postgres over its protocol, regardless of language or ORM. The only change required is the connection string, which directs traffic through LokaDB's infrastructure. Currently in early production at KeepPlain, a Laravel SaaS built on Postgres, LokaDB separates each client's data into its own Postgres database. This approach enhances isolation and security by ensuring that one client's data does not interfere with another's. Usage scenarios include SaaS platforms that require strict data separation, such as multi-tenant applications where each tenant's data must be isolated for compliance or performance reasons. A quickstart example demonstrates how one command can spin up a cloud Postgres instance, set up an organization's database behind the relay and agent, and use a small application to manage data migration between organizations.

## Performance and Benchmarking

LokaDB's performance was evaluated across seven distinct servers, ensuring accurate benchmarking without the constraints of Docker. The cloud database, proxy, relay, and four organization-specific databases operated under varying configurations, with round-trip times ranging from 0.19 to 43.3 ms. According to [Hacker News Show](https://github.com/lokadb/lokadb?ref=stirup.si), these measurements were conducted in a distributed environment, emphasizing real-world conditions. A Django application with 16 clients experienced a 5–10% slowdown when using LokaDB compared to a standard setup, as noted in [Hacker News Show](https://github.com/lokadb/lokadb?ref=stirup.si). However, LokaDB's built-in connection pool significantly improved performance, achieving 2,795 requests/s — approximately twice the rate of a direct Postgres connection (1,321 requests/s), as stated in [Hacker News Show](https://github.com/lokadb/lokadb?ref=stirup.si). These results highlight the trade-offs between isolation and performance in distributed database architectures.

## Security and Isolation Model

LokaDB's security and isolation model is designed to ensure that each SaaS client's data is stored in a separate Postgres database, minimizing the risk of cross-tenant data exposure. According to the security model, rows from a specific organization are stored exclusively in that organization's database, providing a clear separation of data at rest. However, a direct connection to the cloud database bypasses the proxy, allowing visibility into all organizations' rows, similar to a non-LokaDB setup. To mitigate this, LokaDB supports end-to-end TLS encryption from the cloud to the customer database, ensuring that the relay only sees ciphertext. This approach enhances privacy by preventing intermediate systems from inspecting plaintext data. These measures are described in the security model documentation and are attributed to the LokaDB team's design choices.

## Limitations and Non-Isolated Components

LokaDB does not isolate certain components of your application, including caches, queues, search indexes, files, logs, and error reports. Additionally, backups and replicas made before the migration are not isolated either. On the fdw profile, rows in transit through the cloud Postgres—such as those in memory, temporary files, or logs when `log_statement` is enabled—are also not isolated. This means that while LokaDB isolates data at the database level, other parts of your infrastructure may still share resources across organizations. The architecture includes a proxy that routes SQL statements to either the cloud Postgres or the customer's local Postgres instance, depending on the profile configuration. The fdw profile sends all statements to the cloud Postgres, which then uses `postgres_fdw` to access the organization's data. The fdw+direct profile sends statements that only touch an organization's tables directly to its database, while others go through the cloud. The direct profile avoids using `postgres_fdw` entirely, requiring the application to name the organization explicitly.

## Sources and reporting notes

- [Hacker News Show](https://github.com/lokadb/lokadb?ref=stirup.si)

Based on published source material. No independent hands-on testing is claimed.