Servisphere
Amazon Elastic Container Service のアイコン(AWS Architecture Icons)

Amazon Elastic Container Service

コンテナ管理

多数のコンテナ(task/service)を実行・管理する AWS のサービスで、障害時に自動で再起動し、load balancer と連携します。

  • コスト$$ ふつう
  • 難易度●●●●●
  • 未使用でも課金?いいえ
  • AWS マネージド
  • 出題試験SAA · DVA · SOA

範囲: Regional

ECS をマップで開く →
たとえるなら荷物(container)を適切なトラックに積み分ける物流倉庫の配車係のようなものです。

ECS はシステムのどこにある?

マップで全体を見る →

具体例でステップごとに

  1. チームが API を Docker イメージにパッケージし、ECR にプッシュします。
  2. どのイメージを使うか、CPU とメモリ、環境変数、ログの出力先をタスク定義に書きます。
  3. 常に 3 つのタスクを動かす ECS サービスを作成し、Application Load Balancer の後ろに置いて Fargate で実行します。
  4. タスクが失敗すると ECS が新しいタスクを起動し、新バージョンのデプロイ時はタスクを少しずつ入れ替えるので、サイトは止まりません。
  5. アクセスが増えると、サービスの Auto Scaling が CPU に応じてタスク数を増やします。

▶ シナリオ「コンテナアプリケーション」をマップで見る

いつ使う?

✓ 使うべき場面

Kubernetes を学ばずにコンテナアプリケーションを実行したい場合。

✗ 避けるべき場面

チームが Kubernetes に慣れている、またはマルチクラウドで実行する必要がある → EKS。

よくある使い方

  • ALB の背後にあるコンテナ型マイクロサービス
  • SQS から読み取るバックグラウンド処理ワーカー
  • コンテナで実行する Batch ジョブ
  • Kubernetes を学ばずに Docker アプリケーションを AWS に移行

ECS・EKS・Fargate の違い

ECSEKSFargate
概要AWS 独自のコンテナオーケストレーターAWS が管理する標準の Kubernetesサーバー不要のコンテナ実行環境
習得の難しさ低い、概念が少ない高い、Kubernetes の知識が必要低い、ECS か EKS と組み合わせる
固有の料金なしコントロールプレーンの時間料金タスクの vCPU とメモリ
向いている場面AWS だけで使い、シンプルにしたいチームKubernetes に慣れたチーム、複数環境で動かす場合マシンのクラスターを管理したくない場合

料金はいくら?

料金の例Fargate task 2 つ(0.5 vCPU、1 GB)の service を 24 時間 365 日稼働 ≈ $36/月、加えて ALB ≈ $16+/月。
  • 課金方式: ECS 自体は無料です。task を実行する基盤に対して支払います: EC2(マシンの時間単位)または Fargate(vCPU とメモリ GB 単位)。
  • 無料枠: ECS の料金はありません。
⚠️ 料金の落とし穴

task が NAT Gateway 経由で image を pull する(回避するには ECR と S3 の VPC endpoint を使用)。service ごとに別々の ALB。コンテナログの保持期間を設定していない。

料金は us-east-1 の参考値(2026年10月14日 更新)で、変更されている可能性があります。必ず AWS の料金ページでご確認ください。 AWS 公式の料金ページ ↗

💡 試験のコツ

タスクロールはコンテナ内のアプリの権限(S3 の読み取り、DynamoDB への書き込みなど)、タスク実行ロールは ECS が ECR からイメージを取得しログを書き込むための権限です。「サーバー管理不要」なら起動タイプは Fargate を選びます。

本番の試験問題に挑戦

AWS 認定試験は英語でも受験できるため、問題文は英語のまま掲載しています。

1An ecommerce website is deploying its web application as Amazon Elastic Container Service (Amazon ECS) container instances behind an Application Load Balancer (ALB). During periods of high activity, the website slows down and availability is reduced. A solutions architect uses Amazon CloudWatch alarms to receive notifications whenever there is an availability issue so they can scale out resources. Company management wants a solution that automatically responds to such events. Which solution meets these requirements?

  1. ASet up AWS Auto Scaling to scale out the ECS service when there are timeouts on the ALB. Set up AWS Auto Scaling to scale out the ECS cluster when the CPU or memory reservation is too high.
  2. BSet up AWS Auto Scaling to scale out the ECS service when the ALB CPU utilization is too high. Set up AWS Auto Scaling to scale out the ECS cluster when the CPU or memory reservation is too high.
  3. CSet up AWS Auto Scaling to scale out the ECS service when the service's CPU utilization is too high. Set up AWS Auto Scaling to scale out the ECS cluster when the CPU or memory reservation is too high.
  4. DSet up AWS Auto Scaling to scale out the ECS service when the ALB target group CPU utilization is too high. Set up AWS Auto Scaling to scale out the ECS cluster when the CPU or memory reservation is too high.
答えを見る

正解: C

ECS サービスのタスク数はサービス自身の CPU で、クラスターのインスタンス数は CPU/メモリの予約率でスケールさせます。ALB にはスケーリングの基準にできる CPU の指標がありません。

2A company is running a multi-tier web application on premises. The web application is containerized and runs on a number of Linux hosts connected to a PostgreSQL database that contains user records. The operational overhead of maintaining the infrastructure and capacity planning is limiting the company's growth. A solutions architect must improve the application's infrastructure. Which combination of actions should the solutions architect take to accomplish this? (Choose two.)

  1. AMigrate the PostgreSQL database to Amazon Aurora.
  2. BMigrate the web application to be hosted on Amazon EC2 instances.
  3. CSet up an Amazon CloudFront distribution for the web application content.
  4. DSet up Amazon ElastiCache between the web application and the PostgreSQL database.
  5. EMigrate the web application to be hosted on AWS Fargate with Amazon Elastic Container Service (Amazon ECS).
答えを見る

正解: A, E

データベースを Aurora(マネージドサービス)に移し、コンテナを ECS と Fargate で動かせば、運用するサーバーもキャパシティ計画も不要になります。EC2 に移すと、マシンの管理は自分で続けることになります。

Servisphere で 700 問以上を練習する →

よくある質問

ECS は Fargate と EC2 のどちらで動かすのがよいですか?

Fargate はサーバー管理が不要で、タスクごとの CPU とメモリに応じて課金されます。EC2 で動かす場合はインスタンスのクラスターを自分で管理しますが、インスタンスタイプ(GPU を含む)を選べ、大きく安定した負荷では安くなることが多いです。

ECS に料金はかかりますか?

ECS 自体に別料金はありません。コンテナを動かすリソース、つまり Fargate(秒単位の vCPU とメモリ)または EC2 インスタンスと、ロードバランサー、ログ、ストレージなどの料金がかかります。

AWS 認定試験では ECS について何が問われますか?

タスク定義、タスク、サービスの違い、タスクロール(アプリケーションの権限)とタスク実行ロール(イメージの取得やログ書き込みの権限)の違い、Fargate と EC2 の起動タイプの選択、ALB、ECR、CloudWatch Logs との連携などです。

関連サービス

ECS をマップで開く →