每个Docker容器一个或多个数据库 [英] One or multiple databases per Docker container

查看:483
本文介绍了每个Docker容器一个或多个数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

比方说,我有几个不同的容器,每个容器都使用自己的数据库.在这种情况下,关于性能的最佳实践是什么?运行一个包含所有数据库的容器,例如一个MySQL服务器,还是每个数据库运行一个数据库服务器容器?

Let's say I have several different containers and each one of them uses it's own database. What is the best practice in this case regarding performance? Run one container, say a MySQL server, with all the databases in there or run one database server container per database?

除表演外,其他任何评论都将受到欢迎.

Any other comment besides the performance would be welcome.

推荐答案

由于Docker容器的开销在这里并不重要且可以忽略,因此问题更多是关于微服务范式中的体系结构.

Since Docker container overhead is not significant and negligible here, the question is more about architecture in a microservices paradigm.

性能确实是一个复杂的问题,没有一般性建议,但也许以下内容会为您提供帮助:

Performance is indeed complex question and there is no general advice, but maybe following will help you:

我个人认为该项目的初学者应该尝试提前解决所有可能的性能问题(# MVP ,# agile ) 但是,请纠正我,但是看来您没有太多资源(一个主机?),并且想提前节俭.

Personaly i doubt that a beginnig of the project one should try to solve all possible performance problems in advance (#MVP, #agile) However, correct me, but it looks like you have not much resources (one host?) and want to be thrifty with these resources in advance.

好吧,您现在最大的担心是什么?

Ok, what is your bigest concern now?

然后在同一主机上拥有两个并发的mySQL实例可能不是很好(但对于不同的设置来说不是问题)

Then having two concurreent mySQL instances on same host is maybe not that good (but not a problem for different setups)

对于一个主机,我建议开始使用一个数据库容器,但创建不同的架构. 它可能涉及标准容器的其他工作( https://forums.docker.com/t/multiple-databases-in-official-mysql-container/8324 )

For one host i would propose to start use one Database container but create different schemas. It might involve additional work with standard container (https://forums.docker.com/t/multiple-databases-in-official-mysql-container/8324)

我现在不太在乎,从一开始就从单独的数据库开始. 能够将您的服务与数据库水平分开是一个巨大的价值!由于非常理论上的未来性能问题,我不想削弱该设计决策.

I would not care to much now and start with separate databases from begin on. Being able to separate your services horizontal to the databases is a huge value! I would not want to weaken this design decision because of very theoretical future performance issues.

这篇关于每个Docker容器一个或多个数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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