Servisphere
Amazon Simple Queue Service のアイコン(AWS Architecture Icons)

Amazon Simple Queue Service

メッセージキュー

メッセージキューです。送信側が仕事を入れ、受信側が自分で取り出して(poll)処理します。両者が互いの速度に依存しなくなります。

  • コスト$ 安い
  • 難易度●●●●●
  • 未使用でも課金?いいえ
  • サーバーレス
  • 出題試験CLF · SAA · DVA · SOA

範囲: Regional

SQS をマップで開く →
たとえるなら注文受付ポストのようなものです。お客様は注文書を入れるだけで、スタッフは手が空いたときに処理します。

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

マップで全体を見る →

具体例でステップごとに

  1. Web サイトは注文をすぐに受け付けますが、倉庫システムは 1 件の処理に数秒かかります。
  2. Web サイトは倉庫を直接呼ばず、注文を 1 件ずつ SQS キューに入れて、すぐにお客さんへ応答します。
  3. ワーカー(Lambda または EC2)は自分のペースでキューから注文を取り出し、未処理の注文は安全に待機します。
  4. 5 回続けて失敗した注文はデッドレターキューに移され、担当者が確認します。他の注文の処理は止まりません。
  5. セールの日は注文が 20 倍の速さで届きますが、キューが伸び、待機メッセージ数に応じてワーカーが増え、注文は 1 件も失われません。

▶ シナリオ「イベント駆動の画像処理」をマップで見る

いつ使う?

✓ 使うべき場面

システムの疎結合化、バックグラウンド処理、急激な負荷への対応。

✗ 避けるべき場面

1 つのメッセージを同時に複数の宛先に届ける必要がある → SNS / EventBridge。

よくある使い方

  • Web サーバーとバックグラウンド処理ワーカーの分離
  • 負荷の急増時のバッファー
  • 順序を保つ FIFO キュー(注文、決済)
  • 処理に失敗したメッセージを保持する Dead-letter queue

SQS・SNS・EventBridge の違い

SQSSNSEventBridge
種類キュー:処理されるまでメッセージが待つパブリッシュ/サブスクライブ:多数にすぐ配信ルールによるイベントのルーティング
1 メッセージの受信者通常 1 つ多数ルールによる複数のターゲット
メッセージの保持最大 14 日保持しない(数回再送)再生用のアーカイブ
向いている用途疎結合化、急な負荷の吸収通知、ファンアウトAWS/SaaS のイベントへの対応

料金はいくら?

料金の例1,000 万 request/月 ≈ $3.6。
  • 課金方式: 約 $0.40/100 万 request(Standard)、約 $0.50(FIFO)。メッセージの 64 KB ごとに 1 request として計算されます。
  • 無料枠: Always Free: 100 万 request/月。
⚠️ 料金の落とし穴

キューが空でも Short polling は呼び出し続ける — long polling を使いましょう。大きなメッセージは複数の request として課金される。

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

💡 試験のコツ

急なトラフィック増加を吸収するためのコンポーネントの疎結合化なら SQS です。厳密な順序と 1 回だけの処理なら FIFO キュー、失敗を繰り返すメッセージにはデッドレターキュー、二重処理されるなら可視性タイムアウトを延ばし、空の受信を減らすならロングポーリングです。

本番の試験問題に挑戦

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

1A development team is collaborating with another company to create an integrated product. The other company needs to access an Amazon Simple Queue Service (Amazon SQS) queue that is contained in the development team's account. The other company wants to poll the queue without giving up its own account permissions to do so. How should a solutions architect provide access to the SQS queue?

  1. ACreate an instance profile that provides the other company access to the SQS queue.
  2. BCreate an IAM policy that provides the other company access to the SQS queue.
  3. CCreate an SQS access policy that provides the other company access to the SQS queue.
  4. DCreate an Amazon Simple Notification Service (Amazon SNS) access policy that provides the other company access to the SQS queue.
答えを見る

正解: C

相手企業のアカウントにキューの利用を許可する SQS アクセスポリシー(キュー自体に付けるポリシー)を使います。自分のアカウントの IAM ポリシーでは、他のアカウントに権限を与えられません。

2A company is designing an application. The application uses an AWS Lambda function to receive information through Amazon API Gateway and to store the information in an Amazon Aurora PostgreSQL database. During the proof-of-concept stage, the company has to increase the Lambda quotas significantly to handle the high volumes of data that the company needs to load into the database. A solutions architect must recommend a new design to improve scalability and minimize the configuration effort. Which solution will meet these requirements?

  1. ARefactor the Lambda function code to Apache Tomcat code that runs on Amazon EC2 instances. Connect the database by using native Java Database Connectivity (JDBC) drivers.
  2. BChange the platform from Aurora to Amazon DynamoDB. Provision a DynamoDB Accelerator (DAX) cluster. Use the DAX client SDK to point the existing DynamoDB API calls at the DAX cluster.
  3. CSet up two Lambda functions. Configure one function to receive the information. Configure the other function to load the information into the database. Integrate the Lambda functions by using Amazon Simple Notification Service (Amazon SNS).
  4. DSet up two Lambda functions. Configure one function to receive the information. Configure the other function to load the information into the database. Integrate the Lambda functions by using an Amazon Simple Queue Service (Amazon SQS) queue.
答えを見る

正解: D

関数を 2 つに分け、間に SQS キューを置きます。SQS がメッセージを安全に保持し、DB に書き込む関数が制御された速度でバッチ単位に取り出すので、Lambda のクォータを上げる必要がありません。SNS はすぐに配信するため負荷を減らせず、EC2 や DynamoDB への移行は大きな変更で手間がかかります。

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

よくある質問

標準キューと FIFO キューの違いは何ですか?

標準キューはスループットがほぼ無制限ですが、メッセージが複数回届いたり順序が入れ替わったりすることがあります。FIFO キューはメッセージグループ内の順序を厳密に守り、各メッセージを 1 回だけ処理しますが、スループットには上限があります。

SQS の料金はどのように決まりますか?

リクエスト数(送信、受信、削除)で課金され、毎月の無料枠があります。FIFO は標準よりやや高めです。ロングポーリングを使うと空の受信が減り、コストを抑えられます。

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

急なトラフィック増加を吸収するためのコンポーネントの疎結合化、可視性タイムアウト、失敗したメッセージ用のデッドレターキュー、ロングポーリング、標準と FIFO の選択、待機メッセージ数に基づく Auto Scaling などです。

関連サービス

SQS をマップで開く →