Docker sidekiq比本机操作系统慢得多

时间:2018-02-09 14:26:34

标签: multithreading performance docker sidekiq

我已经使用docker compose运行我的应用程序一段时间了。应用程序中最重要的部分之一是后台任务。

我注意到我的大部分后台任务(使用sidekiq运行)运行速度比我的同事计算机(不使用docker)慢得多。

使用泊坞窗,同一后台任务在40 seconds中运行。在本机操作系统上,它在12 seconds中运行。我自己尝试了这个,在我的机器上运行本机操作系统,我可以确认它的速度要快得多。

Docker信息:

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使用率从未发生过这两个容器的价格超过80%。

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:1)

Docker for Mac已知某些文件系统密集型工作负载的性能问题。有关官方信息,请参阅herehere。 Mac的安装量往往是最差的。我在安装一个中等大小的Django +节点项目并试图让runserver命令响应时看到类似的性能命中(扰流板,在这种情况下它不是很多,fs开销太大)。 / p>

您可以尝试的东西,而不是安装整个应用程序目录,尽可能少地安装。很难说不知道项目的样子会有多大帮助。您还应该能够通过不使用绑定装载来提高性能; {; 1}}您的文件通过Dockerfile,然后使用命名卷来保留它们。这会对您的开发工作流程产生一些影响,但我认为这会大大加快sidekiq的性能。

相关问题