【发布时间】:2018-07-20 08:26:27
【问题描述】:
我已经使用docker compose 运行我的应用程序一段时间了。应用程序最繁重的部分之一是后台任务。
我注意到我的大多数后台任务(使用sidekiq 运行)运行速度比我同事的一台计算机(不使用 docker)慢得多。
使用 docker,相同的后台任务在 40 seconds 中运行。在本机操作系统上,它在12 seconds 中运行。我自己在我的机器上尝试过,并在本机操作系统上运行它,我可以确认它要快得多。
码头工人信息:
Containers: 14
Running: 4
Paused: 0
Stopped: 10
Images: 42
Server Version: 17.12.0-ce
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 ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.60-linuxkit-aufs
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.786GiB
Name: linuxkit-025000000001
ID: CFFM:EFLI:4A5K:XTPG:E27S:KXJT:26SS:ZAPE:ZAFW:3BRM:E6YK:MVAA
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 76
Goroutines: 129
System Time: 2018-02-09T14:13:44.910242335Z
EventsListeners: 3
HTTP Proxy: docker.for.mac.http.internal:3128
HTTPS Proxy: docker.for.mac.http.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Docker 撰写:
version: '3.4'
services:
sidekiq-1:
build: .
command: bundle exec sidekiq -c 4 -L log/sidekiq-1.log
tty: true
stdin_open: true
volumes:
- '.:/app'
environment:
- DATABASE_URL=postgres://username@postgres/database
- REDIS_URL=redis://redis:6379
sidekiq-2:
build: .
command: bundle exec sidekiq -c 4 -L log/sidekiq-2.log
tty: true
stdin_open: true
volumes:
- '.:/app'
environment:
- DATABASE_URL=postgres://username@postgres/database
- REDIS_URL=redis://redis:6379
我对可能发生的事情有点迷茫。
我注意到的一件事是,即使我已为 docker 分配了 8 个内核,但在 sidekiq 上只有 4 个线程同时运行,而使用 docker stats 的 CPU 使用率从未超过这 2 个的 80%容器。
任何帮助表示赞赏。
【问题讨论】:
标签: multithreading performance docker sidekiq