简体   繁体   English

多个独立的 mariadb 用法:多个容器还是一个? 隔离与效率?

[英]Multiple independent mariadb usages: multiple containers or one? Isolation vs efficiency?

I have an architectural question.我有一个建筑问题。

Suppose we have a system that has multiple sub-systems: A , B , and so on.假设我们有一个系统,它有多个子系统: AB等等。 Each of these sub-system needs to persist their data and they all use MariaDB .这些子系统中的每一个都需要持久化它们的数据,并且它们都使用MariaDB Sub-system A may need a database (as in create database ... ) called a_db ;子系统A可能需要一个名为a_dbdatabase (如在create database ... ); and Sub-system B may need a database called b_db .子系统B可能需要一个名为b_db的数据库。 Furthermore, there are no data sharing across A and B此外, AB之间没有数据共享

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)在微服务和 docker 之前的单体世界中,通常会设置一个中央MariaDB实例并要求每个子系统使用它,并且在共享实例上只使用您自己的database (即A使用a_dbB使用b_db ,等等)

With docker, I think we could also have multiple mariadb containers running, and each maps their own volume for storage (eg /data/mdb_a and /data/mdb_b , respectively).使用 docker,我认为我们还可以运行多个 mariadb 容器,每个容器都映射自己的存储卷(例如,分别为/data/mdb_a/data/mdb_b )。

An obvious advantage would be complete isolation between A and B .一个明显的优势是AB之间A完全隔离。 There would be no worries that A may accidentally mess with B 's data.不用担心A可能会不小心弄乱B的数据。 And the two sub-systems can independently choose to shutdown/restart their own MariaDB container or even upgrade their MariaDB binary.两个子系统可以独立选择关闭/重启他们自己的 MariaDB 容器,甚至升级他们的 MariaDB 二进制文件。

On the other hand, some of my colleagues argue that running multiple MariaDB containers is inefficient and this approach imposes waste of resources.另一方面,我的一些同事认为运行多个 MariaDB 容器效率低下,这种方法会造成资源浪费。

Are their good empirical measurements and articles discuss the trade-offs between the two approaches?他们良好的实证测量和文章是否讨论了两种方法之间的权衡?

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).容器化世界中的持久性存储仍处于起步阶段,在高流量环境中运行多个数据库副本(在本例中为 mariadb)时可能会出现问题。

Running more than one mariadb replica, with shared persistent data storage(eg NFS), regardless of the number of databases you use, could cause some corruption issues.运行多个带有共享持久数据存储(例如 NFS)的 mariadb 副本,无论您使用多少数据库,都可能导致一些损坏问题。

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.许多人仍然在 VM 或裸机上运行他们的数据库,并且只在容器中运行数据库以进行本地开发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM