Search code examples
amazon-web-servicesaws-lambdaamazon-rdsaws-fargateamazon-ecr

Ideas for application architecture on AWS (ECR + ECS Fargate + RDS + Lambda(?) )


I am a beginner in this and I am trying to figure out what would be the best architecture and workflow for the following use-case (I am using React on front, and nodejs on backend, but this might be irrelevant considering this is a question regarding architecture):

Use-case:

User lands on my page, where I have a table already filled with customers from RDS table. User has an option to either delete a customer (corresponding row) or edit that customer, and all the changes done on frontend should be recorded in a datebase so that next time when user visits the page he/she gets the latest database state. The problem that I have is that I am tasked with implementing this architecture using services such as ECR, ECS ( I opted for Fargate, as serverless solution ), RDS but I have no idea how the workflow should look like and what role would lambdas have in case they are necessary ( or are they? ). Considering also that I need to use RDS, which option PostgreSQL/MySQL/Aurora would be the best fit for this use-case?


What I've tried up till now:

What I've managed to do up till now, is I dockerized my react app (containing the the frontend table where customers will go), pushed it to ECR, created a cluster inside of ECS with a most default task definition holding the ecsTaskExecution Role, a container holding the image from ECR, and a service that's responsible for running the task. I also added Application Load Balancer in front of the ECS cluster so that my react app can be reached from browser (planning to add my personal domain).


Problem:

I am clueless as to who should "speak" to who when it comes to all these individual services, how many containers should I have, are lambdas as functions that will do the deleting & updating needed, or do they only serve as triggers which will leave all the processing to ECS tasks? Basically I am having struggles with imagining the whole picture of the workflow. Any ideas?

Thanks in advance. :)


Solution

  • Well after a few days of experimenting and reading, this is the architecture I came up with:

    ReactJS application hosted on S3, NodeJS application ( Express server ) containerized on docker, pushed to ECR and then on ECS (I choose EC2 Linux + Networking for ECS cluster and then according to that I choose EC2 for Task which is responsible for running my ECR container), while for a database I choose MySQL inside of RDS.

    So basically the communication is happening between S3 -> ECS -> RDS ( ReactJS -> NodeJS -> MySQL ).