docker - 为什么 Docker 上的 MariaDB 运行速度比同一 Synology 计算机上的 'native' MariaDB 软件包慢得多?

标签 docker mariadb synology

有一台 Synology DS1621xs+(配备 NVMe SSD 缓存和 24 GB RAM)。 操作系统:Synology DSM 7.1 文件系统:btrfs Docker版本:20.10.3

这台机器上有一个在 Docker 上运行的 MariaDB10 服务器。

同一台计算机上的“ native ”Synology MariaDB10 套件上正在运行相同的数据库。 (从 Docker 实例转储并复制。)

对“ native ”MariaDB10 软件包的数据库的查询比在 Docker 实例上运行快得多。差异至少为 2.5 倍,但在某些查询上为 20 倍。

造成这种巨大性能差异的原因是什么?为什么 Docker 上的查询比 Synology Package 版本的 MariaDB 慢?

Docker信息:

Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 10
  Running: 7
  Paused: 0
  Stopped: 3
 Images: 36
 Server Version: 20.10.3
 Storage Driver: btrfs
  Build Version: Btrfs v4.0
  Library Version: 101
 Logging Driver: db
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 3fa00912415f3e9c6f82dd72119179d599efd13b
 runc version: 31cc25f16f5eba4d0f53e35374532873744f4b31
 init version: ed96d00 (expected: de40ad0)
 Security Options:
  apparmor
 Kernel Version: 4.4.180+
 Operating System:  (containerized)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 23.25GiB
 Name: NAS
 ID: ZLGI:KUWA:HOGC:3J6W:B6NJ:CZLJ:ZQP2:HAG5:3DP6:OEPX:5WRW:IHAJ
 Docker Root Dir: /volume2/@docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No kernel memory TCP limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support
WARNING: No blkio weight support
WARNING: No blkio weight_device support
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
`

MariaDB 容器日志:

2022-11-19T08:55:19.209130033Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Buffer pool(s) load completed at 221119  9:55:19
2022-11-19T08:55:19.174115217Z  stdout  Version: '10.6.5-MariaDB-1:10.6.5+maria~focal'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2022-11-19T08:55:19.174011946Z  stdout  2022-11-19  9:55:19 0 [Note] mysqld: ready for connections.
2022-11-19T08:55:19.167072919Z  stdout  2022-11-19  9:55:19 0 [Warning] 'proxies_priv' entry '@% root@mariadb-copy' ignored in --skip-name-resolve mode.
2022-11-19T08:55:19.163349561Z  stdout  2022-11-19  9:55:19 0 [Note] Server socket created on IP: '::'.
2022-11-19T08:55:19.163211778Z  stdout  2022-11-19  9:55:19 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-11-19T08:55:19.161820288Z  stdout  2022-11-19  9:55:19 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-11-19T08:55:19.149901116Z  stdout  2022-11-19  9:55:19 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-11-19T08:55:19.149840357Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-11-19T08:55:19.149391807Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: 10.6.5 started; log sequence number 3282096825; transaction id 7204
2022-11-19T08:55:19.148296829Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-11-19T08:55:19.148223400Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-11-19T08:55:19.148147151Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-11-19T08:55:19.147243337Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: 128 rollback segments are active.
2022-11-19T08:55:19.086673922Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Completed initialization of buffer pool
2022-11-19T08:55:19.085986215Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-11-19T08:55:19.085469623Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Using Linux native AIO
2022-11-19T08:55:19.068551244Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-11-19T08:55:19.068528556Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Number of pools: 1
2022-11-19T08:55:19.068487467Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Using transactional memory
2022-11-19T08:55:19.068374374Z  stdout  2022-11-19  9:55:19 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-11-19T08:55:19.049836283Z  stdout  2022-11-19  9:55:19 0 [Note] mysqld (server 10.6.5-MariaDB-1:10.6.5+maria~focal) starting as process 1 ...
2022-11-19T08:55:18.900158637Z  stdout  2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.
2022-11-19T08:55:18.892594609Z  stdout  2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-11-19T08:55:18.738312960Z  stdout  2022-11-19 09:55:18+01:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.3.14+maria~bionic started.

最佳答案

MariaDB 已更改 innodb_flush_method=O_DIRECT 10.6 中以辅助高端性能。因此,MariaDB-10.6 更加依赖 innodb_buffer_pool_sizeinnodb_log_file_size 来获得读/写性能。

作为解决方法,请使用 innodb_flush_method=fsync 测试 10.6。 btrfs 比现在的内核 4.4.0 更新得多,因此它的 O_DIRECT 路径可能不如 4.4.0 中的性能好。

也可能是 MDEV-29967 broken linear read ahead我们正在努力在下一个版本之前修复这个问题。

也可能是10.6的统计数据不同try a recalculation using ANALYZE TABLES .

this link 中有一些 btrfs 链接/建议.

或者可能是完全不同的东西,需要:

  • 仔细衡量和分割各个查询及其执行。
  • 消除本地环境(在与本地包相同版本/配置的容器中运行 10.3 版本)。

关于docker - 为什么 Docker 上的 MariaDB 运行速度比同一 Synology 计算机上的 'native' MariaDB 软件包慢得多?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74499155/

相关文章:

docker - 如何在 Linux 中为 Rider 设置 Docker

mysql - 我可以安全地从 Centos Linux 中删除 mariadb 吗?

在 Synology NAS 上执行 SQL 的 Python 脚本

linux - 群晖NAS服务器上的mongoctl

linux - Synology DSM Backup - 配置文件

linux - 无法连接到 docker 容器外部的 oracle :12. 1.0.2

c# - 如何代理来自在 docker 容器中运行的 dotnet 核心应用程序的每个请求

docker - 无法拉取图像拉取访问被拒绝,存储库不存在或可能需要 'docker login' :

MYSQL:错误 1064(42000) MariaDB 服务器在 'NOT NULL' 附近使用正确的语法

mysql - 当在 utf8mb4 数据和子字符串 ü😋 上有索引时,MySql 和 MariaDB 中的错误?