AWS EC2 infrastructure

amazon ec2awsdockerMySQLtomcat

I was on a job interview today and one question I faced was:

I have my application running within a docker container on an EC2 instance (AWS Linux 64bit). The docker containers we use for the application (one application per container) connects to an RDS instance and we have the containers set up to auto-scale. What do you think of that set up?

I advised him that a better way may be to have on EC2 instance based on size of customers as he can use AWS's scalable feature to auto scale as needed. He mentioned he tried it this way but yielded slower networking for customers when auto-scaling.

My question is this: Is it more efficient from an architectural point of view, to run scalable EC2 instances running Docker that connect to an RDS? Or is the current setup better?

My reasoning behind using EC2 scalability is because he has auto scalable containers running and that if his EC2 may eventually run out of resources and may cause high CPU utilization from auto scaling too many containers.

He is using Tomcat as his web/application server if that bit of info is useful to this question.

Best Answer

slower networking for customers when auto-scaling

That statement is a bit confusing... but I will assume he meant that scaling events are slower when using EC2 Instances compared to scaling containers.

Launching an EC2 instance is faster than launching a docker container, therefore, it is faster to scale the containers within the OS itself than to scale EC2 instances. If you have to scale up EC2 instances, that means you have to launch a new instance and this takes time depending on the startup process of your system.

But if you are scaling docker containers instead, if you need to scale up, it means launching a new docker container on that same instance and this is way faster than launching a new EC2 instance. This allows applications to respond to quickly respond to scaling events.

I understand your concern about running out of resources on the instance if you scale the containers but... there's nothing stopping you from scaling your EC2 instances too. If you are interested you should check out AWS ECS and how it handles auto-scaling

Related Question