{"id":1842,"date":"2021-02-21T20:34:10","date_gmt":"2021-02-21T13:34:10","guid":{"rendered":"https:\/\/vticloud.io\/?p=1842"},"modified":"2021-09-20T09:42:07","modified_gmt":"2021-09-20T02:42:07","slug":"huong-dan-cho-nguoi-moi-bat-dau-ve-dich-vu-amazon-ecs","status":"publish","type":"post","link":"https:\/\/vticloud.io\/en\/huong-dan-cho-nguoi-moi-bat-dau-ve-dich-vu-amazon-ecs\/","title":{"rendered":"Amazon ECS Service Beginner&#8217;s Guide"},"content":{"rendered":"<p><\/p>\n<p data-renderer-start-pos=\"1\">In the article &#8220;<a href=\"https:\/\/vticloud.io\/aws-phan-hoi-anthos-va-azure-arc-voi-amazon-eks-anywhere\/\">AWS responds to Anthos and Azure Arc with Amazon EKS Anywhere<\/a>&#8220;, VTI Cloud mentions promising new updates of Amazon Web Services (AWS) related to\u00a0<strong data-renderer-mark=\"true\">containers.<\/strong> One of the services centrally focused on by AWS in 2021 is the Amazon Elastic Container Service (Amazon ECS).<\/p>\n<p data-renderer-start-pos=\"304\">This article is an overview for beginners with<strong data-renderer-mark=\"true\">\u00a0Amazon Elastic Container Service (Amazon ECS).<\/strong> VTI Cloud will refer to concepts, core terms, simple architectural diagrams, and summary examples.<\/p>\n<h2 id=\"Tr\u01b0\u1edbc-h\u1ebft,-ch\u00fang-ta-ph\u1ea3i-t\u00ecm-hi\u1ec3u-v\u1ec1-Docker\" data-renderer-start-pos=\"483\">First of all, we have to learn about Docker<\/h2>\n<p data-renderer-start-pos=\"528\">To understand Amazon ECS, we must first\u00a0<span id=\"2c97773b-2ad6-4e27-bd15-2b35e341d8b9\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"2c97773b-2ad6-4e27-bd15-2b35e341d8b9\">understand the concept\u00a0<\/span>of Docker.<\/p>\n<p data-renderer-start-pos=\"605\"><strong data-renderer-mark=\"true\">Docker\u00a0<\/strong>\u2013 a run time container is a software \u2013 a tool that allows building, deploying, packaging applications easily and quickly compared to the previous virtualization architecture. <strong data-renderer-mark=\"true\">Containers\u00a0<\/strong>run\u00a0<em data-renderer-mark=\"true\">by Run Time Containers\u00a0<\/em>such as Docker are a kind of fully packaged software standard library, the source code required to run applications with high stability, availability without concern for physical infrastructure. Many different containers can be run on a host, as long as the host has Docker software installed.<\/p>\n<p data-renderer-start-pos=\"605\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1843\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/docker-vs-vm.png\" alt=\"docker vs vm\" width=\"1024\" height=\"435\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/docker-vs-vm.png 1024w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/docker-vs-vm-300x127.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/docker-vs-vm-768x326.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<h3 id=\"So-s\u00e1nh-Docker-v\u00e0-\u1ea2o-h\u00f3a-(Virtualization)\" data-renderer-start-pos=\"1105\">Compare Docker and Virtualization<\/h3>\n<p data-renderer-start-pos=\"1149\">As you can see in the diagram above, Docker is different from normal Virtualization.\u00a0<strong data-renderer-mark=\"true\">Docker<\/strong>\u00a0is located between the application and the server operating system (OS). Docker can share the host operating system on multiple &#8220;Containers&#8221; instead of asking each person to have and run the operating system separately.<\/p>\n<p data-renderer-start-pos=\"1410\">Each container is full of what an application needs \u2013 for example, certain versions of a language or library \u2013 and no more than it needs. Many containers can be used for different parts of the application if you wish and they can be set up to communicate with each other as needed.<\/p>\n<p data-renderer-start-pos=\"1710\">This allows packing its application into a reusable module, which can run on any machine available. This enables more detailed resource allocation and can minimize the amount of CPU or memory resources wasted.<\/p>\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"1950\"><em data-renderer-mark=\"true\"><strong data-renderer-mark=\"true\">By using the docker container specified to run\u00a0<span id=\"20f3ae98-1107-4f3c-98a5-d135bf2d8602\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"20f3ae98-1107-4f3c-98a5-d135bf2d8602\">production\u00a0<\/span>code, make sure that the dev and production environment are the same.<\/strong><\/em><\/p>\n<h3 id=\"Khi-s\u1ed1-l\u01b0\u1ee3ng-c\u00e1c-container-m\u1edf-r\u1ed9ng-qu\u00e1-nhanh\" data-renderer-start-pos=\"2090\">When the number of containers expands too fast<\/h3>\n<p data-renderer-start-pos=\"2136\">As your application grows, managing deployment, structure, schedule, and expansion of containers for applications quickly becomes very complicated. This is when the container management service was born. It aims to allow simple configuration options and handle non-professional work while you focus on application programming.<\/p>\n<h2 id=\"T\u00ecm-hi\u1ec3u-v\u1ec1-Amazon-ECS\" data-renderer-start-pos=\"2531\">Learn about Amazon ECS<\/h2>\n<p data-renderer-start-pos=\"2555\"><span style=\"color: #ff6600;\">Amazon\u00a0<\/span><a class=\"sc-hXRMBi eMCAAt\" title=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" href=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" data-renderer-mark=\"true\"><span style=\"color: #ff6600;\">Elastic Container Service (Amazon ECS)<\/span><\/a>, as defined by AWS is<\/p>\n<blockquote>\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"2631\">A highly scalability container management service that easily runs, stops, or manages docker containers in a cluster. You can host a serverless infrastructure by running a service or task using Fargate launch type or using EC2 launch type to run EC2 instances.<\/p>\n<\/blockquote>\n<p data-renderer-start-pos=\"2918\">Amazon ECS has been compared to\u00a0<span style=\"color: #ff6600;\"><a class=\"sc-hXRMBi eMCAAt\" style=\"color: #ff6600;\" title=\"https:\/\/kubernetes.io\/\" href=\"https:\/\/kubernetes.io\/\" data-renderer-mark=\"true\">Kubernetes,<\/a>\u00a0<\/span><a class=\"sc-hXRMBi eMCAAt\" title=\"https:\/\/docs.docker.com\/engine\/swarm\/\" href=\"https:\/\/docs.docker.com\/engine\/swarm\/\" data-renderer-mark=\"true\"><span style=\"color: #ff6600;\">Docker Swarm<\/span>,<\/a>\u00a0and\u00a0<span style=\"color: #ff6600;\">Azure\u00a0<a class=\"sc-hXRMBi eMCAAt\" style=\"color: #ff6600;\" title=\"https:\/\/azure.microsoft.com\/en-us\/services\/container-instances\/\" href=\"https:\/\/azure.microsoft.com\/en-us\/services\/container-instances\/\" data-renderer-mark=\"true\">Container Instances.<\/a><\/span><\/p>\n<p data-renderer-start-pos=\"2918\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1844\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/container-in-docker.png\" alt=\"container in docker ecs\" width=\"800\" height=\"395\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/container-in-docker.png 800w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/container-in-docker-300x148.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/container-in-docker-768x379.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p data-renderer-start-pos=\"3005\"><strong data-renderer-mark=\"true\">Amazon ECS\u00a0<\/strong>runs containers in clusters of\u00a0<strong data-renderer-mark=\"true\">many Amazon EC2 instances<\/strong> pre-installed with Docker. It handles container installation, scalability, monitoring, and management of these instances (launch\/stop) through both APIs and AWS management consoles.<\/p>\n<p data-renderer-start-pos=\"3258\">Amazon Elastic Container Service enables to simplify the view of EC2 instances into a resource pool, such as CPU and memory.<\/p>\n<p data-renderer-start-pos=\"3398\">You can use Amazon ECS to install\u00a0<span id=\"87cebd87-d936-451e-b054-f89270bb847f\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"87cebd87-d936-451e-b054-f89270bb847f\">containers<\/span>\u00a0through clusters\u00a0<span id=\"08bcdd33-0774-4379-9b03-9b6c798ae8b5\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"08bcdd33-0774-4379-9b03-9b6c798ae8b5\">and rely on the<\/span>\u00a0resources you need, independent policies, or the ability to change. With Amazon ECS, you don&#8217;t have to operate your own cluster management and configuration management system or worry about expanding your management infrastructure.<\/p>\n<p data-renderer-start-pos=\"3707\">Amazon ECS is a region-based service that simplifies runs container applications across multiple A&#8217;s in the same region. You can create an ECS cluster inside a new or old VPC. After a cluster is initially and run, you can define the\u00a0task and services that it defines the Docker\u00a0<span id=\"3ea8703b-3f62-430d-bfb8-3e99e616b453\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"3ea8703b-3f62-430d-bfb8-3e99e616b453\">container\u00a0<\/span>image that will run through clusters.<\/p>\n<h2 id=\"Thu\u1eadt-ng\u1eef-c\u1ed1t-l\u00f5i-v\u00e0-s\u01a1-\u0111\u1ed3-ki\u1ebfn-tr\u00fac\" data-renderer-start-pos=\"4044\">Amazon ECS core terminology and architectural diagrams<\/h2>\n<p data-renderer-start-pos=\"4082\">Here we come to two new groups of terms:<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"4132\"><strong data-renderer-mark=\"true\">Task Definition<\/strong>,\u00a0<strong data-renderer-mark=\"true\">Task<\/strong>, v\u00e0\u00a0<strong data-renderer-mark=\"true\">Service.<\/strong><\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"4170\"><strong data-renderer-mark=\"true\">ECS Container Instance<\/strong>,<em data-renderer-mark=\"true\">\u00a0<\/em><strong data-renderer-mark=\"true\">ECS Container Agent<\/strong>, v\u00e0\u00a0<strong data-renderer-mark=\"true\">Cluster<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"Task-Definition\" data-renderer-start-pos=\"4230\">Task Definition<\/h3>\n<p data-renderer-start-pos=\"4247\">This is a text file (JSON format). It will describe 1 or more containers (up to 10) to form your application. Task definition will specify a few parameters for the application, such as which container will be used, image used, launch type used, the configuration of the container (CPU and memory)), open port, and what data volume will be created with the container in the task &#8230;<\/p>\n<p data-renderer-start-pos=\"4621\">The parameter in the task definition depends on which launch type is being used. An example of a task definition that contains a container used to run an NGINX web server that uses the<strong data-renderer-mark=\"true\"> Fargate launch type.<\/strong><\/p>\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4810\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">{<\/span><\/span><\/p>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4814\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;family&#8221;: &#8220;webserver&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4839\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;containerDefinitions&#8221;: [<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"2\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4867\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">{<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"3\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4871\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;name&#8221;: &#8220;web&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"3\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4888\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;image&#8221;: &#8220;nginx&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"3\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4908\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;memory&#8221;: &#8220;100&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"3\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4927\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;cpu&#8221;: &#8220;99&#8221;<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"2\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4941\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">},<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4945\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">],<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4950\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;requiresCompatibilities&#8221;: [<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4981\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;FARGATE&#8221;<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4993\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">],<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"4998\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;networkMode&#8221;: &#8220;awsvpc&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"5025\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;memory&#8221;: &#8220;512&#8221;,<\/span><\/span><\/p>\n<\/div>\n<div class=\"fabric-editor-block-mark fabric-editor-indentation-mark\" style=\"padding-left: 40px;\" data-level=\"1\">\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"5044\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span class=\"code\" data-renderer-mark=\"true\">&#8220;cpu&#8221;: &#8220;256&#8221;,<\/span><\/span><\/p>\n<\/div>\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"5060\"><span class=\"code\" data-renderer-mark=\"true\"><span style=\"font-family: arial, helvetica, sans-serif;\">}<\/span><\/span><\/p>\n<h3 id=\"Task-v\u00e0-Schedule\" data-renderer-start-pos=\"5063\">Task and Schedule<\/h3>\n<p data-renderer-start-pos=\"5081\">A task is the initial creation of a task definition inside the cluster. Many different Tasks can be created by a Task Definition, depending on your needs, but specify a certain number of tasks. However, these tasks may be the same.<\/p>\n<div class=\"rich-media-item mediaSingleView-content-wrap image-center sc-ktHwxA krYOxy sc-hEsumM fiAJFr\" data-layout=\"center\" data-node-type=\"mediaSingle\">\n<div class=\"sc-tilXH dYOHpZ\">\n<div class=\"sc-fHxwqH ibJlPX\" data-context-id=\"893321219\" data-type=\"file\" data-node-type=\"media\" data-width=\"800\" data-height=\"480\" data-id=\"118acbe6-fa94-4a77-b6ff-c4b99b2c3aa4\" data-collection=\"contentId-893321219\" data-file-name=\"task in task definition.png\" data-file-size=\"110457\" data-file-mime-type=\"image\/png\">\n<div class=\"sc-iFMziU gbyfgv\" data-testid=\"media-card-view\">\n<div><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1847\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/task-in-task-definition.png\" alt=\"task in ecs task definition\" width=\"800\" height=\"480\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/task-in-task-definition.png 800w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/task-in-task-definition-300x180.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/task-in-task-definition-768x461.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/div>\n<div>\n<p data-renderer-start-pos=\"5317\">For each task using the Fargate launch type, there is a separate boundary and does not share kernel, CPU resources, memory, or elastic network interface with other tasks.<\/p>\n<p data-renderer-start-pos=\"5486\">Amazon ECS task scheduler is responsible for replacing tasks inside the cluster. There are a few different ways to schedule a task<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"5629\">Service schedule<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"5649\">Manually running task<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"5674\">Running task on a cron-like schedule<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"5714\">Custom scheduler<\/p>\n<\/li>\n<\/ul>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1848\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/overview-service-fargate.png\" alt=\"overview-service-fargate\" width=\"728\" height=\"219\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/overview-service-fargate.png 728w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/overview-service-fargate-300x90.png 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/p>\n<h3 id=\"Service\" data-renderer-start-pos=\"5737\">Service<\/h3>\n<p data-renderer-start-pos=\"5746\">Determine the minimum and maximum of one or more Tasks from a Task Definition that runs at any certain time<span id=\"44beda77-aa0b-4433-9712-644a57d375cd\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"44beda77-aa0b-4433-9712-644a57d375cd\">.<\/span><\/p>\n<p data-renderer-start-pos=\"5746\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1849\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/service-in-ecs.png\" alt=\"service in ecs\" width=\"800\" height=\"271\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/service-in-ecs.png 800w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/service-in-ecs-300x102.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/service-in-ecs-768x260.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p data-renderer-start-pos=\"5911\">Now that service is available, Service Tasks need to be run somewhere to be accessible. It needs to be placed on<strong data-renderer-mark=\"true\">\u00a0a Cluster\u00a0<\/strong>and the container management service will handle it when running on one or more\u00a0<strong data-renderer-mark=\"true\">ECS Container Instance(s).<\/strong><\/p>\n<h3 id=\"ECS-Container-Instances-and-ECS-Container-Agents\" data-renderer-start-pos=\"6143\">Amazon ECS Container Instances and Amazon ECS Container\u00a0<a class=\"sc-hXRMBi eMCAAt\" title=\"https:\/\/github.com\/aws\/amazon-ecs-agent\" href=\"https:\/\/github.com\/aws\/amazon-ecs-agent\" data-renderer-mark=\"true\"><u data-renderer-mark=\"true\">Agents<\/u><\/a><\/h3>\n<p data-renderer-start-pos=\"6193\">In the image below is\u00a0<strong data-renderer-mark=\"true\">an EC2 instance<\/strong> that has a\u00a0<strong data-renderer-mark=\"true\">docker engine<\/strong>\u00a0installed and\u00a0<strong data-renderer-mark=\"true\">an ECS Container Agent<\/strong>\u00a0inside. An ECS Container Instance can run multiple Tasks of the same or different breed, from the same or different Services.<\/p>\n<p data-renderer-start-pos=\"6193\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1850\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/fargate-ecs.png\" alt=\"fargate ecs\" width=\"762\" height=\"439\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/fargate-ecs.png 762w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/fargate-ecs-300x173.png 300w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><\/p>\n<p data-renderer-start-pos=\"6402\">The agent is used to support exchange connections between ECS and instances, provide information about running containers, and manage newly created containers.<\/p>\n<h3 id=\"Cluster\" data-renderer-start-pos=\"6555\">Cluster<\/h3>\n<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1851\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/cluster-amazon-ecs.png\" alt=\"cluster amazon ecs\" width=\"800\" height=\"348\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/cluster-amazon-ecs.png 800w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/cluster-amazon-ecs-300x131.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/cluster-amazon-ecs-768x334.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p data-renderer-start-pos=\"6567\">As seen above, a Cluster is a group of ECS Container Instances. Amazon ECS handles the logic of scheduling, maintaining, and processing scalability requests for these instances. Tasks running on ECS are always in the cluster.<\/p>\n<p data-renderer-start-pos=\"6792\"><span id=\"4576e9dc-5236-440b-86e7-02880e615300\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"4576e9dc-5236-440b-86e7-02880e615300\">When tasks are run on Fargate, cluster resources are managed by Fargate. When using the EC2 launch type, clusters are ECS Container Instance groups (powered by EC2 instances).<\/span><\/p>\n<blockquote>\n<p style=\"padding-left: 40px;\" data-renderer-start-pos=\"7000\">See more on Cluster in AWS Documentation:<span style=\"color: #ff6600;\"><a class=\"sc-hXRMBi eMCAAt\" style=\"color: #ff6600;\" title=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" href=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" data-renderer-mark=\"true\">What is Amazon Elastic Container Service? &#8211; Amazon Elastic Container Service<\/a><\/span><\/p>\n<\/blockquote>\n<p data-renderer-start-pos=\"7129\">A Cluster can run multiple Services. If your product has multiple apps, then you can put some of these apps in a Cluster. This makes it more efficient to use available resources and minimizes setup time compared to traditional management models.<\/p>\n<\/div>\n<p data-renderer-start-pos=\"7129\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1852\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/services-in-a-cluster.png\" alt=\"services in a cluster\" width=\"800\" height=\"233\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/services-in-a-cluster.png 800w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/services-in-a-cluster-300x87.png 300w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/services-in-a-cluster-768x224.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p data-renderer-start-pos=\"7384\">Amazon ECS loads your image containers from the registry you set up earlier and then runs these images in your cluster:<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"7523\">Cluster there Region-specifi<span id=\"43c9f86c-ce15-4c92-872b-4e0da8712250\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"43c9f86c-ce15-4c92-872b-4e0da8712250\">c<\/span>.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"7554\">Cluster can contain many tasks using both Fargate launch type and EC2 launch type.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"7640\">When tasks use EC2 launch type, clusters can contain many different ECS Container Instances. At the same time, an ECS Container Instance belongs to only one cluster.<\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"7833\">You can create a custom IAM policy for cluster enabled or limit user access to cluster<span id=\"ce2c0e3d-49c9-4079-9f1a-a06a04eb0e8e\" data-renderer-mark=\"true\" data-mark-type=\"annotation\" data-mark-annotation-type=\"inlineComment\" data-id=\"ce2c0e3d-49c9-4079-9f1a-a06a04eb0e8e\">s.<\/span><\/p>\n<\/li>\n<\/ul>\n<h2 id=\"C\u00e1c-tr\u01b0\u1eddng-h\u1ee3p-s\u1eed-d\u1ee5ng-EC2-launch-type\" data-renderer-start-pos=\"7934\">EC2 launch type use cases in Amazon ECS<\/h2>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"7976\"><strong data-renderer-mark=\"true\">The workload is big, but still wants to save costs<\/strong><\/p>\n<\/li>\n<\/ul>\n<p data-renderer-start-pos=\"8026\">When an application needs a high CPU and multiple GB of memory and an optimal desire for AWS costs, it is possible to use clusters of reserved EC2 instances or EC2 spot instances.<\/p>\n<p data-renderer-start-pos=\"8217\">You&#8217;ll be responsible for maintaining and optimizing this cluster, but the advantage of Amazon EC2 will save quite a bit of cost (when using spot or reserved instance)<\/p>\n<h2 data-renderer-start-pos=\"8382\">Cases of using Fargate launch type in Amazon ECS<\/h2>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"8428\"><strong data-renderer-mark=\"true\">Test environment<\/strong><\/p>\n<\/li>\n<\/ul>\n<p data-renderer-start-pos=\"8447\">With testing environments that don&#8217;t require too much workload, using AWS Fargate serverless services instead of EC2 instance services will help you get the most out of your resources.<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"8632\"><strong data-renderer-mark=\"true\">The workload environment is small, but occasionally there is a sudden increase (burst)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p data-renderer-start-pos=\"8704\">When workloads are small but occasionally have occasional spikes, such as traffic or requests unexpectedly increasing during the day and low at night, using the Fargate launch type will be more advantaged.<\/p>\n<p data-renderer-start-pos=\"8908\">Because Fargate can scale up resources from a tiny night container (extremely low cost) for responding to daytime spikes that simply pay for CPU core and GB of on-demand memory.<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"9095\"><strong data-renderer-mark=\"true\">Large workload, but does not want to consume resources for operation (Overhead cost)<\/strong><\/p>\n<\/li>\n<\/ul>\n<p data-renderer-start-pos=\"9177\">Operating a cluster of multiple EC2 instances takes a lot of effort and time, as you must ensure the latest patching, security, and update of docker and ECS Agent instances. At this point, Fargate would be the best option!<\/p>\n<p data-renderer-start-pos=\"9411\">The reason is that this serverless service is automatically protected by AWS engineers behind and patches and updates from AWS infrastructure without businesses bothering.<\/p>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"9591\"><strong data-renderer-mark=\"true\">Periodical workload<\/strong><\/p>\n<\/li>\n<\/ul>\n<p data-renderer-start-pos=\"9611\">When the system always has to run tasks periodically, such as cron jobs (hourly or occasionally) from the queue, AWS Fargate will provide the most stable support for the system. Instead of having to restart ec2 instances after these tasks while running and still being charged when EC2 instances are turned off, Fargate is only charged while in run mode.<\/p>\n<h2 id=\"K\u1ebft-lu\u1eadn\" data-renderer-start-pos=\"9937\">Conclusion<\/h2>\n<p data-renderer-start-pos=\"9947\">We&#8217;ve seen how an application running on Docker can be performed using Task Definition and has a 1:1 relationship with a Service, thereby using Task Definition to create a variety of Task instances.<\/p>\n<p data-renderer-start-pos=\"10150\">The service is deployed to a Cluster of ECS Container Instances, providing the pool of resources needed to run and extend the application. Additional Services can be deployed to the same Cluster.<\/p>\n<p data-renderer-start-pos=\"10352\">Amazon ECS, or any container management service, will aim to simplify as much as possible, eliminating many of the complexities of operating infrastructure at scale.<\/p>\n<p data-renderer-start-pos=\"10352\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1853\" src=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/amazon-ecs-cluster.png\" alt=\"amazon ecs cluster\" width=\"628\" height=\"552\" srcset=\"https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/amazon-ecs-cluster.png 628w, https:\/\/vticloud.io\/wp-content\/uploads\/2021\/02\/amazon-ecs-cluster-300x264.png 300w\" sizes=\"(max-width: 628px) 100vw, 628px\" \/><\/p>\n<p data-renderer-start-pos=\"10524\">As the needs of the system become more complex, container management services will ensure easy management of the system. By using APIs or Management Consoles, you can come up with Task definitions to add new ECS Container Instances as needed. This ensures that there are always a number of Tasks running and all alluring resources intelligently across the Services.<\/p>\n<p data-renderer-start-pos=\"10524\">The case study of Deliveroo that leverages the Amazon ECS&#8217;s benefits are shown at this link: <a href=\"https:\/\/vticloud.io\/en\/case_study\/deliveroo-cat-giam-hon-50-chi-phi-van-hanh-cung-aws\/\">Deliveroo &#8211; Reduce operating costs by more than 50% with AWS | VTI CLOUD<\/a><\/p>\n<h3 id=\"Ngu\u1ed3n:\" data-renderer-start-pos=\"10881\">Reference:\u00a0<\/h3>\n<ul class=\"ak-ul\" data-indent-level=\"1\">\n<li>\n<p data-renderer-start-pos=\"10892\"><a class=\"sc-hXRMBi eMCAAt\" title=\"https:\/\/www.freecodecamp.org\/news\/amazon-ecs-terms-and-architecture-807d8c4960fd\/\" href=\"https:\/\/www.freecodecamp.org\/news\/amazon-ecs-terms-and-architecture-807d8c4960fd\/\" data-renderer-mark=\"true\">A beginner\u2019s guide to Amazon\u2019s Elastic Container Service (freecodecamp.org)<\/a><\/p>\n<\/li>\n<li>\n<p data-renderer-start-pos=\"10971\"><a class=\"sc-hXRMBi eMCAAt\" title=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" href=\"https:\/\/docs.aws.amazon.com\/AmazonECS\/latest\/developerguide\/Welcome.html\" data-renderer-mark=\"true\">What is Amazon Elastic Container Service? &#8211; Amazon Elastic Container Service<\/a><\/p>\n<\/li>\n<\/ul>\n<h2>About VTI Cloud<\/h2>\n<p data-renderer-start-pos=\"6835\"><strong data-renderer-mark=\"true\">VTI Cloud<\/strong>\u00a0is an\u00a0<span style=\"color: #ff6600;\"><a class=\"sc-iELTvK jHUAie\" style=\"color: #ff6600;\" title=\"https:\/\/vticloud.io\/news_events\/vti-cloud-chinh-thuc-tro-thanh-advanced-consulting-partner-cua-aws\/\" href=\"https:\/\/vticloud.io\/news_events\/vti-cloud-chinh-thuc-tro-thanh-advanced-consulting-partner-cua-aws\/\" data-renderer-mark=\"true\">Advanced Consulting Partner<\/a>\u00a0<\/span>of AWS Vietnam with a team of over 50+ AWS certified solution engineers. With the desire to support customers in the journey of digital transformation and migration to the AWS cloud, VTI Cloud is proud to be a pioneer in consulting solutions, developing software, and deploying AWS infrastructure to customers<strong data-renderer-mark=\"true\">\u00a0in Vietnam<\/strong>\u00a0<strong data-renderer-mark=\"true\">and Japan.<\/strong><\/p>\n<p data-renderer-start-pos=\"7217\">Building safe, high-performance, flexible, and cost-effective architectures for customers is\u00a0<strong data-renderer-mark=\"true\">VTI Cloud\u2019s<\/strong>\u00a0leading mission in enterprise technology mission.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>In the article &#8220;AWS responds to Anthos and Azure Arc with Amazon EKS Anywhere&#8220;, VTI Cloud mentions promising new updates of Amazon Web Services (AWS) related to\u00a0containers. One of the services centrally focused on by AWS in 2021 is the Amazon Elastic Container Service (Amazon ECS). This article is an overview for beginners with\u00a0Amazon Elastic [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":1856,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[52,108],"_links":{"self":[{"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/posts\/1842"}],"collection":[{"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/comments?post=1842"}],"version-history":[{"count":1,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/posts\/1842\/revisions"}],"predecessor-version":[{"id":3156,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/posts\/1842\/revisions\/3156"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/media\/1856"}],"wp:attachment":[{"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/media?parent=1842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/categories?post=1842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vticloud.io\/en\/wp-json\/wp\/v2\/tags?post=1842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}