我应该使用 AWS Elastic Bean}还是 Amazon EC2 Container Service (ECS)来扩展 Docker 容器?

我已经开发了一个基于 Docker 的应用程序,它由多个微服务组成。它必须使用 AmazonSQS 消息并处理它们。起初我想使用 AWS Elastic Bean} ,但是后来我迷上了 EC2容器服务。现在我不知道该选哪个了。

到目前为止,Elastic Bean}支持多容器环境。这很棒,因为每个微服务在一个 docker 容器中都有自己的应用服务器。下一个问题是扩张:

我不知道缩放机制是怎么运作的。例如: 我有5个码头容器在我的弹性豆茎环境。现在只有第五个 docker 容器处于重负载下,因为它有大量 SQS 消息要处理,其他四个几乎处于空闲状态,因为它们不需要很多 CPU 或者可能没有很多 SQS 消息。让我们假设第5个容器运行一个 JBoss 应用程序服务器。据我所知,即使有足够的 CPU/内存可用,服务器也只能消耗有限数量的并行请求。

如果 JBoss Docker 容器不能处理大量的请求,但是有足够的 CPU/内存可用,当然我想在同一个实例上自动启动第二个 Docker/JBoss 容器。但是如果我没有足够的 CPU/内存,会发生什么呢?当然,我希望使用第二个实例,它可以通过 EB 中的自动缩放组进行配置。现在第二个实例开始运行,但是除了第5个之外的每个容器都几乎是空闲的,当然我不希望它们在第二个实例中也产生不必要的4,这将是资源的浪费。只有第5个应该产生和其他规模应该像第5规模的基础上配置参数,如: CPU/内存/SQS。

我不知道亚马逊 ECS 是否正在这样做,或者这是否可能,但我真的找不到任何资源在互联网上关于这个主题,这是一般说来,扩展基于实例/容器。

35736 次浏览

EB vs ECS really comes down to control. Do you want to control your scaling and capacity or do you want to have that more abstracted and instead focus primarily on your app. ECS will give you control, as you have to specify the size and number of nodes in the cluster and whether or not auto-scaling should be used. With EB, you simply provide a Dockerfile and EB takes care of scaling your provisioning of number and size of nodes, you basically can forget about the infrastructure with the EB route.

Here's the EB documentation on Docker: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.html

With ECS you'll have to build the infrastructure first before you can start deploying the the Dockerfile so it really comes down to 1) your familiarity with infrastructure and 2) level of effort that you want to spend on the infrastructure vs the app.

Not to resurrect a dead question, but hopefully this helps someone.

The accepted answer is not clear enough: based on what OP described, OP wants ECS, not Multi-Container Elastic Beanstalk (MCEB). As far as I can tell, MCEB never attempts to efficiently pack containers into instances. OP asks in a comment, "if only one is under load, it scales only this one, or does it always scale up the instances and start all containers, no matter under what load they are ?" And the answer is "the latter"; MCEB scales up the instances and starts all containers, no matter what load they are under.

Edit

Don't use the architecture you're imagining.

How micro are your microservices? Would it be ridiculous to give them each a t2.nano? Then make them each a single-container Docker EB app - EB worker applications can be driven by SQS messages.

Edit 1/31/18:

AWS Fargate seems pretty cool.

Edit 6/5/19:

Use EKS if you need to orchestrate containers, to satisfy an itch. But really, try to avoid this. Distributed systems are hard.