1

I'm running web service on EC2-small which has 2gig memory.

It has soft and hard limit option.

I had set soft limit to 1gig and my server kept crashing when load is high.

Then I found the following SO post, AWS ECS Task Memory Hard and Soft Limits says, it's better to use hard limit if I'm memory bound.

So how high should I set my hard limit for my 2gig memory EC2 machine?

I want my EC2 don't crash and scale up with auto scaling group policy.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
eugene
  • 39,839
  • 68
  • 255
  • 489
  • You set hard limit using `memory` option in [task size](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#task_size) of your task definition. Have you tried that? – Marcin Feb 09 '21 at 09:54

1 Answers1

0

Check how much memory is being used by the instance when no container is running on it, and then set the limit accordingly.

For ubuntu-based instances the OS uses around 400-500MB, so the hard limit would be 1.4G to play safe.

Also, the hard limit ensures that many replicas can't be launched in the same instance if there are not enough resources, whereas the soft limit does not. In other words, you might have a soft limit of 1.5G and two replicas, and both could be run on the same instance. However, a hard limit of 1.5G won't allow two replicas on the same one.