Data transfer cost - How to make sure the traffic between two ecs task stay private?

0

Hello all!

I am currently running two ECS services: an API and a Web App. The API needs to be accessed by remote hosts as well as the Web App. In an effort to optimize my data transfer costs, I want to keep traffic between the Web App and API private, without having to traverse a NAT Gateway and thus incur additional charges.

I thought of two options to solve this problem, but I'm not sure the first option guarantees that traffic remains private.

Option1: Without private ALB

Option 2: With private ALB

Is the internal ALB needed in my case and ss this a good practice to have a "double setup" for both private and public routing?

Thank's in advance,

2개 답변
0
수락된 답변

Hello.
If the communication is within a service, it is possible to use "service discovery" to communicate without going through the public Internet.
https://docs.aws.amazon.com/AmazonECS/latest/bestpracticesguide/networking-connecting-services.html

Also, a few thoughts on the two options you are proposing.
Option 1 requires a NAT Gateway.
The reason for this is that ALB is created using internet facing, so even if it is registered in the private host zone, the IP address will use the global IP.
Therefore, a NAT Gateway is required for communication.

NAT Gateway is not required for option 2.
The IP address used is a private IP, as it communicates to the internal ALB.
In other words, NAT Gateway is not necessary because the communication is within the VPC.

profile picture
전문가
답변함 10달 전
profile pictureAWS
전문가
검토됨 9달 전
  • Hello, Thank you for your detailed response. I will have a look at service discovery.

0

Hi, why don't you just go directly between ECS Service API and ECS Web App on the private subnet in which both reside ?
That's straightforward and very efficient cost-wise. Best, Didier

profile pictureAWS
전문가
답변함 10달 전
  • Hi, thank you for your response.

    Both services consist of multiple tasks, replicated across various AZ to ensure high availability. As per my understanding, a load balancer is required to distribute the requests evenly among all these tasks.

    Are there any other solutions I might not be aware of?

  • No, you're right a load balancer is best for traffic coming from the outside. But, I was suggesting a different architecture for the internal traffic: a tight coupling between a pair of containers (Service API,Service WebApp) : the WebApp container would declare itself healthy only when its pair is healthy (he'd use the health check of the corresponding + his own to announce healthy or not).

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠