Scheduling Amazon ECS Tasks
Amazon EC2 Container Service (Amazon ECS) is a shared state, optimistic concurrency system that provides flexible scheduling capabilities for your tasks and containers. The Amazon ECS schedulers leverage the same cluster state information provided by the Amazon ECS API to make appropriate placement decisions.
Amazon ECS provides a service scheduler (for long-running tasks and applications), the ability to run tasks manually (for batch jobs or single run tasks), with Amazon ECS placing tasks on your cluster for you, and the ability to run tasks on the container instance that you specify, so that you can integrate with custom or third-party schedulers or place a task manually on a specific container instance.
The service scheduler is ideally suited for long running stateless services and applications. The service scheduler ensures that the specified number of tasks are constantly running and reschedules tasks when a task fails (for example, if the underlying container instance fails for some reason). The service scheduler optionally also makes sure that tasks are registered against an Elastic Load Balancing load balancer. You can update your services that are maintained by the service scheduler, such as deploying a new task definition, or changing the running number of desired tasks. By default, the service scheduler spreads tasks across Availability Zones, but you can use task placement strategies and constraints to customize task placement decisions. For more information, see Services.
Manually Running Tasks
RunTask action is ideally suited for processes such as batch jobs
that perform work and then stop. For example, you could have a process call
RunTask when work comes into a queue. The task pulls work from the
queue, performs the work, and then exits. Using
RunTask, you can allow the
default task placement strategy to distribute tasks randomly across your cluster, which
minimizes the chances that a single instance gets a disproportionate number of tasks.
Alternatively, you can use
RunTask to customize how the scheduler places
tasks using task placement strategies and constraints. For more information, see RunTask in the
Amazon EC2 Container Service API Reference.
Amazon ECS allows you to create your own schedulers that meet the needs of your business, or to leverage third party schedulers. Blox is an open source project that gives you more control over how your containerized applications run on Amazon ECS. It enables you to build schedulers and integrate third-party schedulers with Amazon ECS while leveraging Amazon ECS to fully manage and scale your clusters. For more information, see StartTask in the Amazon EC2 Container Service API Reference.
CreateService actions enable you to specify
task placement constraints and task placement strategies to customize how Amazon ECS places
your tasks. For more information, see Amazon ECS Task Placement.