Fargate 中的 vCPU 真正意味着什么? [英] What vCPUs in Fargate really mean?

查看:38
本文介绍了Fargate 中的 vCPU 真正意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在这里此处,但我明白我需要特别了解 Fargate 的实现vCPU.所以我的问题是:

I was trying to get answers on my question here and here, but I understood that I need to know specifically Fargate implementation of vCPUs. So my question is:

  1. 如果我为我的任务分配了 4 个 vCPU,这是否意味着我的在此任务中的容器上运行的单线程应用将能够充分利用所有这些 vCPU,因为它们本质上只是一个我可以使用处理器核心的一部分时间?
  2. 比方说,我为我的任务分配了 4 个 vCPU,但在技术层面上我将 4 个 vCPU 分配给一个可以自由处理一个物理内核线程(甚至更多的超线程).我的逻辑是否正确Fargate 案?
  1. If I allocate 4 vCPUs to my task does that mean that my single-threaded app running on a container in this task will be able to fully use all this vCPUs as they are essentially only a portion of time of the processor's core that I can use?
  2. Let's say, I assigned 4vCPUs to my task, but on a technical level I assigned 4vCPUs to a physical core that can freely process one thread (or even more with hyperthreading). Is my logic correct for the Fargate case?

附言这是一个 node.js 应用程序,它与多个相互交互的玩家运行会话,所以我确实想提供一个具有最大容量的单个 node.js 进程.

p.s. It's a node.js app that runs session with multiple players interacting with each other so I do want to provide a single node.js process with a maximum capacity.

推荐答案

Fargate 在后台使用 ECS(弹性容器服务)来编排 Fargate 容器.ECS 反过来依赖 EC2 提供的计算资源来托管容器.根据 AWS Fargate 常见问题解答:

Fargate uses ECS (Elastic Container Service) in the background to orchestrate Fargate containers. ECS in turn relies on the compute resources provided by EC2 to host containers. According to AWS Fargate FAQ's:

Amazon Elastic Container Service (ECS) 是一种高度可扩展、高性能的容器管理服务,支持 Docker 容器并允许您在 Amazon EC2 实例的托管集群上轻松运行应用程序...

Amazon Elastic Container Service (ECS) is a highly scalable, high performance container management service that supports Docker containers and allows you to easily run applications on a managed cluster of Amazon EC2 instances ...

ECS 使用 Fargate 配置的容器来自动扩展、负载平衡和管理容器的调度

ECS uses containers provisioned by Fargate to automatically scale, load balance, and manage scheduling of your containers

这意味着 vCPU 本质上与 EC2 实例 vCPU 相同.来自文档:

This means that a vCPU is essentially the same as an EC2 instance vCPU. From the docs:

Amazon EC2 实例支持 Intel 超线程技术,该技术允许多个线程在单个 Intel Xeon CPU 内核上并发运行.除 T2 实例外,每个 vCPU 都是一个 Intel Xeon CPU 内核的超线程.

Amazon EC2 instances support Intel Hyper-Threading Technology, which enables multiple threads to run concurrently on a single Intel Xeon CPU core. Each vCPU is a hyperthread of an Intel Xeon CPU core, except for T2 instances.

所以回答你的问题:

  1. 如果将 4 个 vCPU 分配给一个单线程应用程序 - 它只会使用一个 vCPU,因为 vCPU 只是单核的超线程.

  1. If you allocate 4 vCPUs to a single threaded application - it will only ever use one vCPU, since a vCPU is simply a hyperthread of a single core.

当您选择 4 个 vCPU 时,您实际上是在为单个物理内核分配 4 个超线程.因此,您的单线程应用程序仍将仅使用单核.

When you select 4 vCPUs you are essentially assigning 4 hyperthreads to a single physical core. So your single threaded application will still only use a single core.

如果您想要对 CPU 资源进行更细粒度的控制 - 例如分配多个内核(可由单线程应用程序使用) - 您可能必须使用 EC2 启动类型(并管理您自己的服务器)而不是使用 Fargate.

If you want more fine grained control of CPU resources - such as allocating multiple cores (which can be used by a single threaded app) - you will probably have to use the EC2 Launch Type (and manage your own servers) rather than use Fargate.

Edit 2021:评论中指出,大多数 EC2 实例实际上每个 CPU 内核有 2 个超线程.一些专用实例(例如 c6g 和 m6g)每个内核有 1 个线程,但大多数 EC2 实例有 2 个线程/内核.因此,ECS/Fargate 使用的实例很可能每个内核也有 2 个线程.有关更多详细信息,请参阅 doco

Edit 2021: It has been pointed out in the comments that most EC2 instances in fact have 2 hyperthreads per CPU core. Some specialised instances such as the c6g and m6g have 1 thread per core, but the majority of EC2 instances have 2 threads/core. It is therefore likely that the instances used by ECS/Fargate also have 2 threads per core. For more details see doco

这篇关于Fargate 中的 vCPU 真正意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆