Search code examples
amazon-web-servicesamazon-ec2amazon-ecsreact-fullstack

AWS ECS -Best way to deploy a full stack project(Task-Definitions, Clusters & Services)


Hi I want to deploy my full stack project to AWS ECS. If I understand it correctly there are 3 possibilities to deploy frontend and backend in ECS:

  1. Frontend and Backend are in the same Task-Definition, same Cluster and same Service (1 Task-Definition, 1 Cluster, 1 Service)

  2. Frontend and Backend have their own Task-Definition. They are in the same Cluster and running in two Services (2 Task-Definition, 1 Cluster, 2 Services)

  3. Frontend and Backend have their own Task-Definition, their own Cluster and own Service (2 Task-Definition, 2 Cluster, 2 Services)

I already tried the first solution, which worked very well. So what is the best solution to deploy it? What are the pros and cons for each solution?

I also want to develop an app (in the future with the same backend) so I think solution two is therefor better than one. I guess solution one is cheaper because I run less tasks?


Solution

  • There's no reason to split them up into separate clusters. If you are running them on Fargate then separate clusters is pointless. If you are running them on EC2 then separate clusters would actually cost more, with no real benefit.

    Separate services in the same cluster (option 2) is generally the preferred method because you can scale each independently. However if your entire frontend it just serving up some React resources, you could deploy that as a static site on S3.