How do i setup a Auto scalling group for my ec2 instance where i am running a docker container??

0

Hello Everyone, I have Ec2 instance of type r6i.large that has 2 vCpu and 16 gb memory in which i am running a fastapi docker container. During the execution, while processing big parts the docker container takes 1 vCpu and 12 gb memory. During this time if any request comes to the fastapi application the request waits for the previous execution to be completed then process it.

Now, i want to setup a architecture where during this execution if a request comes using asg it will scale up another server and process the request there. Then after completion it automatically scale down the server to save the cost. Using asg, i want to scale up another server only when the memory consumption is more than 10 gb and vCpu usage is 1 and another request is waiting in the fastapi application. Can you guys give all the architecture procedure i need to take to achieve this ??

1 Answer
1

Hi,

The right way to do this is to use AWS Fargate, which is the serverless version of AWS ECS : it will scale up and down automatically for you based on activity. And you'll pay only for what you use.

See https://aws.amazon.com/fargate/getting-started/

That would also allow you to get rid of your EC2 instance and its management,

See this tutorial for a global overview and an easy start: https://spacelift.io/blog/what-is-aws-fargate

Best,

Didier

profile pictureAWS
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions