简体   繁体   English

进程在 ubuntu 18.04 上的 docker 容器中运行缓慢

[英]Processes are running slow in docker container on ubuntu 18.04

Processes are taking time when running them in a docker container on ubuntu 18 machine.进程在 ubuntu 18 机器上的 docker 容器中运行时需要时间。 But the same process with the same docker version is running fine on ubuntu 16 machine.但是具有相同 docker 版本的相同进程在 ubuntu 16 机器上运行良好。

I have a node application listening on some port.我有一个节点应用程序正在监听某个端口。 Accepting get requests on the path "/" and "/docker" which simply runs a command "whoami" in the host machine and in docker container respectively and returns the result.接受路径“/”和“/docker”上的get请求,它们分别在主机和docker容器中运行一个命令“whoami”并返回结果。 The same node application with the same docker container is running on both the machines (ubuntu16 and ubuntu18).具有相同 docker 容器的相同节点应用程序在两台机器(ubuntu16 和 ubuntu18)上运行。

Now, First I tried sending 20 concurrent get request with path "/" to both the machines.现在,首先我尝试向两台机器发送带有路径“/”的 20 个并发获取请求。 And both the machines executed the command in avg of两台机器都执行了平均的命令
35-40ms. 35-40 毫秒。

Now, Second I tried sending 20 concurrent get request with path "/docker" to both the machines.现在,第二个我尝试向两台机器发送 20 个带有路径“/docker”的并发获取请求。 Here, ubuntu16 machine took Max 4.3 seconds and Avg 3 seconds.在这里,ubuntu16 机器花费了 Max 4.3 秒和 Avg 3 秒。 But ubuntu18 machine taking Max 10seconds and Avg 9 seconds.但是 ubuntu18 机器最多需要 10 秒,平均需要 9 秒。

I tried the above test multiple times.我多次尝试上述测试。 and concluded when running process inside docker the time taken to execute is almost double in ubuntu18 machine as compare to ubuntu16.并得出结论,当在 docker 中运行进程时,与 ubuntu16 相比,在 ubuntu18 机器中执行所需的时间几乎翻了一番。

I checked the following:我检查了以下内容:

  1. I tried monitoring through top and htop while hitting 20 requests.我尝试通过tophtop进行监控,同时达到 20 个请求。 But everything seems the same their.但一切似乎都一样。

  2. Also tried monitoring using perf command.还尝试使用perf命令进行监控。 But unable to find any unusual difference their.但无法发现他们有什么异常。 But I am not very used to perf command and so unable to understand clearly.但是我不是很习惯 perf 命令,所以无法理解清楚。

  3. While these 20 requests were in processing.这 20 个请求正在处理中。 I run same docker command manually with strace .我使用strace手动运行相同的 docker 命令。 And found random results ie sometimes time taken in clock_gettime or futex (FUTEX_WAIT) or sometimes in +++ exited with 0 +++ message on ubuntu18.并发现随机结果,即有时在clock_gettimefutex (FUTEX_WAIT)或有时在+++ exited with 0 +++花费的时间在futex (FUTEX_WAIT) +++ exited with 0 +++消息+++ exited with 0 +++ and but less time took on ubuntu16.但在 ubuntu16 上花费的时间更少。


Below are my different configurations and code snippet I am using and running.以下是我正在使用和运行的不同配置和代码片段。

Machine1: Giving better performance.
node    v10.16.0
npm     6.9.0
docker  18.09.8
ubuntu  16.04.3 LTS, xenial

Machine2: Giving poor performance.
node    v10.16.0
npm     6.9.0
docker  18.09.8
ubuntu  18.04.2 LTS, bionic


Node application code snippet:节点应用程序代码片段:

// for path "/docker"
var excuteInDocker = function() {
    var cmd = "docker";
    var args = ["exec", "ubuntu", "whoami"];
    return executeCmd(cmd, args);
}

// for path "/"
var execute = function(){
    var cmd = 'whoami';
    var args = [];
    return executeCmd(cmd, args);
}


Ouput of docker info which are common to both ubuntu 16 and 18: ubuntu 16 和 18 共有的docker info输出:

Containers: 1
 Running: 1
 Paused: 0
 Stopped: 0
Images: 2
Server Version: 18.09.8
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 425e105d5a03fabd737a126ad93d62a9eeede87f
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.296GiB
Name: myhostname
ID: LLLO:OMTS:PNNM:T3MP:AD2F:UMDG:IIZK:OGBO:3ZLL:YDBX:ONAO:AY5G
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 27
 Goroutines: 42
 System Time: 2019-07-25T15:25:54.991694211+05:30
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

WARNING: No swap limit support


docker info specific to ubuntu 16特定于 ubuntu 16 的docker info

Kernel Version: 4.4.0-112-generic
Operating System: Ubuntu 16.04.3 LTS
Total Memory: 7.303GiB
ID: FOFI:RW7N:RZSP:HHKH:BKS3:LMWL:TC2J:W7V2:222Y:Q2AU:XMU3:KLU7


docker info specific to ubuntu 18特定于 ubuntu 18 的docker info

Kernel Version: 4.15.0-1040-aws
Operating System: Ubuntu 18.04.2 LTS
Total Memory: 7.296GiB
ID: LLLO:OMTS:PNNM:T3MP:AD2F:UMDG:IIZK:OGBO:3ZLL:YDBX:ONAO:AY5G

ubuntu16 machine Data: ubuntu16机器数据:

1. Data of time taken in execution 1. 执行时间数据

2019-07-25 14:06:42.851 INFO  uid: 540ae880-aeb7-11e9-919d-dd32b3cf84d5 time: 475 result: {"success":true,"data":"root"}
2019-07-25 14:06:43.183 INFO  uid: 54145e60-aeb7-11e9-919d-dd32b3cf84d5 time: 745 result: {"success":true,"data":"root"}
2019-07-25 14:06:45.711 INFO  uid: 540c4810-aeb7-11e9-919d-dd32b3cf84d5 time: 3326 result: {"success":true,"data":"root"}
.
.
.
2019-07-25 14:06:46.835 INFO  uid: 541d5f10-aeb7-11e9-919d-dd32b3cf84d5 time: 4338 result: {"success":true,"data":"root"}
  1. logs of command strace -t docker exec ubuntu whoami enter image description here命令的日志strace -t docker exec ubuntu whoami在此处输入图像描述

  2. result of perf top --sort comm,dso enter image description here perf top --sort comm,dso在此处输入图像描述的结果


ubuntu18 machine Data: ubuntu18 机器数据:

1. Data of time taken in execution 1. 执行时间数据

2019-07-25 14:07:32.559 INFO  uid: 715a6af0-aeb7-11e9-a5a9-2fffd4e800d1 time: 1008 result: {"success":true,"data":"root"}
2019-07-25 14:07:32.941 INFO  uid: 7178c860-aeb7-11e9-a5a9-2fffd4e800d1 time: 1191 result: {"success":true,"data":"root"}
2019-07-25 14:07:40.363 INFO  uid: 71767e70-aeb7-11e9-a5a9-2fffd4e800d1 time: 8628 result: {"success":true,"data":"root"}
.
.
.
2019-07-25 14:07:41.970 INFO  uid: 718af0d0-aeb7-11e9-a5a9-2fffd4e800d1 time: 10101 result: {"success":true,"data":"root"}

  1. logs of command strace -t docker exec ubuntu whoami enter image description here命令的日志strace -t docker exec ubuntu whoami在此处输入图像描述

  2. result of perf top --sort comm,dso enter image description here perf top --sort comm,dso在此处输入图像描述的结果

So, I need help in debugging what is wrong with docker on the ubuntu18 machine.所以,我需要帮助来调试 ubuntu18 机器上的 docker 出了什么问题。 Or if there is any limitation with docker on ubuntu18 or maybe some machine or docker configuration issue.或者,如果 ubuntu18 上的 docker 有任何限制,或者某些机器或 docker 配置问题。

I did not encounter such a problem on my desktop, but mysql container was running very slowly in a way that I could not understand on my ubuntu laptop.我在台式机上没有遇到过这样的问题,但是 mysql 容器以一种我在 ubuntu 笔记本电脑上无法理解的方式运行得很慢。 This solution solved my problem. 这个解决方案解决了我的问题。

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

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