Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One or multiple databases per Docker container

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.

like image 222
StLia Avatar asked Aug 04 '16 08:08

StLia


1 Answers

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

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

Personally, I doubt that at the beginning 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 many resources (one host?) and want to be thrifty with these resources in advance.

Ok, what is your biggest concern now?

RAM is a concern

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

For one host I would propose to start using 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)

Other concerns

I would not care too much now and start with separate databases from the beginning. 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.

like image 165
aholbreich Avatar answered Oct 21 '22 06:10

aholbreich