Long-running task even with autoscaling

0

I would like to scale-out (and scale-in) a node.js application on ECS (Fargate). However, one task (container) should be long-running, should always use the same internal IP and should serve all HTTP requests (the additional tasks will only listen to messages on a SQS queue). Note that the task definition could all be the same (e.g., same image).

Can this be achieved by setting the minimum number of tasks to one or shall I rather create two deployments (one for single master node and one for multiple worker nodes)?

Dunken
已提问 2 个月前150 查看次数
1 回答
0
已接受的回答

To address your requirements for scaling a Node.js application on Amazon ECS (Fargate), it is recommended to create two separate services. One service would be dedicated to hosting the long-running task that should serve all HTTP requests. The other service would be responsible for scaling the additional tasks that listen to messages on the SQS queue.

While it is possible to define a single task definition for both components, following best practices for containerization suggests separating concerns into distinct containers or services. This approach promotes modularity, maintainability, and scalability of the application components.

Please note that in the Fargate, it is not possible to maintain the same internal IP address for a task. Fargate tasks are designed to be ephemeral and dynamic, and their underlying infrastructure (including IP addresses) can change. Therefore, relying on a fixed internal IP address for communication between containers or services is not feasible.

Instead, it is recommended to leverage the built-in service discovery mechanisms provided by AWS, such as DNS resolution (Service Connect or Service Discovery) or load balancers (Application Load Balancer or Network Load Balancer). These mechanisms ensure reliable and scalable communication between services, even as tasks are dynamically scaled or replaced.

By adopting this architecture, you can effectively scale the worker tasks independently while ensuring the long-running task remains available and accessible through a consistent endpoint, facilitating efficient request handling and message processing.

References:

profile pictureAWS
已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则