简体   繁体   English

多租户隔离数据库的DAL和配置的最佳实践

[英]best practice for DAL and configuration on Multi-Tenant isolated DB

My company holds a dozen websites and isolated DBs (identical schemas). 我的公司拥有十几个网站和独立的数据库(相同的模式)。 every customer has its own website (different app pool) and DB. 每个客户都有自己的网站(不同的应用程序池)和数据库。

every website has its own configuration, several connection strings, but they all have same schema for configuration. 每个网站都有自己的配置,多个连接字符串,但它们都具有相同的配置架构。

cust1.domain.com cust1.domain.com

cust2.domain.com cust2.domain.com

cust3.domain.com cust3.domain.com

We would like to merge all websites to one (single app pool) and stay with isolated DBs for security and large amount of data reasons. 我们希望将所有网站合并为一个(单个应用程序池)并保留隔离的数据库,以确保安全性和大量数据。

what is the best practice for designing a DAL and configuration of it? 设计DAL和配置它的最佳实践是什么? what are the implications of it, if large amount of tenant will be on the same time? 如果大量的租户将在同一时间,它的含义是什么? does one application pool can manage this situation or it can be managed somehow? 一个应用程序池可以管理这种情况,还是可以以某种方式管理它?

BTW, we are using asp-membership for users authentication. 顺便说一下,我们使用asp-membership进行用户身份验证。

Thanks in advance, Eddie 在此先感谢,艾迪

使用global.asax Application_PostAuthenticate事件加载正确的数据库,然后在Application_EndRequest关闭连接

One option is to use the profile in membership and store a piece of information that will allow you to determine which of the actual db's they should be connecting to. 一种选择是在成员资格中使用配置文件并存储一条信息,以便您确定它们应连接到哪个实际数据库。 Downside is that you will need to store this piece of information for the duration of the users session so either a cookie or session variable is likley to be needed. 缺点是您需要在用户会话期间存储此信息,因此可能需要cookie或会话变量。

The implications of one site vs many depends a lot on your environment and application, do you currently have the multiple sites on a single box or do you have a web farm? 一个站点与多个站点的含义在很大程度上取决于您的环境和应用程序,您目前在一个盒子上有多个站点,或者您是否拥有Web场? do you know the number of concurrent users for each site, the amount of traffic? 你知道每个站点的并发用户数,流量吗? Performance monitor can help you here to see how busy each site is but you may need more invasive logging to determine metrics such as concurrent users. 性能监视器可以帮助您查看每个站点的繁忙程度,但您可能需要更多的侵入式日志记录来确定并发用户等指标。 I found this server fault question around IIS 7 performance which may be of help 我发现这个服务器故障问题围绕IIS 7性能可能有所帮助

You can try 'Shared DataBase With Different Schema' from multi tenant data architecture . 您可以尝试从多租户数据架构中“使用不同架构共享数据库”。 In your DAL you can choose specific schema which perticular to current user. 在您的DAL中,您可以选择与当前用户相关的特定架构。 Simple and secure in this way 这种方式简单而安全

Continue reading http://msdn.microsoft.com/en-us/library/aa479086.aspx 继续阅读http://msdn.microsoft.com/en-us/library/aa479086.aspx

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

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