One or more databases per Docker container

Say I have several different containers, and each one uses its own database. What is the best practice in this case regarding performance? Run one container, say, a MySQL server, with all the databases, or run one container of the database server on the database?

Any other comments besides effectiveness will be welcome.

+6
source share
2 answers

Since the overhead of the Docker container is insignificant and insignificant here, the question is about the architecture in the microservices paradigm.

Performance is a really tricky question and there are no general tips, but maybe the following will help you:

Personally, I doubt that at the beginning of the project you should try to solve all possible performance problems in advance (#MVP, #agile) However, correct me, but it seems that you have few resources (one host?) And you want to be economical with these resources in advance.

Well, what do you care most about right now?

Memory?

Then having two matching mySQL instances on the same host is probably not very good (but not a problem for different settings)

For one host, I suggest starting to use one database container, but creating different schemas. This may require additional work with a standard container ( https://forums.docker.com/t/multiple-databases-in-official-mysql-container/8324 )

No memory

I would not want to start with separate databases from the very beginning now. The ability to share your services horizontally with databases is of utmost importance! I would not want to weaken this design decision due to very theoretical future performance issues.

+3
source

You want to use a single database server, it is preferable to use a shell that you can connect to for administration, sharing a Unix socket, port, or both in related containers. This means that it will be easier for you to manage the database container as a service, tune performance, control usage, back up volumes, etc.

Of course, there may be non-standard situations when you may want to have independent servers, for example, running servers with isolated host resources, users, databases, although I am sure that this should not apply to the development environment.

0
source

All Articles