问题
I have an architectural question.
Suppose we have a system that has multiple sub-systems: A
, B
, and so on. Each of these sub-system needs to persist their data and they all use MariaDB
. Sub-system A
may need a database
(as in create database ...
) called a_db
; and Sub-system B
may need a database called b_db
. Furthermore, there are no data sharing across A
and B
In a monolithic world before microservice and docker, it is common to set up one central MariaDB
instance and ask each sub-system to use it and to just use your own database
while on the shared instance (That is, A
uses a_db
, B
uses b_db
, and so on)
With docker, I think we could also have multiple mariadb containers running, and each maps their own volume for storage (e.g. /data/mdb_a
and /data/mdb_b
, respectively).
An obvious advantage would be complete isolation between A
and B
. There would be no worries that A
may accidentally mess with B
's data. And the two sub-systems can independently choose to shutdown/restart their own MariaDB container or even upgrade their MariaDB binary.
On the other hand, some of my colleagues argue that running multiple MariaDB containers is inefficient and this approach imposes waste of resources.
Are their good empirical measurements and articles discuss the trade-offs between the two approaches?
回答1:
Persistent storage in the containerized world is still in its infancy, and can be problematic in high traffic environments when running more than one replica of your database(in this case, mariadb).
Running more than one mariadb replica, with shared persistent data storage(e.g. NFS), regardless of the number of databases you use, could cause some corruption issues.
I have not experienced these things myself, but you should research running databases in containers further, before doing anything in production. There are lots of articles on the web about this.
A lot of people still run their databases in VM's, or on bare metal, and only run databases in containers for local development only.
来源:https://stackoverflow.com/questions/46694888/multiple-independent-mariadb-usages-multiple-containers-or-one-isolation-vs-ef