`
iunknown
  • 浏览: 409516 次
社区版块
存档分类
最新评论

[zz]Multi Tenancy - The Physical Data Model

    博客分类:
  • MISC
阅读更多
http://ayende.com/Blog/archive/2008/08/07/Multi-Tenancy--The-Physical-Data-Model.aspx

Continuing on the multi tenancy theme, let us talk about the actual physical structure of the data store. In general, you have two basic options.

The TenantId column and separated data stores. The TenantId is simply adding a column to all the columns, showing what tenant the row belongs to.
The separate data store calls for a much higher level of separation, where there is no shared storage for the tenants.
There are variation on those, such as having separation in the schema level instead of DB level, etc, but they all end up being down to one of those choices.

The TenantId approach allows you to use a single DB for the entire application, potentially reducing costs for managing the environment. It is also the easiest to explain, we just filter by TenantId and that is it!

It comes with a whole set of problems that is related to that decision, however:

Isolation - You have to actively do filtering all the time. This has major issues on your code. And now, tacking TenantId = @CurrentTenant at each query is not going to be sufficient. Consider the case of joins in such an environment, you are likely to get a filter only on the end result, after it was joined already. And that is just one example.
Backup - The backup strategy that you have for this scenario sucks. Basically, you have to roll your own.
Customer copy of the data - Going back to the backup strategy? You can't just hand the customer the backup. You have to dump the data out, and write something that writes it back in, and it has to be fast.
Security - you have to let all tenants access the data, security is in the app logic level.
Extensibility - in a shared environment it is hard to do a lot of extensibility in the data, because each client is stepping on each other toes.
As you probably gathered, I strongly suggest going with the separate model. Now our management strategy is dealing with the connection string. Isolation is built in and doesn't require any , for backup you have the vendor tools, and giving the customer its own data is trivial, just send him the backup file. Security is easy, a tenant can access only their DB, and extending this is much easier, because each tenant has their own walled garden to play with.

分享到:
评论
1 楼 iunknown 2009-06-23  
http://discuss.joelonsoftware.com/default.asp?design.4.319460.16

Multi-tenant database design
We are in the process of designing an on-demand business application. We use MS SQL Server for the database.

Here are some of the constraints we've been given:
* Single database for multiple customers
* Customers can extend the data model by adding fields and tables (application is meta-data driven)

What would be the best way to solve this?

1. Have a TenantID field in all tables

The database remains static, i.e. adding a tenant does not change/add tables.

Extending the data model would not really change the physical model, but make use of extension tables. These extension tables contain the extra fields.

Advantages:
* Static data model
* App can use DB account with limited rights, always a good thing for security

Disadvantages:
* Complicated mapping between logical model the customer sees and the physical model, resulting in queries requiring joins to extension tables...
* Difficult to optimize the database, e.g. adding proper indexes on customer extensions

2. Have each table exist per tenant

Every table would exist once per tenant, e.g. the Account table would exist as Tenant1ID_Account and Tenant2ID_Account.

Customizations would really alter the data model.

Advantages:
* Simplifies queries and reduces the complexity of mapping
* Easier to optimize the database by adding indexes on some of the extensions

Disadvantages:
* Database account used by the application requires dbo rights, which may be dangerous if somebody finds a security hole letting them do a SQL injection attack
* Many tables. The application we are designing is a large suite of modules. This can easily add up to 500-1000 tables per tenant. A moderate success would result easily in a hundred tenants. I don't think managing a database with 100,000 tables is realistic

相关推荐

    multi-tenancy-assets-master.rar

    【标题】"multi-tenancy-assets-master.rar" 暗示了一个关于多租户资产管理系统的源代码库。多租户架构是一种设计模式,常见于云计算服务,它允许单个软件实例服务于多个独立的客户,每个客户称为一个租户。在这样的...

    multi-tenancy-test:多租户测试

    本项目"multi-tenancy-test"专注于多租户测试,使用了Java生态系统中的Hibernate 4 ORM框架和JavaServer Faces(JSF)2 Web应用框架。 **多租户概念** 多租户架构的核心是数据隔离,每个租户都有自己的数据视图,而...

    DBackup-Multi-Tenancy-Manual

    【鼎甲备份软件多租户管理配置手册】是广州鼎甲计算机科技有限公司为用户提供的一款详尽的指导文档,旨在帮助用户理解和配置其备份系统的多租户功能。在现代云计算环境中,多租户架构已经成为一种常见的方式,允许...

    acm-multi-tenancy-dev-team测试:acm-multi-tenancy-dev-team测试

    标题"acm-multi-tenancy-dev-team测试"暗示了这是一个关于ACM(可能是Application Configuration Manager或Automated Certificate Management)系统中多租户开发团队的测试项目。团队可能正在对支持多租户特性的代码...

    36 为什么说Kubernetes只有soft multi-tenancy?.pdf

    36 为什么说Kubernetes只有soft multi-tenancy?.pdf

    Python库 | django_tenancy-0.3.1a2-py2.py3-none-any.whl

    资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:django_tenancy-0.3.1a2-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    multi-tenancy-sample:这是一个示例应用程序,显示了如何实现多租户架构

    这是一个示例应用程序,显示了如何实现多租户架构。 要求:您应该已经安装并配置了maven您应该已经安装了MySQL并为MySQL设置了环境变量(无论您的命令行/终端目录如何,都可以在计算机中执行命令“ mysql”)。...

    Python库 | django_tenancy-0.2.2-py2.py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:django_tenancy-0.2.2-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    jhipster-multi-tenancy-poc

    "jhipster-multi-tenancy-poc" 是一个针对 JHipster 平台的多租户概念验证(Proof of Concept,PoC)项目,旨在展示如何在 JHipster 应用中实现多租户功能。 在企业级软件开发中,多租户架构是一种重要的设计模式,...

    Multi-Tenancy-in-Loopback-4

    lb4-多租户 该应用程序是使用和。 安装依赖项 默认情况下,生成此应用程序时会安装依赖项。 每当package.json中的依赖项发生更改时,请运行以下命令: npm install 要仅在package-lock.json安装已解决的依赖项,请...

    mybatis-plus-multi-tenancy_springboot多租户实现例子.zip

    这个“mybatis-plus-multi-tenancy_springboot多租户实现例子.zip”压缩包提供了一个使用SpringBoot和MyBatis Plus实现多租户系统的示例。以下是对这个项目的关键知识点的详细解释: 1. **多租户架构**:多租户是指...

    jpa-multi-tenancy

    **JPA多租户详解** Java Persistence API (JPA) 是Java平台上的一个标准,用于对象关系映射(ORM),...通过深入研究`jpa-multi-tenancy-master`项目,开发者可以获得宝贵的实践经验,更好地理解和应用JPA的多租户特性。

    laravel-tenancy-sanctum

    composer require laravel/sanctum ...// skopiowane z Stancl'owego InitializeTenancyByDomain ... if(in_array($request->getHost(), config('tenancy.central_domains'), true)){ return $next($requ

    Cognos Multi-tenancy Solution.pptx

    Cognos Cognos Cognos Cognos Cognos Cognos Cognos Cognos

    docker-multi-tenancy:Docker多租户代理

    docker build -t harbur/docker-multi-tenancy . 或搭配Docker Compose docker-compose build 入门 使用Docker运行代理: docker run -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock harbur/docker-...

    Laravel开发-laravel-tenancy

    **Laravel 开发中的多租户解决方案:laravel-tenancy** 在 Laravel 开发中,多租户架构是一种设计模式,允许单个应用程序为多个独立的客户或组织提供服务,每个客户都拥有自己的数据和配置。laravel-tenancy 是一个...

    multi-tenancy:JPAHibernate-Spring Boot-多租户测试项目

    "multi-tenancy-master"可能是项目的根目录,其中包含了源代码、配置文件、测试文件等。开发者可以查看项目的`pom.xml`文件了解依赖管理,`src/main/java`下可能有Spring Boot的启动类和配置,`src/main/resources`...

    laravel-multi-tenancy

    composer require erikfig/laravel-tenancy 然后发布配置文件: php artisan vendor:publish --provider=ErikFig\Laravel\Tenancy\Providers\TenancyServiceProvider 将创建以下文件: 配置/ tenancy.php 路线/...

Global site tag (gtag.js) - Google Analytics