0

I want to move my current relational database installation into a docker container or a set of a docker containers.

I have a web server with an associated relational database. I provide a set of 40 web services to my clients. Each service is a derivative of my web application. I use an apache web server. It uses redirects with different document roots for each service. In addition, each service has its database in a single MariaDB instance.

Now I wonder if I would put the database into a docker container, would it make sense to dockerize each service with each own dockerized mariadb as well.

Is there an issue with high computation overhead if each of the 60 services has its web server and database?

When considering a microservice architecture there are opposing ideas database-per-service and shared-database. Since my service does not share databases, the pattern database-per-service would fit. The question is if the overhead of each docker container is negatively impacted performance.

Where is the research status on this topic? What are the dominating approaches to computational overhead with more than 40 dockerized databases?

1
  • What are the dominating approaches to computational overhead with more than 40 dockerized databases? Jeff Bezos: Let's have a talk.... Now seriously. No one wants to deal with this overhead, the most common solution is not to think about it and just buy more CPU, RAM or data space. If you have money, then Cloud is the way to go. Basically, cloud platforms will manage this either by distributing containers all over the CPD or by scaling up | out computational resources for you.
    – Laiv
    Jun 30 at 8:58

2 Answers 2

1

There is almost no computational overhead, other than time used for the process switches (or more precisely: thread switches between threads of different processes). So, of course, it will make a difference if you have a single database process only or multiple database processes, one per service. More processes will require slightly more CPU time. But it will make hardly any difference if the multiple database processes run all inside a single container or each in an own container.

The difference is not CPU time but memory usage. Within a single container, multiple processes can share binary images, e.g. the binary image of the process executable itself or binary images of shared libraries. This is not the case across container boundaries. Even if in both containers the same binary is executed and it loads exactly the same libraries, there will be multiple copies of that binary and libraries in memory.

Yet using more memory will also have some performance impact even if you have plenty of RAM available. This is not because the CPU must perform more computation, it is because the CPU is very fast and RAM is very slow and thus the CPU can only work fast thanks to fast cache memory. However, as the amount of cache space is very limited, the more physical RAM your processes code uses, the more they will fight over the existing cache memory and every time data is not in cache, e.g. as it got pushed out by process memory of another process, the CPU has to fetch it from memory and that is very slow and will thwart the CPU.

1
  • First of all, your explanation is great. It provides the context. Let me recap: what you are saying is my assumption misses the point by thinking that the split of databases into several or single entity will effect my system CPU heavily. Your are rather saying that memory is is the issue. So that the limited memory cache dictates the performance. Since the processes/container fight for their place in memory. if the RAM is full the next process has to wait until something opens up. I assume here a swarm or a kubernetes can share the load. Where can find further references on memory issue?
    – A.Dumas
    Jun 29 at 20:39
0

You should not use the docker for the database. It is to difficult to handle and brings too much overhead - computational and administration.

Maybe if you have a lot of ram it can work with docker. If it works just keep it that way. 40 instances of docker is just will just overload the system. database server are build to handle that many databases. are you self hosting or do have a provider?

2
  • I am self hosting the the database.
    – A.Dumas
    Jun 29 at 20:24
  • The answer doesn't address the question. It would be better to get this one as a comment. Jul 5 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.