[转帖]MySQL with Docker - Performance characteristics

mysql,with,docker,performance,characteristics · 浏览次数 : 0

小编点评

## Summary of the MySQL with Docker performance characteristics article: This article examines the performance characteristics of MySQL when running in Docker containers. It focuses on I/O and network overhead, comparing the results to a stock instance running on the host computer. **Key findings:** * Docker's storage options (volumes, host directories, and data volumes) have similar performance, with no significant difference observed. * Heavy I/O-bound load evens out the performance differences, resulting in Docker performing just as well as a stock instance. * Docker introduces a minor overhead when not bound by I/O, especially on the bridged network. * The best storage option depends on your convenience and workflow, but there's no major difference between the options. * Tuning your configuration file is crucial for optimal performance, even within a Docker container. **Specific results:** * MachineRW (trans/sec) - Stock instance: 2.06 B/s * Docker Volume: 1.82 B/s * Host dir: 1.94 B/s * Bridged network: 1.70 B/s **Conclusion:** The article concludes by emphasizing that there's no major performance reason for not considering using MySQL with Docker in production. It recommends focusing on optimizing your configuration file for best results, regardless of the storage option chosen.

正文

https://dev.mysql.com/blog-archive/mysql-with-docker-performance-characteristics/

 

Docker presents new levels of portability and ease of use when it comes to deploying systems. We have for some time now released Dockerfiles and scripts for MySQL products, and are not surprised by it steadily gaining traction in the development community.

The typical concern that users have with any level of abstraction, is if there is a measurable level of overhead in doing so. We have conducted our own performance tests to understand the characteristics more closely, and in this post I will go into some detail as to what we have observed.

We’ve primarily focused on I/O and network overhead and compared the results to a stock instance of MySQL. Specifically we wanted to compare the performance between Docker’s different storage options and also how much overhead Docker’s bridged network brought into the picture. The tests have been run on a Oracle Server X5-2, with 2x Xeon E5-2660 v3 (40 hardware threads) and 256GB RAM using Docker version 1.11.2 on Ubuntu 16.04.

Docker has three different ways of providing persistent storage.

  • The default is by using data volumes. This writes data to a directory on the host system using Docker’s internal volume management.
  • The second way is by specifying a directory on the host system that will be mounted into a specified location inside the container.
  • A third way is by creating a data volume container. Basically, this lets you create a shared container whose data volumes can be used by other containers.

Docker images are made up of a set of layers stacked on top of each other, where each layer represent file system differences. Docker’s storage drivers are responsible for stacking the image layers and creating a single unified view of the image. However, data volumes and host directories bypass Docker’s storage driver and should therefore run at near-native speeds. For our tests, we’ve used the AUFS storage driver as it’s the most widely used driver.

For measuring network overhead, we’ve conducted tests using Docker’s host and bridge networks, specified by  --net=host  or  --net=bridged  respectively when creating your container. Bridged networking is the default when creating containers. Host networking on the other hand adds a container on the host’s network stack, and should thus avoid the overhead typically imposed by the bridged network.

For these tests, we used a custom configuration file. We first deliberately set the buffer pool size to around 10% of the total database size in order to increase I/O-bound load. The database size was 2358MB, so we set our buffer pool size to 256MB. We then increased the buffer size to 16384MB to see what happens when Docker isn’t bound by I/O load. Specifying a custom configuration file for MySQL with Docker is relatively straight-forward. The easiest way to go about this is by mounting your config file into  /etc/my.cnf  on your container. This is done by passing  -v /path/to/host/my.cnf:/etc/my.cnf  to Docker when creating the container. You could also manually modify the container and commit your changes back into a new image, but this is somewhat impractical as you’ll have to do this procedure each time you update MySQL.

We’ve conducted tests using sysbench. We ran the following command in order to set up our databases for testing.

Warm-up was performed by first running a test like the one outlined below for 320 seconds. The full test was run thereafter. Each test was run three times, and the results in the table below reflect the average of those three runs.

We changed the  --mysql-host  address as needed when running with the bridged network.

The tests produced the following results:

MachineRW (trans/sec)
Stock instance running on host 847
Docker Volume –net=host 857
Docker Hostdir –net=host 850
Docker Datacontainer –net=host 849
Docker Volume –net=bridged 868
Docker Hostdir –net=bridged 846
Docker Datacontainer –net=bridged 856

As we can see, heavy I/O-bound load give rather even results. There’s no measurable I/O nor network overhead imposed by Docker. In this scenario, MySQL under Docker performs just as well as running MySQL directly on the host computer. Also note that Docker’s storage options all have almost equal performance with no option being significantly better than the others.

We then scaled up our buffer pool size to 16384MB to see what happens when Docker isn’t bound by I/O load. We then ran the tests once again.

MachineRW (trans/sec)
Stock instance running on host 12686
Docker Volume –net=host 12201
Docker Hostdir –net=host 12180
Docker Datacontainer –net=host 12233
Docker Volume –net=bridged 11698
Docker Hostdir –net=bridged 11644
Docker Datacontainer –net=bridged 11662

These results show that Docker imposes some overhead compared to a stock instance running on the host. There also is a minor network overhead, although not as substantial as with previous versions of Docker. We also note that there’s practically no difference between Docker’s various storage options.

Conclusion

The key takeaway here is that heavy I/O-bound load evens out the differences which might otherwise be present, resulting in Docker performing just as well as a stock instance. When not bound by I/O, Docker imposes a minor overhead, especially when running through the bridged network. Given the results, there’s no major difference between the various storage options and it therefore comes down to what’s most convenient when choosing your storage option. It’s also important to tune your configuration file for optimum performance, even when MySQL runs inside a Docker container.

MySQL with Docker has this far mainly seen use in testing and development environments, but with these results we clearly see that there is no performance-wise reason for not considering the use of MySQL with Docker in production as well.

与[转帖]MySQL with Docker - Performance characteristics相似的内容:

[转帖]MySQL with Docker - Performance characteristics

https://dev.mysql.com/blog-archive/mysql-with-docker-performance-characteristics/ Docker presents new levels of portability and ease of use when it co

[转帖]MySQL: Convert decimal to binary

Last Update:2018-12-05 Source: Internet Author: User Tags decimal to binary mysql code Developer on Alibaba Coud: Build your first app with APIs, SDKs

[转帖]MySQL pid 和 socket 文件说明

2021-10-13 11:595110转载MySQL 1 pid-file文件 MySQL 中的 pid 文件记录的是当前 mysqld 进程的 pid ,pid 亦即 Process ID 。可以通过 pid-file 参数来配置 pid 文件路径及文件名,如果未指定此变量,则 pid 文件默认

[转帖]MySQL 慢查询日志深入理解

https://www.jb51.net/article/210312.htm + 目录 什么是慢查询日志 MySQL的慢查询日志是 MySQL提供的一种日志记录,它用来记录在 MySQL 中响应时间超过阀值的语句,具体指运行时间超过long_query_time 值的 SQL,则会被记录到慢查询日

[转帖]MySQL Performance : Impact of InnoDB Transaction Isolation Modes in MySQL 5.7

http://dimitrik.free.fr/blog/archives/2015/02/mysql-performance-impact-of-innodb-transaction-isolation-modes-in-mysql-57.html There were so many valua

[转帖]MySQL Performance : IP port -vs- UNIX socket impact in 8.0 GA

http://dimitrik.free.fr/blog/posts/mysql-performance-80-ga-ip-port-vs-unix-socket-impact.html 2018-06-15 16:05 | MySQL, Performance, InnoDB, Benchmark

[转帖]MySQL Performance : XFS -vs- EXT4 Story

http://dimitrik.free.fr/blog/posts/mysql-80-perf-xfs-vs-ext4.html 2020-05-13 22:15 | MySQL, Performance, InnoDB, Benchmarks, DoubleWrite, XFS, EXT4 by

[转帖]MySQL Performance : 8.0 and UTF8 impact

http://dimitrik.free.fr/blog/posts/mysql-performance-80-and-utf8-impact.html 2018-04-26 00:58 | MySQL, Performance, UTF8 by Dimitri The world is movin

[转帖]MySQL十六:36张图理解Buffer Pool

https://www.cnblogs.com/yunlongn/p/16630257.html 转载~ 在应用系统中,我们为加速数据访问,会把高频的数据放在「缓存」(Redis、MongoDB)里,减轻数据库的压力。 在操作系统中,为了减少磁盘IO,引入了「缓冲池」(buffer pool)机制。

[转帖]MySQL提升笔记(4)InnoDB存储结构

https://cdn.modb.pro/u/310923 这一节本来计划开始索引的学习,但是在InnoDB存储引擎的索引里,存在一些数据存储结构的概念,这一节先了解一下InnodDB的逻辑存储结构,为索引的学习打好基础。 从InnoDB存储引擎的存储结构看,所有数据都被逻辑地放在一个空间中,称之为