Do I need AWS Load balancer with nginx in AWS ECS? Do I need AWS Load balancer with nginx in AWS ECS? nginx nginx

Do I need AWS Load balancer with nginx in AWS ECS?


I suggest you start with using the load balancer, because:

  • you can configure SSL at the load balancer and terminate SSL at the load balancer
  • you can protect yourself from malicious attacks by configuring the load balancer to integrate with AWS WAF

  • you could easily add more targets in the future

  • the absence of load balancer requires you to configure SSL at the application level

  • it supports health check.

  • you get free ACM certificate to use with load balancer
  • easy to renew SSL certs every year

Note: consider using AWS S3 and cloudfront to serve your static content

introducing load balancer to your existing architecture

The application load balancer supports host based routing now, which means it makes it possible to use multiple domains (or sub domains) pointing to multiple websites. In addition to host based routing its also supporting path based routing. for e.g while mydomain.com/web1 pointing to website1 , mydomain.com/web2 can point to website2.

I can't think of a reason why you would need to use nginx (unless I am missing something).

So answering to your question, I would do this way.

  • introduce an application load balancer
  • deploy multiple containers via ECS (Fargate)
  • for each service, i will have a target group dedicated to manage scaling and health checks.
  • finally, I would do host based routing, s1.mydomain.com, s2.mydomain.com each pointing to different target groups (one per service)

Reference:https://aws.amazon.com/blogs/aws/new-host-based-routing-support-for-aws-application-load-balancers/

Hope this helps.


As you are saying that

I want to support very huge traffic.

I would expect that at some point you will need to scale your AWS ECS cluster horizontally to multiple instances and at that point, you will need an Elastic Load Balancer to balance your traffic between them.

https://docs.aws.amazon.com/AmazonECS/latest/developerguide///service-load-balancing.html


If this statement is true

I want to support very huge traffic

In addition to ECS tasks, you need to read about different concepts within AWS ECS:

In order to properly use AWS ECS you need to use those services together.