Docker缓慢的非本地数据库访问 [英] Docker slow non-local database access

查看:227
本文介绍了Docker缓慢的非本地数据库访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在本地开发环境中使用Docker,并将其部署到Google Cloud Container Engine进行生产。我们的生产SQL服务器也位于Google Cloud上。

当我们的容器在Container Engine实例上运行时,数据库访问速度非常快,但在我们运行时速度非常慢本地机器。一些页面加载通常需要1.9秒的时间才会生成,并且会在我们的本地时间达到25.0秒。



我假设接近程度可能是一个问题,所以我尝试启动在我的本地机器上建立一个MySQL Docker容器,并将本地的Dockerized Web服务器连接到这个容器上,速度很快。生产1.9秒的页面加载时间在我的本地徘徊在1.8秒左右。



我决定在办公室的一台服务器上运行MySQL Docker实例,但当我做了这些页面加载回到25.0s和再次上升。

看起来有些事是在Docker需要连接的时候减慢连接任何资源都不在本地机器上。



我的 docker info 输出,如果它有帮助的话:

 集装箱:4 
运行:2
暂停:0
停止:2
图片: 203
服务器版本:1.12.2
存储驱动程序:aufs
根目录:/ mnt / sda1 / var / lib / docker / aufs
备份文件系统:extfs
Dirs:209
Dirperm1支持:true
记录驱动程序:json-file
Cgroup驱动程序:cgroupfs
插件:
卷:本地
网络:空桥主机覆盖
内核版本:4.4.24-boot2docker
操作系统:Boot2Docker 1.12.2(TCL 7.2); HEAD:9d8e41b - Tue Oct 11 23:40:08 UTC 2016
OSType:linux
架构:x86_64
CPU:4
总内存:3.858 GiB
名称: dev
ID:AYO6:TL7P:XSST:VI5T:HKCC:QTOZ:HP3X:NKYQ:YCWT:THV2:AQM2:5XER
Docker根目录:/ mnt / sda1 / var / lib / docker
调试模式(客户端):false
调试模式(服务器):true
文件描述符:32
Goroutines:58
系统时间:2016-10-26T22:46: 19.218543394Z
EventsListeners:1
注册表:https://index.docker.io/v1/
标签:
provider = virtualbox


编辑:



在设法缩小问题的范围时,我设置了MySQL Docker容器放在我的Macbook上,然后在另一台机器上运行Dockerized Web服务器(运行Ubuntu 14.04)。

数据库访问速度很快,但是当我反转这一点(Ubuntu上的MySQL,Macbook上的Web服务器)时,它再次变得非常慢。奇怪。我也尝试将我的Macbook上的Docker更新为1.12,这会将VirtualBox从等式中删除,但这也未解决问题。

它可能会导致Docker的网络适配器出现问题吗?我很难过。

解决方案

Docker for Mac的版本是什么?
因为在我遇到类似问题的时候,现在我发现了Docker for MAC的一个已知问题,可能与您有关。





这个问题已被映射到下面的问题。





他们还提供了一个解决方法,但现在它应该足以更新Docker版本。


We are using Docker for our local development environments, and deploying to Google Cloud Container Engine for production. Our production SQL server is also on Google Cloud.

When our container is running on a Container Engine instance, DB access is lightning fast, but is horribly slow when running in our local machines. Some page loads that normally took 1.9s on production is brought up to 25.0s and up on our locals.

I assumed proximity may have been an issue, so I tried booting up a MySQL Docker container on my local machine, and connecting the local Dockerized web server to that instead, and was fast. That 1.9s page load on production was hovering around 1.8s now on my local.

I decided I would get a MySQL Docker instance running on one of our servers in our office, but when I did those pages loads spiked back up to 25.0s and up again.

It would seem that something is slowing down the connection the moment Docker needs to connect to any resource not on my local machine.

My docker info output if it helps at all:

Containers: 4
 Running: 2
 Paused: 0
 Stopped: 2
Images: 203
Server Version: 1.12.2
Storage Driver: aufs
 Root Dir: /mnt/sda1/var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 209
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null bridge host overlay
Kernel Version: 4.4.24-boot2docker
Operating System: Boot2Docker 1.12.2 (TCL 7.2); HEAD : 9d8e41b - Tue Oct 11 23:40:08 UTC 2016
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.858 GiB
Name: dev
ID: AYO6:TL7P:XSST:VI5T:HKCC:QTOZ:HP3X:NKYQ:YCWT:THV2:AQM2:5XER
Docker Root Dir: /mnt/sda1/var/lib/docker
Debug mode (client): false
Debug mode (server): true
 File Descriptors: 32
 Goroutines: 58
 System Time: 2016-10-26T22:46:19.218543394Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
 provider=virtualbox

EDIT:

While trying to narrow down the problem, I set up the MySQL Docker container on my Macbook, and then set up our Dockerized web server on another machine (running Ubuntu 14.04).

Database access was fast, but when I reversed this (MySQL on the Ubuntu machine, web server on the Macbook) it was dreadfully slow again. Strange. I also tried updating Docker on my Macbook to 1.12, which removes VirtualBox from the equation, and this hasn't solved the issue either.

It would SEEM that there's something going on with the network adapter for Docker perhaps? I'm stumped.

解决方案

Which is the version of Docker for Mac you were using? Because back in the time I experienced a similar issue and now I found a known issue for Docker for MAC that could be related to you.

This issue has been mapped into the following one.

They provided also a workaround, but right now it should be enough to update the Docker version.

这篇关于Docker缓慢的非本地数据库访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆