执子之手

与子偕老


  • 首页

  • 分类

  • 归档

  • 标签

  • 关于

  • 搜索
close

Docker for Mac磁盘性能低下的解决办法

时间: 2017-03-29   |   分类: 运维     |   阅读: 455 字 ~1分钟   |   访问: 0

最近备份恢复Gogs的时候,发现同样的配置参数在Mac上访问Gogs的用户首页特别慢,大概耗时8秒,而在Linux上面运行的时候不到1秒钟。后来就上网搜索,加上自己试验,最后找到了原因应该是Gogs镜像本身的问题(可能是采用了alpine这一内核,但是具体原因不详,有待进一步实验)。

这个过程中曾经怀疑是Docker运行MySQL过慢的原因,虽然最终发现不是,但是搜索过程中发现了Docker for Mac确实有性能问题,那就是对大量磁盘IO的操作性能会非常差,大概会差10倍。

具体讨论可以看附录的帖子,这里大概摘录一下:

It seems the VM calls the virtio-blk implementation of flush in hyperkit approximately 25000 times. Each of these is implemented currently by an fsync(F_FULLFSYNC) to avoid writes being partially written or re-ordered over a power loss (as recommended by the Apple docs). Unfortunately each fsync(F_FULLFSYNC) seems to take about 10ms which accounts for the slowdown.

I agree that there are important use-cases where data persistence is less important than throughput, especially on developer setups or CI builds where containers are ephemeral. I’ll investigate the possibility of a configuration option.

解决办法

帖子里面也给出了解决办法,就是通过修改配置文件。以下方法适应于17.03.0-CE。

1$ cd ~/Library/Containers/com.docker.docker/Data/database/
2git reset --hard
3HEAD is now at 5e56922 last-start-time changed at 1487162086
4$ echo os >  com.docker.driver.amd64-linux/disk/on-flush
5$ git add com.docker.driver.amd64-linux/disk/on-flush
6$ git commit -s -m 'Use fsync'
7[master d0b523f] Use fsync
8 1 file changed, 1 insertion(+), 1 deletion(-)

附录A. 参考资料

  • Severe Docker 1.12.1 performance regression with DB2 images (~10x slower) #668
#Docker# #Mac#
Node.js 使用Redis发布订阅模式
Electron开发使用Vue Devtools
  • 文章目录
  • 站点概览
Orchidflower

Orchidflower

Do one thing at a time, and do well.

77 日志
6 分类
84 标签
GitHub 知乎 OSC 豆瓣
  • 解决办法
  • 附录A. 参考资料
© 2009 - 2024 执子之手
Powered by - Hugo v0.113.0
Theme by - NexT
ICP - 鲁ICP备17006463号-1
0%