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
asked a month ago138 views
1 Answer
0
Accepted Answer

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
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions