多个数据库还是单个数据库?

发布于 2025-01-07 10:04:43 字数 156 浏览 4 评论 0原文

我们正在计划 SAAS 应用程序。

现在我们到了数据库点。包含我们所有客户的单个关系数据库还是每个客户的多个数据库?
我认为单个数据库就可以了,但要采取适当的设计和安全性。 性能怎么样?

这是一个薪资 SAAS,因此每个客户都需要根据自己的公司进行员工管理。

We are planning a SAAS application.

Now we are at the database point. A single relational database with all our client or a multiple database for each client?
I think a single database would be ok but taking the proper design and securtity.
What about performance?

It is a payroll SAAS so each client need to do his employee administration based on his company.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

眼泪淡了忧伤 2025-01-14 10:04:43

如果您使用单个数据库,它也会影响您的备份和安全考虑。通过将其全部放入单个数据库中,备份/恢复将影响所有客户。它还会影响您的扩展决策。每个客户一个数据库意味着您可以添加新的数据库服务器并重新平衡数据库。单个数据库意味着您将来可能需要能够集群。

另一方面,多个数据库意味着更多的管理开销,并且当您提供需要架构修改的增强功能时也意味着更多的工作。

If you use a single database, it also affects your backup and security considerations. By putting it all into single database, then a backup/restore will affect all customers. It will also affect your scaling decisions. A DB per customer means that you can add new db servers and rebalance databases. A single database means that you may need to be able to cluster in the future.

On the other hand, multiple dbs means more administration overhead, and also more work when you deliver enhancements that require schema modification.

街道布景 2025-01-14 10:04:43

这取决于您是否会独立维护每个客户的应用程序。如果它是“经典”SAAS 应用程序,您将拥有许多客户端,并且在大多数客户端需要某些更改之前您不准备更改您的应用程序,那么您应该做一个数据库。另一方面,如果您只是为 5 个客户托管解决方案,并且可能会发生客户 3 想要不同的东西(这很可能是薪资应用程序)并且您想要满足他的要求,那么请使用单独的数据库。

关于性能(如果您有 SaaS 和一个数据库),有多种方法可以进行分区以及其他性能改进技术(例如复制),如果最终遇到性能问题,您可以实施这些技术……在这种情况下,您只需要维护一个数据库。

It depends if you will maintain application for every client independently. If it is "classic" SAAS application, where you will have many clients and you are not ready to change your application until most of the clients require some change, then one database is what you should do. On the other hand, if you are just hosting solution for 5 clients, and might happen that client 3 wants something different (which is very likely with payroll applications) and you want to fulfill his requirements, then go with separate databases.

Regarding performance (if you have SaaS and one database), there are many ways to do partitioning, and other performance improvement techniques (replication for example) which you can implement if you end up with performance issues...and in that case, you will have to maintain only one database.

扶醉桌前 2025-01-14 10:04:43

如果它是软件即服务,那么您可能需要考虑弹性以及简单的性能。

就我个人而言,我会为所有客户端选择一个数据库,但在多个服务器之间复制它并进行负载平衡,以确保当它们在月底/发薪日同时访问它时获得良好的性能。这还可以在一台服务器崩溃时为您提供故障转移。

对于较大的应用程序,我什至可能会考虑一两个具有读/写功能的数据库服务器用于管理,多个只读数据库服务器用于报告,再次使用复制。您可以关闭一台服务器以进行快速、离线和一致的数据库备份,同时仍保留在线访问。

If it's Software as a Service, then you might want to consider resilience as well as simply performance.

Personally, I'd go for a single database for all clients, but replicate it across multiple servers with load balancing to ensure decent performance when they're all hitting it at the same time at the end-of-month/payday. This also gives you a failover in the event of one server crashing.

For a larger application, I might even consider one or two database servers with read/write for admin, with multiple read only database servers for reporting, again using replication. And you can take a single server down for fast, offline and consistent database backups while still retaining online access.

难得心□动 2025-01-14 10:04:43

这是一种设计权衡

性能与多个数据库和单个数据库无关,除非您规划分布式数据服务器模型(每个数据库位于单独的服务器上)。

保留多个数据库会给您增加一些不必要的工作。让我们假设此时您不知道会发生什么以及哪个是最佳解决方案(如果客户需要很多更改,数据库的大小是否会快速增加......)在这种情况下,我建议从一个数据库开始,如果业务正在快速增长,那么您可以轻松地分离每个客户的数据库。

阿尔伯特·爱因斯坦:一切都应该尽可能简单;但并不简单。

This is a design trade-off

Performance has nothing to do with multiple vs single database unless you plan a distributed data server model (each database on a separate server).

Keeping multiple databases add some unnecessary work for you. Let's assume at the point you don't know what is going to happen and which is the best solution (if customers need much change, do databases increase in size rapidly...) in this case I suggest starting with one database and if the business is growing up rapidly then you can separate each customers db easily.

Albert Einstein: Everything should be made as simple as possible; But not simpler.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文