简体   繁体   English

使用SQL / WCF / Silverlight进行多租户

[英]Multi-tenancy with SQL/WCF/Silverlight

We're building a Silverlight application which will be offered as SaaS. 我们正在构建一个将以SaaS形式提供的Silverlight应用程序。 The end product is a Silverlight client that connects to a WCF service. 最终产品是连接到WCF服务的Silverlight客户端。 As the number of clients is potentially large, updating needs to be easy, preferably so that all instances can be updated in one go. 由于客户端的数量可能很大,因此更新需要很容易,最好是一次可以更新所有实例。

Not having implemented multi tenancy before, I'm looking for opinions on how to achieve 之前没有实施多租户,我正在寻找有关如何实现多租户的意见

  • Easy upgrades 轻松升级
  • Data security 数据安全
  • Scalability 可扩展性

Three different models to consider are listed on msdn msdn上列出了要考虑的三种不同模型

  1. Separate databases. 单独的数据库。 This is not easy to maintain as all schema changes will have to be applied to each customer's database individually. 这很不容易维护,因为所有架构更改都必须分别应用于每个客户的数据库。 Are there other drawbacks? 还有其他缺点吗? A pro is data separation and security. 优点是数据分离和安全性。 This also allows for slight modifications per customer (which might be more hassle than it's worth!) 这还允许对每个客户进行轻微的修改(这可能比它的价值还要麻烦!)
  2. Shared Database, Separate Schemas. 共享数据库,单独的架构。 A TenantID column is added to each table. 将TenantID列添加到每个表。 Ensuring that each customer gets the correct data is potentially dangerous. 确保每个客户获取正确的数据都是潜在的危险。 Easy to maintain and scales well (?). 易于维护,扩展性好(?)。
  3. Shared Database, Separate Schemas. 共享数据库,单独的架构。 Similar to the first model, but each customer has its own set of tables in the database. 与第一个模型相似,但是每个客户在数据库中都有自己的一组表。 Hard to restore backups for a single customer. 难以为单个客户恢复备份。 Maintainability otherwise similar to model 1 (?). 其他方面的可维护性类似于模型1(?)。

Any recommendations on articles on the subject? 关于该主题的文章有什么建议吗? Has anybody explored something similar with a Silverlight SaaS app? 有人使用Silverlight SaaS应用程序探索过类似的东西吗? What do I need to consider on the client side? 我需要在客户端考虑什么?

I've similar case, but my solution is take both advantage. 我有类似的情况,但我的解决方案是同时利用两者。

Where data and how data being placed is the question from tenant. 数据在哪里以及如何放置是租户的问题。 Being a tenant of course I don't want my data to be shared, I want my data isolated, secure and I can get at anytime I want. 作为租户,我当然不希望共享数据,我希望数据隔离,安全并且我可以随时获取。

Certain data it possibly share eg: company list. 它可能共享的某些数据,例如:公司列表。 So database should be global and tenant database, just make sure to locked in operation tenant database schema, and procedure to update all tenant database at once. 因此数据库应该是全局和租户数据库,只需确保锁定了操作的租户数据库架构,并立即更新所有租户数据库的过程即可。

Anyway SaaS model everything delivered as server / web service, so no matter where the database should come to client as service, then only render by client GUI. 无论如何,SaaS都将以服务器/ Web服务形式交付的所有内容建模,因此无论将数据库作为服务提供给客户端的位置如何,都只能通过客户端GUI进行呈现。

Thanks 谢谢

Depends on the type of application and scale of data. 取决于应用程序的类型和数据规模。 Each one has downfalls. 每个人都有失败。

1a) Separate databases + single instance of WCF/client. 1a)单独的数据库+ WCF /客户端的单个实例。 Keeping everything in sync will be a challenge. 保持一切同步将是一个挑战。 How do you upgrade X number of DB servers at the same time, what if one fails and is now out of sync and not compatible with the client/WCF layer? 您如何同时升级X台数据库服务器,如果一台服务器出现故障,现在不同步并且与客户端/ WCF层不兼容,该怎么办?

1b) "Silos", separate DB/WCF/Client for each customer. 1b)“ Silos”,为每个客户单独分配DB / WCF / Client。 You don't have the sync issue but you do have the overhead of managing many different instances of each layer. 您没有同步问题,但确实有管理每个图层的许多不同实例的开销。 Also you will have to look at SQL licensing, I can't remember if separate instances of SQL are licensed separately ($$$). 另外,您还必须查看SQL许可,我不记得是否单独的SQL实例是单独许可的($$$)。 Even if you can install as many instances as you want, the overhead of multiple instances will not be trivial after a certain point. 即使您可以安装所需数量的实例,多个实例的开销在特定时间点之后也不是小事。

3) Basically same issues as 1a/b except for licensing. 3)除许可外,与1a / b基本相同。

2) Best upgrade/management scenario. 2)最佳升级/管理方案。 You are right that maintaining data isolation is a huge concern (1a technically shares this issue at a higher level). 正确的是,保持数据隔离是一个巨大的问题(1a从技术上讲在更高级别上具有此问题)。 The other issue is if your application is data intensive you have to worry about data scalability. 另一个问题是,如果您的应用程序是数据密集型的,则必须担心数据可伸缩性。 For example if every customer is expected to have tens/hundreds millions rows of data. 例如,如果期望每个客户拥有数以千万计的数据行。 Then you will start to run into issues and query performance for individual customers due to total customer base volumes. 然后,由于总的客户群数量,您将开始遇到问题并查询单个客户的性能。 Clients are more forgiving for slowdowns caused by their own data volume. 客户端对于自己的数据量导致的速度下降更为宽容。 Being told its slow because the other 99 clients data is large is generally a no-go. 由于其他99个客户端数据很大而被告知缓慢,通常是不可行的。

Unless you know for a fact you will be dealing with huge data volumes from the start I would probably go with #2 for now, and begin looking at clustering or moving to 1a/b setup if needed in the future. 除非您知道一个事实,否则从一开始就将要处理大量数据,我现在可能会选择#2,并开始考虑集群化,或者如果将来需要的话,转向1a / b设置。

We also have a SaaS product and we use solution #2 (Shared DB/Shared Schema with TenandId). 我们也有SaaS产品,我们使用解决方案2(带有TenandId的共享数据库/共享架构)。 Some things to consider for Share DB / Same schema for all: 所有共享数据库/相同架构要考虑的一些事项:

  1. As mention above, high volume of data for one tenant may affect performance of the other tenants if you're not careful; 如上所述,如果您不小心,一个租户的大量数据可能会影响其他租户的性能。 for starters index your tables properly/carefully and never ever do queries that force a table scan. 对于初学者来说,正确/仔细地索引您的表,永远不要执行强制执行表扫描的查询。 Monitor query performance and at least plan/design to be able to partition your DB later on based some criteria that makes sense for your domain. 监视查询性能,至少规划/设计,以便以后根据对您的域有意义的一些标准对数据库进行分区。

  2. Data separation is very very important, you don't want to end up showing a piece of data to some tenant that belongs to other tenant. 数据分离非常重要,您不希望最终向属于其他租户的某个租户显示一条数据。 every query must have a WHERE TenandId = ... in it and you should be able to verify/enforce this during dev. 每个查询中都必须包含WHERE TenandId = ...,并且您应该能够在开发过程中验证/强制执行此操作。

  3. Extensibility of the schema is something that solutions 1 and 3 may give you, but you can go around it by designing a way to extend the fields that are associated with the documents/tables in your domain that make sense (ie. Metadata for tables as the msdn article mentions) 解决方案1和3可能会为模式提供可扩展性,但是您可以通过设计一种方法来扩展与域中有意义的文档/表相关联的字段(例如,表的元数据为msdn文章提到)

What about solutions that provide an out of the box architecture like Apprenda's SaaSGrid? 提供像Apprenda的SaaSGrid这样的现成架构的解决方案呢? They let you make database decisions at deploy and maintenance time and not at design time. 它们使您可以在部署和维护时而不是设计时做出数据库决策。 It seems they actively transform and manage the data layer, as well as provide an upgrade engine. 他们似乎在积极地转换和管理数据层,并提供升级引擎。

Existing answers are good. 现有的答案是好的。 You should look deeply into the issue of upgrading and managing multiple databases. 您应该深入研究升级和管理多个数据库的问题。 Without knowing the specific app, it might turn out easier to have multiple databases and not have to pay the extra cost of tracking the TenantID. 在不知道特定应用程序的情况下,拥有多个数据库可能会更容易,而不必支付跟踪TenantID的额外费用。 This might not end up being the right decision, but you should certainly be wary of the dev cost of data sharing. 这可能最终不是正确的决定,但是您一定要警惕数据共享的开发成本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM