Using ECS to deploy a service running a job scheduling software like Sidekiq or celery

Hello everyone,

it is not clear to me how to deploy a service on ECS which is not a web/http application but piece of software whose work is to schedule and run background jobs. Take for example sidekiq or celery.

What would be the healt-check for such a service? Should it be added to a load balancer?


Related discussions:

Does it have a way to be health checked that isn’t a web request, or a web endpoint callable from inside the container to check it? If so you can use docker health checks defined in the task definition and the ecs agent will perform it. https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_healthcheck

I have a bunch of task running as services that don’t have ALBs or health checks or http, if they crash the container exits and then the service will restart it since it desired count is 1 or more.

I start jobs with cloudwatch event rules

A worker task that merely runs jobs from a queue typically does not need to have a Load Balancer associated with it. If the process provides a health-checking web service, I’d use that for the health check; otherwise one may not be needed if the process is healthy as long as it continues running.

Cool! Thank you! I thought that having an health check was mandatory as well as the load balancer part.

Thank you! Make sense! I’ll do something along your line. I thought that having a health check and balancer was mandatory.

If I were starting a new system, I would just have Lambdas to consume SQS messages, instead of using Celery, which I find to be insufficiently stable for a product of its maturity.

The only requirement for a container, like in docker is that the image has an [ENTRYPOINT].

This entrypoint is a what is sounds like… a bash or shell command that spawns some process.

It is very easy to create a docker image that starts an apache instance, which means your docker container’s life cycle is tied to the lifecycle of the apache web service process.

If you are trying to run a scheduler on a docker container, you will need to do the following:

  1. Make your [ENTRYPOINT] point to some blocking bash script that never exits. This will make the lifecycle of your docker container to be infinite. Alternatively, you can point to a process that already has a daemon like apached and just run a zombie web server if you’re just testing.
  2. If a daemon exists already for your scheduler, then try to hook it up directly as your [ENTRYPOINT]. This will tie your docker container’s lifecycle to the scheduler itself.
  3. If your scheduler/agent doesn’t have a daemon, create a background job that will run to perform your tasks but don’t necessarily tie your docker container’s lifetime to that background job.

This job can also publish logs if necessary, or your can look at logs through cloud watch. You can create a load balancer based on the container’s CPU/Memory usage. You’ll want to spinup new nodes when your hit thresholds, and register them to your scheduler’s cluster.

same here, SNS with or without SQS as subscriber to feed lambdas or, if processing takes too long an ASG running similar workers (polling SQS) in containers. Fargate might be a good alternative for the latter.

no queue service to maintain and monitor, only need to monitor error rates and size of the queue which cloudwatch can do and alert you upon tresholds.