7

我已经对这个问题进行了一些研究(通过谷歌和在这里),但没有发现任何我认为符合我的情况的东西,所以我问。

我有一个项目,目前有一个帐户 - 一个环境模型,并希望扩展到一个帐户 - 多个环境。环境将是相同的(至少就表结构而言)并且需要大约 100 个表。我在两种可能的方法之间左右为难:

  1. 使用单个数据库,带有表前缀来分隔每个环境和一个无前缀的帐户表
  2. 使用多个数据库 - 一个中央帐户数据库,每个环境都有一个单独的数据库(中央数据库可能有其他中央的、一次性的数据,例如我们论坛软件的表格)

这两种方法是否有任何显着的性能提升/担忧?数据将(至少目前)全部驻留在同一物理服务器上。查询应该只需要访问一个环境(在极少数情况下除外)——当然还有主账户记录。

4

5 回答 5

3

I think it'd be simpler to only manage one database. This will make development and configuration much easier, than having many databases to worry about configuring correctly.

In terms of performance, you can let the DBMS handle the clustering/distributed stuff, so you won't have to worry about it. Splitting up the data yourself isn't going to make things faster usually, since the DBMS can (usually) do a much better job at that then you can.

于 2012-06-28T02:25:30.423 回答
3

我们有多个数据库的工作——以及不同的数据库供应商(DB2、Oracle、MySQL)。巨大的 PITA,尽管其中一些痛苦可能来自于每个数据库由不同的组拥有的事实。但是,如果您需要在数据库(而不是应用程序)中加入数据(您认为现在这种情况很少见,但您等待...),您会后悔多服务器解决方案。

于 2012-06-28T02:30:11.267 回答
3

有趣的问题。作为标准答案,我建议让一个实例运行所有帐户。即前缀解决方案。这是托管服务提供商到处使用的方法。

让一个 RDBMS 运行似乎是有意义的。更容易进行备份和其他系统范围的任务。我建议就性能而言,运行一个实例比为每个帐户运行一个单独的进程要高效得多。

如果您需要启用负载平衡,“前缀”模型也将更容易扩展,因为大多数现代 RDBMS 都具有支持此类功能的插件/功能,而不必为每个帐户的每个实例设置多次。

现代数据库系统很容易每秒处理数千个请求,通过查找花哨的自定义(前缀)表名,它们不会有任何性能损失。只要您能想出一个简单的层次结构(帐户前缀)方法来分离帐户,运行数千个表就不会有问题。

唯一潜在的缺点是安全性。在大多数情况下,即使拥有多台服务器也无法解决您的安全问题。

于 2012-06-28T02:50:46.190 回答
0

I would say use many databases to allow for future modification of the various environments. It is doubtful you are talking about static data that all of the site would use, each site deserves its own set of data...

If for no other reason, (as I said before) to allow for modifications.

于 2012-06-28T02:24:44.497 回答
0

The project I'm currently working on is similar in that respect; one account for multiple sites.

The solution I've gone for is delegated authentication, one service that solely deals with authentication and issues verifiable assertions about an identity. This can be coupled with authorization as well. To get an idea of what is required you can look at the OpenID project, and OAuth2 for authorization.

Setting up this service is not easy (though the OpenID site has setup guides for it), but it does provide the flexibility to move your environments out to different physical locations without having to change your code. In fact, you're free to even keep a single database and perhaps move one environment to a dedicated machine when it gains more traction than the others.

于 2012-06-28T02:44:19.207 回答