AWS ECS服务垂直扩展

huangapple go评论57阅读模式
英文:

AWS ECS service vertical scaling

问题

  1. 是否可以在内存消耗不需要时缩减扩展的服务?如何操作?
  2. 我们的应用程序缓存数据,作为“最后手段”写回数据库:是否可以配置AWS ECS不要启动新服务,而是首先关闭旧服务,等它完成后再启动新服务?
英文:

This is somewhat follow-up / clarification question of this:

https://stackoverflow.com/questions/59628660/horizontal-and-vertical-autoscaling-with-aws-ecs-fargate

I'm in the same situations, as the OP, and assuming that I'm going with the second answer (Cloudwatch + SNS + Lambda), I have the following questions:

  1. Is it possible, to scale down the up-scaled service, if the memory consumption doesn't needed? How?
  2. Our application caches data, that as "last resort" is written back to database: Is it possible to configure AWS ECS to NOT!!! start a new service than shut down the old one, but FIRST shut down the old service and when it is done, start a new one?

Thank you

答案1

得分: 0

  1. 是否可以在内存消耗不需要的情况下缩小经过放大的服务?如何操作?

是的,您只需要设置第二个CloudWatch警报,当内存消耗低于一定阈值时触发,就像您在内存消耗高于一定阈值时所设置的那样。

  1. 我们的应用程序缓存数据,作为“最后的手段”写回数据库:是否可以配置AWS ECS,不启动新服务,而是首先关闭旧服务,然后再启动新服务?

听起来您只希望最多只有一个服务实例在任何时候运行。并且您需要确保以前的实例已关闭,然后再创建新实例。

您需要将ECS服务的desiredCount设置为1,并将服务的部署配置设置如下:

maximumPercent: 100
minimumHealthyPercent: 0

有了desiredCount1,最大百分比为100,最小健康百分比为0,每当您更新服务的任务定义并触发新的部署时,ECS将首先关闭现有的ECS任务(因为您告诉它您希望最多只有一个运行),然后才会启动更新的ECS任务。

英文:

> 1. Is it possible, to scale down the up-scaled service, if the memory consumption doesn't needed? How?

Yes, you would just need a second CloudWatch alarm to trigger when the memory consumption is below a certain threshold, just like you had for when it was above a certain threshold.

> 2. Our application caches data, that as "last resort" is written back to
> database: Is it possible to configure AWS ECS to NOT!!! start a new
> service than shut down the old one, but FIRST shut down the old
> service and when it is done, start a new one?

It sounds like you only ever want at most one instance of the service running at a time. And you need to make sure the previous instance has shut down, before creating the new instance.

You would need to set the ECS Service's desiredCount to 1, and the service's Deployment Configuration settings as follows:

maximumPercent: 100
minimumHealthyPercent: 0

With a desired count of 1, maximum percent of 100 and minimum healthy percent of 0, whenever you update the service's task definition and trigger a new deployment, ECS will first shutdown the existing ECS task (because you have told it you want at most 1 running at a time) and only then will it start the updated ECS task.

huangapple
  • 本文由 发表于 2023年5月21日 23:06:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76300551.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定