多租户与单租户?
Multi Tenant vs Single Tenant?
我即将使用 Rail 和 Postgres 构建一个 SAAS 产品。我想知道我是否应该遵循架构级别、基于子域的多租户或单租户应用程序是否足够好架构?
我的要求在客户端之间没有数据的可靠性,因此基于模式的多租户架构对我来说似乎是正确的。谁能进一步解释一下为什么是好是坏并给出相关解释?
Here's a post from the creators of the Apartment gem 建议他们将来不会使用每个租户模式的方法。
The end result of the above mentioned problems have caused us to mostly abandon our separate schemas approach to multi-tenancy. For all services we build going forward, we use a more traditional column scoped approach and have written our own wrappers that effectively mimic the per-request tenanting approach that Apartment gave us.
如果您要部署到 Heroku,warning 关于每个租户的架构会影响托管备份工具的性能:
The most common use case for using multiple schemas in a database is building a software-as-a-service application wherein each customer has their own schema. While this technique seems compelling, we strongly recommend against it as it has caused numerous cases of operational problems. For instance, even a moderate number of schemas (> 50) can severely impact the performance of Heroku’s database snapshots tool, PG Backups.
对于最大的数据隔离,每个租户一个数据库的方法是合适的。
对于最简单的操作,每个 table 的 tenant_id
列可用于限定您的查询范围,并且可以使用 row level security policies.
强制执行
我即将使用 Rail 和 Postgres 构建一个 SAAS 产品。我想知道我是否应该遵循架构级别、基于子域的多租户或单租户应用程序是否足够好架构? 我的要求在客户端之间没有数据的可靠性,因此基于模式的多租户架构对我来说似乎是正确的。谁能进一步解释一下为什么是好是坏并给出相关解释?
Here's a post from the creators of the Apartment gem 建议他们将来不会使用每个租户模式的方法。
The end result of the above mentioned problems have caused us to mostly abandon our separate schemas approach to multi-tenancy. For all services we build going forward, we use a more traditional column scoped approach and have written our own wrappers that effectively mimic the per-request tenanting approach that Apartment gave us.
如果您要部署到 Heroku,warning 关于每个租户的架构会影响托管备份工具的性能:
The most common use case for using multiple schemas in a database is building a software-as-a-service application wherein each customer has their own schema. While this technique seems compelling, we strongly recommend against it as it has caused numerous cases of operational problems. For instance, even a moderate number of schemas (> 50) can severely impact the performance of Heroku’s database snapshots tool, PG Backups.
对于最大的数据隔离,每个租户一个数据库的方法是合适的。
对于最简单的操作,每个 table 的 tenant_id
列可用于限定您的查询范围,并且可以使用 row level security policies.