[Part 1] How to deploy a scalable web application

Mindaugas Nakrosis
3 min readOct 24, 2021

Today I will be writing a series consisting of three parts explaining how to deploy a scalable web application through Github Actions to Amazon ECS.

This is Part 1.

Container management with Amazon Elastic Container Service (ECS)

Amazon Elastic Container Service is a fully managed container orchestration service that makes it easy for you to deploy, manage, and scale containerized applications. It is somewhat similar to Kubernetes if you have heard of it.

In this article I will go through how AWS ECS works and what it consists of.

Docker

To understand how ECS works you first need to understand what Dockers and how does it fit into this puzzle.

Docker is a tool used for building, deploying, and managing containerized applications. It enables developers to package applications into containers — standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment. Containers simplify delivery of distributed applications, and have become increasingly popular as organizations shift to cloud-native development and hybrid multicloud environments.

Basically you build a container and then deploy that container to a server you want it to be run. You do not need to take care of any setup prerequisites so that whatever you deploy works — for example Node.js. It is all defined in the container itself.

Elastic Container Service

What is it used for?

As your application grows it becomes increasingly difficult to manage the deployment, structure, scheduling, and scaling of these containers rapidly becomes very complicated. That is where the ECS comes in.

This is where a “container management service” comes in. It aims to allow simple configuration options and handles the heavy lifting while you go back to writing the app.

ECS runs your containers on a cluster of Amazon EC2 virtual machine instances which have Docker already pre-installed. It allows you to simplify your view of all the EC2 instances to a pool of resources, e.g. CPU, memory.
Of course all of this is coupled with Amazon infrastructure and that is not perfect, but it has its pros as well. You don’t have to manage a lot of stuff.

ECS terms and architecture

Task definition is a configuration file that describes how the task should look like. It has a lot of different options that can be configured, the most important being what Docker containers to run.

Task — an instance of task definition. Multiple tasks can be created from a single task definition.

Service — defines a minimum or maximum amount of tasks to be run from one task definition at any given time. Handles load balancing, auto-scaling. For example if memory is maxed out we may add an additional task. We also can limit the maximum amount to save money.

Cluster — a group of EC2 instances. I found a good photo explaining how cluster looks like and what it incorporates.

This is an example ECS cluster, with one Service running four Tasks across two ECS Container Instances.

It is really easy to get mixed up around all these terms. Feel free to explore AWS docs which offers amazing detailed explanations with diagrams.1

Example

Next week I will be writing Part 2 explaining how to setup all of your ECS infrastructure. Keep posted.

Thanks for reading!

--

--