0 votes
1 view
in AWS by (18.1k points)

I have an AWS t2.micro EC2 instance with docker on it, and I bring up the following instances;

Which results in something like this docker stats;

CONTAINER   MEM USAGE/LIMIT     MEM % 

wordpress   331.9 MB/1.045 GB   31.77%

nginx       18.32 MB/1.045 GB   1.75% 

mysql       172.1 MB/1.045 GB   16.48%

Then, I run siege's default 15 concurrent connections against it, which spawns multiple apache processes, reaching the memory limit of the EC2 instance, crashing docker and bash due to no more memory, requiring my intervention to get it all running again.

I have a couple of questions regarding this.

Am I expecting too much? Should this setup be able to handle 15 concurrent connections? If so, what changes* need to be made?

How can I automate recovery from this? Is there a way to detect that memory is reaching capacity and do something (like reject requests or similar) until memory usage decreases? Is there a way to keep the system stable during the high request volume so once it's over it does not require my intervention to bring it back up?

* I've already done this to drop mysql memory from 22% to 15%.

1 Answer

0 votes
by (42.2k points)

You can try limiting the max memory usage on each container because each Docker container takes up 1 GB itself, but t2.micro's total RAM is 1 GB so this might happen. Check this out - http://docs.docker.com/engine/reference/run/#user-memory-constraints. You can do something that will not allow the memory limit to not exceed 1 GB.

...