Amazon ECS Now Supports Per-Container Swap Space Parameters

Posted on: Aug 19, 2019

When using Amazon ECS with the EC2 launch type on Linux, you can now control the use of swap space on a per-container basis. Swap space is used by operating systems such as Linux to allow processes to use more memory than is physically available on the host; the operating system kernel will “swap” physical memory to disk as needed to meet the demands of the software running on the host. Swap space enables applications to use more memory than they otherwise would be able to access, at the cost of higher latency and lower throughput of that memory access. Applications such as those with highly varying memory requirements, but less sensitivity to latency, may benefit from the use of swap memory. 

With per-container swap configuration in ECS, customers can control each container's use of swap. Different containers can have swap enabled or disabled, and for those that have it enabled, the maximum amount of swap used can be limited per container. This means, for example, that latency-critical containers can have swap disabled, whereas containers with high transient memory demands can have swap turned on in order to reduce the likelihood of out-of-memory errors under load. ECS will ensure that each container runs with the desired swap configuration, even if those containers are running on the same EC2 instance. 

The new swap space controls in ECS are available in all regions where ECS is available. You can enable per-container swap controls in your ECS task definitions for tasks running on EC2 Linux instances. To get started, view our documentation.