首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker sidekiq比本机操作系统慢得多

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

Stack Overflow用户
提问于 2018-02-09 22:26:34
回答 1查看 247关注 0票数 1

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

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

使用docker,相同的后台任务可以在40 seconds中运行。在原生操作系统上,它在12 seconds中运行。我自己试过了,在我的机器上,在原生操作系统上运行,我可以确认它的速度要快得多。

Docker信息:

代码语言:javascript
复制
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 compose:

代码语言:javascript
复制
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%。

感谢您的帮助。

EN

回答 1

Stack Overflow用户

发布于 2018-02-10 01:28:04

Docker for Mac对于某些文件系统密集型工作负载存在已知的性能问题。官方信息请参见herehere。使用Mac挂载的卷往往是最差的。在挂载一个中等大小的Django + node项目并尝试让runserver命令响应时,我也看到过类似的性能影响(搅局,在这种情况下,它不是很好,太多的文件系统开销)。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48707996

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档