Need help?

Our experts have had an average response time of 13.52 minutes in October 2021 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Allocate memory to tasks in ECS – How to do it

by | Aug 19, 2021

Wondering how to allocate memory to tasks in ECS? We can help you.

Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.

Today, let us see how our Support techs assist with this query.

 

How to allocate memory to tasks in ECS?

Amazon ECS uses two parameters for allocating memory to tasks. They are memoryReservation and memory.

The value for each parameter is subtracted from the available memory units of an Amazon ECS container instance when a task is running.

The calculation is based on the soft limit or hard limit of a task definition.

Today, let us see the steps followed by our Support Techs to perform this task.

Before you start, check to see that you have an Amazon ECS cluster that includes an Amazon Elastic Compute Cloud (Amazon EC2) instance.

View the memory allocations of a container instance

  1. Firstly, open the Amazon ECS console.
  2. Then, in the navigation pane, choose Clusters.
  3. Next, choose the cluster that you created.
  4. Choose the ECS Instances view, and then choose the container instance included with the cluster that you created from the Container Instance column.
    Please note the Details pane shows that the memory in the Available column is equal to the memory in the Registered column.
  5. For statistics on the resource usage of the instance, connect to the instance using SSH, and then run the docker stats command.

 

Create a task definition with a soft limit

  1. From the Amazon ECS console, in the navigation pane, choose Task Definitions.
  2. Then, choose Create new Task Definition.
  3. For the launch type, choose EC2, and then choose Next step.
  4. For Task Definition Name, enter a name.
  5. In the Container Definitions section, choose Add container.
  6. Then for Container name, enter a name.
  7. For Image, enter nginx or the appropriate Docker image for your environment.
  8. For Memory Limits (MiB), choose Soft limit, and then enter 700.
  9. Choose Add, and then choose Create.

 

Run the task definition with a soft limit

  1. From the Amazon ECS console, in the navigation pane, choose Clusters, and then choose the cluster that you created.
  2. Choose the Tasks view, and then choose Run new Task.
  3. Then, choose Run Task.
  4. When the Last status column of the task with a soft limit shows as RUNNING, choose Clusters from the navigation pane.
  5. Choose the ECS Instances view, and then choose the instance from the Container Instance column.
  6. For statistics on the resource usage of the instance, connect to the instance using SSH, and then run the docker stats command.
  7. Next, choose Clusters from the navigation pane, and then choose the cluster.
  8. Choose the Tasks view, select the task with a soft limit, and then choose Stop.
  9. Choose the ECS Instances view, and then choose the instance from the Container Instance column.

 

Create a new revision of a task definition with a hard limit

  1. From the Amazon ECS console, in the navigation pane, choose Task Definitions.
  2. Select the task definition that you created with a soft limit, and then choose Create new revision.
  3. In the Container Definitions section, in the Container Name column, choose the container that you added for the task definition with a soft limit.
  4. For Memory Limits (MiB), choose Hard limit, and then enter 1000.
  5. Choose Update, and then choose Create.

 

Run the revised task definition with a hard limit

  1. From the Amazon ECS console, in the navigation pane, choose Clusters, and then choose the cluster that you created.
  2. Choose the Tasks view, and then choose Run new Task.
  3. For Task Definition, choose the task definition with a hard limit that you created, and then choose Run Task.
  4. When the Last status column of the revised task with a hard limit shows as RUNNING, choose Clusters from the navigation pane.
  5. Choose the ECS Instances view, and then choose the instance from the Container Instance column.
  6. For statistics on the resource usage of the instance, connect to the instance using SSH, and then run the docker stats command.
  7. Then, choose Clusters from the navigation pane, and then choose the cluster.
  8. Choose the Tasks view, select the task with a hard limit, and then choose Stop.
  9. Choose the ECS Instances view, and then choose the instance from the Container Instance column.

 

Create a new revision of a task definition with both a soft limit and a hard limit

  1. From the Amazon ECS console, in the navigation pane, choose Task Definitions.
  2. Select the task definition that you created with a hard limit, and then choose Create new revision.
  3. In the Container Definitions section, in the Container Name column, choose the container that you added for the task definition with a hard limit.
  4. For Memory Limits (MiB), choose Soft limit, and then enter 700.
  5. Choose Add Hard limit, and then enter 1200.
  6. Choose Update, and then choose Create.

 

Run the revised task definition with both a soft limit and a hard limit

  1. From the Amazon ECS console, in the navigation pane, choose Clusters, and then choose the cluster that you created.
  2. Choose the Tasks view, and then choose Run new Task.
  3. For Task Definition, choose the task definition that you created with both a soft limit and a hard limit, and then choose Run Task.
  4. When the Last status column of the task shows as RUNNING, choose Clusters from the navigation pane.
  5. Then, choose Clusters from the navigation pane, and then choose the cluster.
  6. Choose the Tasks view, select the task with both a soft limit and a hard limit, and then choose Stop.
  7. Choose the ECS Instances view, and then choose the instance from the Container Instance column.
  8. For statistics on the resource usage of the instance, connect to the instance using SSH, and then run the docker stats command.

 

[Need help with the process? We’d be happy to assist]

 

Conclusion

In short, we saw how our Support Techs allocate memory to tasks in ECS.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF