AWS Batch
用户指南
AWS 文档中描述的 AWS 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 AWS 服务入门

Memory Management

When the Amazon ECS container agent registers a into a , the agent must determine how much memory the has available to reserve for your s. Because of platform memory overhead and memory occupied by the system kernel, this number is different than the installed memory amount that is advertised for Amazon EC2 instances. For example, an m4.large instance has 8 GiB of installed memory. However, this does not always translate to exactly 8192 MiB of memory available for s when the registers.

If you specify 8192 MiB for the , and none of your s have 8192 MiB or greater of memory available to satisfy this requirement, then the cannot be placed in your .

For more information, see Reserving System Memory.

The Amazon ECS container agent uses the Docker ReadMemInfo() function to query the total memory available to the operating system. Linux command line utilities to determine the total memory.

例 - Determine Linux total memory

The free command returns the total memory that is recognized by the operating system.

$ free -b

Example output for an m4.large instance running the Amazon ECS-optimized Amazon Linux AMI.

total used free shared buffers cached Mem: 8373026816 348180480 8024846336 90112 25534464 205418496 -/+ buffers/cache: 117227520 8255799296

This instance has 8373026816 bytes of total memory, which translates to 7985 MiB available for tasks.

Reserving System Memory

If you occupy all of the memory on a with your s, then it is possible that your s will contend with critical system processes for memory and possibly trigger a system failure. The Amazon ECS container agent provides a configuration variable called ECS_RESERVED_MEMORY, which you can use to remove a specified number of MiB of memory from the pool that is allocated to your s. This effectively reserves that memory for critical system processes.

Viewing Memory

You can view how much memory a registers with in the Amazon ECS console (or with the DescribeContainerInstances API operation). If you are trying to maximize your resource utilization by providing your s as much memory as possible for a particular instance type, you can observe the memory available for that and then assign your s that much memory.

To view memory

  1. Open the Amazon ECS console at https://console.amazonaws.cn/ecs/.

  2. Choose the cluster that hosts your s to view.

  3. Choose ECS Instances, and select a from the Container Instance column to view.

  4. The Resources section shows the registered and available memory for the .

    The Registered memory value is what the registered with Amazon ECS when it was first launched, and the Available memory value is what has not already been allocated to s.