Docker容器的运行时性能成本是多少?

本文翻译自:What is the runtime performance cost of a Docker container?

I'd like to comprehensively understand the run-time performance cost of a Docker container. 我想全面了解Docker容器的运行时性能开销。 I've found references to networking anecdotally being ~100µs slower . 我发现网络的参考传闻速度慢了~100μs

I've also found references to the run-time cost being "negligible" and "close to zero" but I'd like to know more precisely what those costs are. 我还发现运行时成本的参考值“可以忽略不计”和“接近于零”,但我想更准确地了解这些成本是多少。 Ideally I'd like to know what Docker is abstracting with a performance cost and things that are abstracted without a performance cost. 理想情况下,我想知道Docker正在以性能成本和抽象的东西进行抽象而没有性能成本。 Networking, CPU, memory, etc. 网络,CPU,内存等

Furthermore, if there are abstraction costs, are there ways to get around the abstraction cost. 此外,如果存在抽象成本,是否有办法绕过抽象成本。 For example, perhaps I can mount a disk directly vs. virtually in Docker. 例如,也许我可以在Docker中直接安装磁盘。


#1楼

参考:https://stackoom.com/question/1TqLF/Docker容器的运行时性能成本是多少


#2楼

Docker isn't virtualization, as such -- instead, it's an abstraction on top of the kernel's support for different process namespaces, device namespaces, etc.; Docker不是虚拟化的 - 相反,它是内核对不同进程命名空间,设备命名空间等的支持的抽象; one namespace isn't inherently more expensive or inefficient than another, so what actually makes Docker have a performance impact is a matter of what's actually in those namespaces. 一个名称空间本身并不比另一个名称空间更昂贵或效率低,所以实际上使Docker产生性能影响的是这些名称空间中实际存在的问题。


Docker's choices in terms of how it configures namespaces for its containers have costs, but those costs are all directly associated with benefits -- you can give them up, but in doing so you also give up the associated benefit: Docker在如何为其容器配置命名空间方面的选择有成本,但这些成本都与好处直接相关 - 您可以放弃它们,但这样做也会放弃相关的好处:

  • Layered filesystems are expensive -- exactly what the costs are vary with each one (and Docker supports multiple backends), and with your usage patterns (merging multiple large directories, or merging a very deep set of filesystems will be particularly expensive), but they're not free. 分层文件系统很昂贵 - 确切地说每个文件的成本各不相同(而Docker支持多个后端),并且使用您的使用模式(合并多个大型目录,或合并一组非常深的文件系统将特别昂贵),但它们'不自由。 On the other hand, a great deal of Docker's functionality -- being able to build guests off other guests in a copy-on-write manner, and getting the storage advantages implicit in same -- ride on paying this cost. 另一方面,Docker的大量功能 - 能够以写入时复制的方式将客人从其他客户身上建立起来,并且隐藏着相同的存储优势 - 可以支付这笔费用。
  • DNAT gets expensive at scale -- but gives you the benefit of being able to configure your guest's networking independently of your host's and have a convenient interface for forwarding only the ports you want between them. DNAT在规模上变得非常昂贵 - 但是您可以独立于主机配置访客的网络,并且只有一个方便的界面来转发您想要的端口。 You can replace this with a bridge to a physical interface, but again, lose the benefit. 您可以将其替换为物理接口的桥接器,但同样会失去优势。
  • Being able to run each software stack with its dependencies installed in the most convenient manner -- independent of the host's distro, libc, and other library versions -- is a great benefit, but needing to load shared libraries more than once (when their versions differ) has the cost you'd expect. 能够以最方便的方式运行每个软件堆栈及其依赖项 - 独立于主机的发行版,libc和其他库版本 - 是一个很大的好处,但需要多次加载共享库(当它们的版本时)不同的)有你期望的成本。

And so forth. 等等。 How much these costs actually impact you in your environment -- with your network access patterns, your memory constraints, etc -- is an item for which it's difficult to provide a generic answer. 这些成本在您的环境中实际影响了多少 - 使用您的网络访问模式,内存限制等 - 是一个难以提供通用答案的项目。


#3楼

Here is an excellent 2014 IBM research paper titled "An Updated Performance Comparison of Virtual Machines and Linux Containers" by Felter et al. 是一篇出色的2014年IBM研究论文,题为“虚拟机和Linux容器的更新性能比较”,作者是Felter等人。 that provides a comparison between bare metal, KVM, and Docker containers. 它提供了裸机,KVM和Docker容器之间的比较。 The general result is that Docker is nearly identical to Native performance and faster than KVM in every category. 一般结果是Docker几乎与Native性能完全相同,并且在每个类别中都比KVM快。

The exception to this is Docker's NAT - if you use port mapping (eg docker run -p 8080:8080 ) then you can expect a minor hit in latency, as shown below. 例外的是Docker的NAT - 如果您使用端口映射(例如docker run -p 8080:8080 ),那么您可以预期延迟会受到轻微影响,如下所示。 However, you can now use the host network stack (eg docker run --net=host ) when launching a Docker container, which will perform identically to the Native column (as shown in the Redis latency results lower down). 但是,您现在可以在启动Docker容器时使用主机网络堆栈(例如docker run --net=host ),该容器将与Native列完全相同(如Redis延迟结果中所示)。

Docker NAT开销

They also ran latency tests on a few specific services, such as Redis. 他们还对一些特定服务(如Redis)进行延迟测试。 You can see that above 20 client threads, highest latency overhead goes Docker NAT, then KVM, then a rough tie between Docker host/native. 您可以看到,20个以上的客户端线程,最高的延迟开销是Docker NAT,然后是KVM,然后是Docker主机/本机之间的粗略关系。

docker Redis延迟开销

Just because it's a really useful paper, here are some other figures. 仅仅因为它是一篇非常有用的论文,这里有一些其他的数字。 Please download it for full access. 请下载它以获得完全访问权限。

Taking a look at Disk IO: 看看磁盘IO:

IO docker vs kvm vs native

Now looking at CPU overhead: 现在看看CPU开销:

docker cpu开销

Now some examples of memory (read the paper for details, memory can be extra tricky) 现在一些内存的例子(详细阅读论文,内存可能会特别棘手)

码头记忆比较


#4楼

Here's some more benchmarks for Docker based memcached server versus host native memcached server using Twemperf benchmark tool https://github.com/twitter/twemperf with 5000 connections and 20k connection rate 这里的一些基准Docker based memcached serverhost native memcached server使用Twemperf基准测试工具https://github.com/twitter/twemperf与5000个连接和20K连接速率

Connect time overhead for docker based memcached seems to agree with above whitepaper at roughly twice native speed. 基于docker的memcached的连接时间开销似乎与上述白皮书大致相当于原生速度的两倍。

Twemperf Docker Memcached

Connection rate: 9817.9 conn/s
Connection time [ms]: avg 341.1 min 73.7 max 396.2 stddev 52.11
Connect time [ms]: avg 55.0 min 1.1 max 103.1 stddev 28.14
Request rate: 83942.7 req/s (0.0 ms/req)
Request size [B]: avg 129.0 min 129.0 max 129.0 stddev 0.00
Response rate: 83942.7 rsp/s (0.0 ms/rsp)
Response size [B]: avg 8.0 min 8.0 max 8.0 stddev 0.00
Response time [ms]: avg 28.6 min 1.2 max 65.0 stddev 0.01
Response time [ms]: p25 24.0 p50 27.0 p75 29.0
Response time [ms]: p95 58.0 p99 62.0 p999 65.0

Twemperf Centmin Mod Memcached

Connection rate: 11419.3 conn/s
Connection time [ms]: avg 200.5 min 0.6 max 263.2 stddev 73.85
Connect time [ms]: avg 26.2 min 0.0 max 53.5 stddev 14.59
Request rate: 114192.6 req/s (0.0 ms/req)
Request size [B]: avg 129.0 min 129.0 max 129.0 stddev 0.00
Response rate: 114192.6 rsp/s (0.0 ms/rsp)
Response size [B]: avg 8.0 min 8.0 max 8.0 stddev 0.00
Response time [ms]: avg 17.4 min 0.0 max 28.8 stddev 0.01
Response time [ms]: p25 12.0 p50 20.0 p75 23.0
Response time [ms]: p95 28.0 p99 28.0 p999 29.0

Here's bencmarks using memtier benchmark tool 这是使用memtier基准工具bencmarks

memtier_benchmark docker Memcached

4         Threads
50        Connections per thread
10000     Requests per thread
Type        Ops/sec     Hits/sec   Misses/sec      Latency       KB/sec
------------------------------------------------------------------------
Sets       16821.99          ---          ---      1.12600      2271.79
Gets      168035.07    159636.00      8399.07      1.12000     23884.00
Totals    184857.06    159636.00      8399.07      1.12100     26155.79

memtier_benchmark Centmin Mod Memcached

4         Threads
50        Connections per thread
10000     Requests per thread
Type        Ops/sec     Hits/sec   Misses/sec      Latency       KB/sec
------------------------------------------------------------------------
Sets       28468.13          ---          ---      0.62300      3844.59
Gets      284368.51    266547.14     17821.36      0.62200     39964.31
Totals    312836.64    266547.14     17821.36      0.62200     43808.90
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Docker容器是一种轻量级、可移植的虚拟化技术。它能够将应用程序及其所有依赖打包成一个独立的、可随时部署的单元,称为容器。与传统的虚拟化技术相比,Docker容器更加灵活、高效,能够快速部署和扩展应用。 容器云(Container Cloud)是建立在云计算基础上的一种基于容器技术的云平台。它能够自动化管理和部署大规模的容器集群,提供资源调度、服务发现、监控等功能,使得应用的开发、测试和部署过程更加简便和高效。 Docker容器容器云之间存在密切的联系和相互依赖。首先,Docker容器作为一种轻量级的容器技术,是容器云平台的基础。容器云平台可以利用Docker容器来实现应用程序的隔离和资源管理,提供统一的管理接口和调度策略。 其次,容器云平台能够进一步增强Docker容器的功能和性能。通过容器云平台,可以实现容器集群的扩容和负载均衡,并提供高可用性和故障恢复的能力。容器云平台还可以提供统一的日志和监控平台,方便运维人员进行容器的管理和故障排查。 最后,Docker容器容器云的结合可以提供更加灵活和高效的应用部署和管理方式。通过Docker容器的打包和发布,可以实现应用在开发、测试和生产环境的无缝迁移,减少了运维的工作量和成本。而容器云平台的自动化管理和扩展能力,则使得应用的部署和升级更加便捷和快速。 综上所述,Docker容器容器云是相辅相成的关系。Docker容器作为一种虚拟化技术,为容器云平台提供了基础;而容器云平台则进一步增强了Docker容器的功能和性能,实现了高效的应用部署和管理。这种结合为企业提供了更加灵活、高效的云计算解决方案。 ### 回答2: Docker容器是一种轻量级的虚拟化技术,可以将应用程序及其依赖项打包在一个可移植的容器中,使其可以在任何环境中运行。容器云是基于云计算的平台,用于管理和部署多个Docker容器Docker容器的特点是轻便、快速、可移植和可靠。它们将应用程序打包成一个独立的单元,可以在不同的计算机和操作系统上运行,而不需要额外的配置和设置。容器不会与系统环境发生冲突,因此可以快速启动和停止,以及实现高效的资源利用。 而容器云是一种更高级的容器管理和部署平台。它可以自动化地管理大量的Docker容器,并提供了更多的功能和服务。容器云可以根据应用程序的需求自动扩展容器的数量,确保应用程序始终具有足够的资源来运行。它还可以提供负载均衡、容器间通信和服务发现等功能,简化了应用程序的开发和部署过程。 容器云还可以提供监控、日志记录和故障恢复等功能,帮助开发人员更好地管理和维护应用程序。它还支持多租户和权限管理,确保不同用户之间的容器隔离和安全性。 总而言之,Docker容器容器云是一对密切相关的概念。Docker容器为应用程序提供了轻量级的虚拟化环境,而容器云则在此基础上提供了更高级的管理和部署功能。它们的结合可以极大地简化应用程序的开发和部署过程,并提高应用程序的可靠性和可扩展性。 ### 回答3: Docker容器是一个轻量级、可移植和可扩展的容器化技术。它允许开发人员将应用程序及其依赖项打包为一个标准化的容器,然后可以在任何支持Docker的环境中运行。 Docker容器的主要优点包括: 1. 灵活性:Docker容器提供了一个独立的运行环境,可以将应用程序及其依赖项打包在一起。这使得应用程序的部署和迁移变得简单和可预测。 2. 资源隔离:每个Docker容器都有自己的文件系统、进程空间和网络接口,这意味着容器之间的应用程序资源相互隔离,可以避免相互干扰。 3. 可拓展性:Docker容器可以快速创建和销毁,并可以自动进行扩展和缩减,以适应更改的负载需求。 容器云是建立在Docker容器技术之上的云计算平台。它可以用来管理和编排大规模的容器集群,并提供一套高级特性,使得容器的部署、监控和扩展变得更加便捷。 容器云的主要功能包括: 1. 集中管理:容器云提供了一个集中化的管理平台,可以轻松地管理和监控大规模容器集群中的所有容器实例。 2. 自动化部署:容器云可以根据用户定义的规则和策略,自动部署和扩展容器实例,以适应不同的负载需求。 3. 服务发现和负载均衡:容器云可以自动发现和管理容器集群中的服务,并提供负载均衡功能,以确保每个容器实例都能够平衡地处理请求。 4. 安全和可靠性:容器云提供了一系列安全措施,如访问控制、容器隔离和自动恢复,以确保容器应用程序的安全和可靠性。 总之,Docker容器容器云是一对密切相关的概念。Docker容器提供了一种轻量级和标准化的打包和部署方式,而容器云则提供了一个管理和编排大规模容器集群的平台,以简化容器的运维工作。通过结合使用这两种技术,开发人员和运维团队可以更高效地部署和管理容器化的应用程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值