Search code examples
amazon-web-servicesaws-lambdaamazon-ecsaws-copilot

When to use AWS copilot Worker Service?


I've read the docs about Services and in particular Worker Service. I am confused about when to use the Worker Service.

Say my worker consumes messages from an SNS+SQS which arrive once in three days, but once arrived it may take 15-20 minutes to process all of them (1 message takes no more than 60 seconds to process). So, my worker is kind of idle for most time. Does it mean I need to pay for my worker service even when it is idle? Lambdas seem to be more suitable in this case but the worker service does not use lambdas.

Note: Spots do not work since the jobs are NOT fault-tolerant.


Solution

  • Does it mean I need to pay for my worker service even when it is idle?

    Yes. ECS is charged based on the amount of CPU/RAM you have reserved. You are reserving physical resources for your container, and you will be paying for them regardless of how much you are making use of them. Besides which, your container won't be entirely idle, it will have to be constantly polling SQS.

    If you are deploying to EC2 targets then this may not be a big deal, since you would simply be running another container on an EC2 instance you are already paying for, but if you are deploying to Fargate then it is definitely an added expense.

    Lambdas seem to be more suitable in this case but the worker service does not use lambdas.

    Then I suggest deploying this portion of your application as a Lambda function. Just because you are using Copilot to deploy some containers to AWS doesn't mean you should limit yourself to only using the services supported by CoPilot.