【问题标题】:Docker sidekiq much slower than native OSDocker sidekiq 比原生操作系统慢得多
【发布时间】: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


    【解决方案1】:

    Docker for Mac 已知某些文件系统密集型工作负载的性能问题。有关官方信息,请参阅 herehere。使用 Mac 安装的卷往往是最差的。在安装中型 Django + 节点项目并尝试让 runserver 命令响应时,我看到了类似的性能下降(剧透,在这种情况下不是很好,fs 开销太大)。

    您可以尝试一些方法,而不是挂载整个应用程序目录,而是尽可能少地挂载。很难说不知道项目是什么样子会有多大帮助。您还应该能够通过不使用绑定挂载来提高性能; COPY 你的文件通过 Dockerfile 进入,然后使用命名卷来持久化它们。这会给您的开发工作流程带来一点阻碍,但我认为这会显着提高 sidekiq 的性能。

    【讨论】:

      猜你喜欢
      • 2012-01-30
      • 1970-01-01
      • 2011-03-01
      • 2014-06-09
      • 2014-05-27
      • 2017-08-30
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多