

# SUS03-BP01 非同期のジョブおよびスケジュールされたジョブ向けにソフトウェアとアーキテクチャを最適化する
<a name="sus_sus_software_a2"></a>

キュー駆動型などの効率的なソフトウェアおよびアーキテクチャパターンを使用して、デプロイされたリソースの使用率を一貫して高く維持します。

 **一般的なアンチパターン:** 
+  予期せぬ需要の急増に対応するために、クラウドワークロードのリソースを過剰にプロビジョニングしています。
+  お使いのアーキテクチャでは、メッセージングコンポーネントによって非同期メッセージの送信者と受信者が切り離されていません。

 **このベストプラクティスを活用するメリット:** 
+  効率的なソフトウェアとアーキテクチャのパターンは、ワークロード内の未使用リソースを最小限に抑え、全体的な効率を向上させます。
+  非同期メッセージの受信とは無関係に処理をスケールできます。
+  メッセージングコンポーネントを使用することで、可用性要件が緩和され、より少ないリソースで対応できるようになります。

 **このベストプラクティスを活用しない場合のリスクレベル:** 中 

## 実装のガイダンス
<a name="implementation-guidance"></a>

 [イベント駆動型](https://aws.amazon.com/event-driven-architecture/)アーキテクチャなどの効率的なアーキテクチャパターンを使用すると、コンポーネントの使用率が均等になり、ワークロードのオーバープロビジョニングを抑えます。効率的なアーキテクチャパターンを使用することで、時間の経過に伴う需要の変化により、使用されずにアイドル状態になるリソースを最小限に抑えることができます。

 ワークロードコンポーネントの要件を理解し、リソース全体の利用率を高めるアーキテクチャパターンを採用します。不要になったコンポーネントは廃止します。

### 実装手順
<a name="implementation-steps"></a>
+  ワークロードの需要を分析し、それらに対応する方法を決定します。
+  同期応答を必要としないリクエストやジョブには、キュー駆動型アーキテクチャと自動スケーリングワーカーを使用して使用率を最大化します。キュー駆動型アーキテクチャを検討する場合の例を次に示します。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/wellarchitected/latest/sustainability-pillar/sus_sus_software_a2.html)
+  いつでも処理できるリクエストやジョブについては、スケジューリングメカニズムを利用してジョブをバッチ処理することで効率化を図ります。AWS でのスケジューリングメカニズムの例を次に示します。    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/wellarchitected/latest/sustainability-pillar/sus_sus_software_a2.html)
+  アーキテクチャでポーリングやウェブフックのメカニズムを使用している場合、それらをイベントに置き換えます。[イベント駆動型アーキテクチャを使用して](https://docs.aws.amazon.com/lambda/latest/operatorguide/event-driven-architectures.html)、高効率のワークロードを構築します。
+  [AWS でサーバーレス](https://aws.amazon.com/serverless/)を活用して、過剰にプロビジョニングされたインフラストラクチャを排除します。
+  アーキテクチャの個別のコンポーネントの適切なサイズを設定し、リソースが入力を待ってアイドル状態になるのを防ぎます。
  +  または [AWS Cost Explorer または [AWS Compute Optimizer](https://aws.amazon.com/compute-optimizer/) で適切なサイズ設定に関する推奨事項](https://docs.aws.amazon.com/cost-management/latest/userguide/ce-rightsizing.html)を使用して、適切なサイズ設定の機会を特定できます。
  +  詳細については、「[適切なサイジング: ワークロードに適したインスタンスのプロビジョニング](https://docs.aws.amazon.com/whitepapers/latest/cost-optimization-right-sizing/cost-optimization-right-sizing.html)」を参照してください。

## リソース
<a name="resources"></a>

 **関連ドキュメント:** 
+  [Amazon Simple Queue Service とは](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html) 
+  [Amazon MQ とは](https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/welcome.html) 
+  [Amazon SQS に基づくスケーリング](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-using-sqs-queue.html) 
+  [AWS Step Functions とは](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html) 
+  [AWS Lambda とは](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 
+  [Amazon SQS での AWS Lambda の使用](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html) 
+  [Amazon EventBridge とは](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 
+ [ REST API を使用した非同期ワークフローの管理 ](https://aws.amazon.com/blogs/architecture/managing-asynchronous-workflows-with-a-rest-api/)

 **関連動画:** 
+ [AWS re:Invent 2023 - Navigating the journey to serverless event-driven architecture ](https://www.youtube.com/watch?v=hvGuqHp051c)
+ [AWS re:Invent 2023 - Using serverless for event-driven architecture & domain-driven design ](https://www.youtube.com/watch?v=3foMZJSPMI4)
+ [AWS re:Invent 2023 - Advanced event-driven patterns with Amazon EventBridge ](https://www.youtube.com/watch?v=6X4lSPkn4ps)
+ [AWS re:Invent 2023 - Sustainable architecture: Past, present, and future ](https://www.youtube.com/watch?v=2xpUQ-Q4QcM)
+ [ Asynchronous Message Patterns \$1 AWS Events ](https://www.youtube.com/watch?v=-yJqBuwouZ4)

 **関連する例:** 
+ [AWS Graviton プロセッサと Amazon EC2 スポットインスタンスを使用したイベント駆動型アーキテクチャ ](https://catalog.workshops.aws/well-architected-sustainability/en-US/2-software-and-architecture/event-driven-architecture-with-graviton-spot)