How to migrate workload from one ec2 instance to another using Boto3

112 Views Asked by At

I have a requirement that says if I have the CPU Utilization of 70% of one EC2 instance It should be scaled up and if I have the CPU Utilization of 30% and at least two EC2 instances it should be scaled down. This is working fine, I can scale up and scale down as it is supposed to be.

But for scenarios in which I have at least two EC2 instances, and one has CPU Utilization of 70% and another one has 30% I should migrate the CPU Workload from the instance with 70% to the one with 30%.

Does anyone know how can I do this using boto3? I've read the EC2 documentation but did not find anything related to this kind of workload migration.

1

There are 1 best solutions below

0
On BEST ANSWER

Does anyone know how can I do this using boto3?

You can't do this in general and that's why you did not find anything about this. This is not how EC2 Autoscaling works, assuming that you are using the scaling as its not stated in your question.

You would have to develop your own, custom solution for such a requirement. And this depends on exactly what is your "workload". It is also not explained in your question so its difficult to even begin recommending something.