32

Assuming we are using a micro service architecture for a product and we decide to use 'Database per service' model, and deploy in cloud servers by provider like AWS. It is convenient to have databases running as a container for development and test environments.

But can same be implemented for Production environment! If so, how safe it would be? Or is it proper to go with cloud solution as AWS RDS-DB instead!!

1

4 Answers 4

14

This blog post lists some reasons why you should not run production databases in containers. It also references another blog post describing problems with updating docker and unstable storage drivers.

The main points here for me boil down to this:

  • Dodgy storage drivers. This may be less of a problem when you write your database state to the host system but Docker for example explicitly encourages users to use volumes for exactly that (see the docs: Citation: "Volumes are the best way to persist data in Docker"). It may just work fine under normal circumstances, but what about the edge-cases like power-failures or read-errors for example?

  • Managing databases in production is hard. Many companies employ full-time DBAs to ensure smooth operation of production databases. The devops paradigm (every dev creates a plethora of DB servers in containers) makes it nearly impossible for a DBA to do his job. That is if the DBA even has access to these DBs.

In conclusion: Containers are fine for certain tasks and a bad idea for others. Running production databases in containers is one of those bad ideas.

4
  • But why DBA cannot just access running DB inside container and manage it? Jul 30, 2020 at 0:54
  • 5
    whats the status of this answer in 2022
    – PirateApp
    Jun 2, 2022 at 5:12
  • 1
    @PirateApp, I am not sure the "Dodgy storage drivers" point is still valid. Having databases in containers is now relatively common so I'd assume that any widespread reliability problems are fixed by now.
    – Richard
    Aug 21, 2022 at 10:37
  • 1
    That said I still wouldn't put a sufficiently large-scale database into a container, but a physical machine that has been specifically built for the purpose (or an appropriate EC2 instance); with boatloads of memory and SSD storage. Not some random k8s node that may or may not have enough memory to efficiently handle queries.
    – Richard
    Aug 21, 2022 at 10:53
10

We containerise our db in production (on-premises enterprise application). Many do. It's perfectly stable and the deployment is much simplified. Of course our db is not under stress; we're dealing with hundreds of concurrent users, not tens of thousands. We just make sure that the container has enough RAM and is monitored well.

If we did need to dedicate an entire VM to the db alone, then yes I would skip docker.

0
0

According to link below, it is not a good idea to use database container in Production. But as I have experienced; if you isolate your container from your app and update your container regularly and also manage networking stuff, there seems to be no problem.

Link: https://www.quora.com/Is-it-not-advisable-to-use-database-in-Docker-container

0
0

As you are using Database Per Service Model for Microservice, in Production perfect solution can be AWS RDS instance for database, Now you have 2 approaches :

  • You can create single RDS Instance and can have different databases for different services on same RDS insatnce, it will save cost a lot but you need to take care of database connections and load you will be having on database based on that you have to choose RDS instance type like 4xlarge etc, better the instance type more connection it will provide and more database load it can handle effectively.

  • Second solution can be creating several RDS instance and number of RDS instance will be equivalent to your microservice count as each service will be using one RDS instance for its database independently, this is not the effective solution, it will incur lot of cost and this solution will under utilize AWS RDS instances.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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