为每个客户端使用单个数据库的优点是什么? [英] What are the advantages of using a single database for EACH client?

查看:172
本文介绍了为每个客户端使用单个数据库的优点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为多个客户端设计的以数据库为中心的应用程序中,我一直认为对所有客户端使用单个数据库是更好的 - 将记录与正确的索引和键相关联。在听Stack Overflow播客时,我听说Joel提到FogBugz每个客户端使用一个数据库(因此,如果有1000个客户端,将有1000个数据库)。使用这种架构的优点是什么?



我理解,对于某些项目,客户端需要直接访问他们的所有数据 - 在这样的应用程序中,很明显,每个客户端需要自己的数据库。但是,对于客户端不需要直接访问数据库的项目,每个客户端使用一个数据库有什么优势吗?看来在灵活性方面,使用单个数据库和表的单个副本要简单得多。



我对所有客户端的一个数据库方法非常有信心,直到我听说Joel(一个有经验的开发者)提到他的软件使用不同的方法 - 我有点困惑他的决定...



我听说过人们引用数据库慢下来与大量的记录,但任何关系数据库有一些优点是不会有这个问题 - 特别是如果使用正确的索引和键。



任何输入都非常感谢!

解决方案

假设在一个数据库中存储所有客户端没有缩放代价;对于大多数人,和配置良好的数据库/查询,这将是相当真实的这些天。如果你不是这些人之一,那么单个数据库的好处是显而易见的。



在这种情况下,收益来自每个客户端的封装。从代码的角度来看,每个客户端都是单独存在的 - 没有可能出现数据库更新可能会覆盖,损坏,检索或更改属于另一个客户端的数据的情况。这也简化了模型,因为你不需要考虑记录可能属于另一个客户端的事实。



您还可以获得可分性的好处 - 拉出与给定客户端相关联的数据,并将它们移动到不同的服务器。当您使用内置数据库机制调用我们删除了一些关键数据!时,可以还原该客户端的备份。



服务器移动性 - 如果您超出一个数据库服务器,您只能在另一个服务器上托管新客户端。如果他们都在一个数据库中,您需要获得更强大的硬件,或者在多个机器上运行数据库。



您可以轻松地进行版本控制保留在软件版本1.0,另一个需要2.0,其中1.0和2.0使用不同的数据库模式,没有问题 - 你可以迁移一个,而不必拉出一个数据库。



我可以想到几十个,我猜。但总而言之,关键的概念是简单。该产品管理一个客户端,从而管理一个数据库。从未有任何来自但该数据库还包含其他客户的问题的复杂性。它适合用户,他们单独存在的心理模型。喜欢的是可以同时对所有客户端做简单的汇报优点,是最小的 - 你经常要对整个世界的报告,而不是仅仅一个客户端


In a database-centric application that is designed for multiple clients, I've always thought it was "better" to use a single database for ALL clients - associating records with proper indexes and keys. In listening to the Stack Overflow podcast, I heard Joel mention that FogBugz uses one database per client (so if there were 1000 clients, there would be 1000 databases). What are the advantages of using this architecture?

I understand that for some projects, clients need direct access to all of their data - in such an application, it's obvious that each client needs their own database. However, for projects where a client does not need to access the database directly, are there any advantages to using one database per client? It seems that in terms of flexibility, it's much simpler to use a single database with a single copy of the tables. It's easier to add new features, it's easier to create reports, and it's just easier to manage.

I was pretty confident in the "one database for all clients" method until I heard Joel (an experienced developer) mention that his software uses a different approach -- and I'm a little confused with his decision...

I've heard people cite that databases slow down with a large number of records, but any relational database with some merit isn't going to have that problem - especially if proper indexes and keys are used.

Any input is greatly appreciated!

解决方案

Assume there's no scaling penalty for storing all the clients in one database; for most people, and well configured databases/queries, this will be fairly true these days. If you're not one of these people, well, then the benefit of a single database is obvious.

In this situation, benefits come from the encapsulation of each client. From the code perspective, each client exists in isolation - there is no possible situation in which a database update might overwrite, corrupt, retrieve or alter data belonging to another client. This also simplifies the model, as you don't need to ever consider the fact that records might belong to another client.

You also get benefits of separability - it's trivial to pull out the data associated with a given client ,and move them to a different server. Or restore a backup of that client when the call up to say "We've deleted some key data!", using the builtin database mechanisms.

You get easy and free server mobility - if you outscale one database server, you can just host new clients on another server. If they were all in one database, you'd need to either get beefier hardware, or run the database over multiple machines.

You get easy versioning - if one client wants to stay on software version 1.0, and another wants 2.0, where 1.0 and 2.0 use different database schemas, there's no problem - you can migrate one without having to pull them out of one database.

I can think of a few dozen more, I guess. But all in all, the key concept is "simplicity". The product manages one client, and thus one database. There is never any complexity from the "But the database also contains other clients" issue. It fits the mental model of the user, where they exist alone. Advantages like being able to doing easy reporting on all clients at once, are minimal - how often do you want a report on the whole world, rather than just one client?

这篇关于为每个客户端使用单个数据库的优点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆