

# 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/zh_cn/wellarchitected/latest/framework/sus_sus_software_a2.html)
+  对于可以随时处理的请求或作业，请使用调度机制批量处理作业以提高效率。以下是 AWS 上的调度机制的一些示例：    
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_cn/wellarchitected/latest/framework/sus_sus_software_a2.html)
+  如果在架构中使用轮询和 Webhook 机制，请将它们替换为事件。使用[事件驱动型架构](https://docs.aws.amazon.com/lambda/latest/operatorguide/event-driven-architectures.html)来构建高效的工作负载。
+  利用 [AWS 上的无服务器架构](https://aws.amazon.com/serverless/)消除过度预置的基础设施。
+  适当调整架构中各个组件的大小，以防止等待输入的闲置资源。
  +  您可以使用 [AWS Cost Explorer 中的合理调整大小建议](https://docs.aws.amazon.com/cost-management/latest/userguide/ce-rightsizing.html)或 [AWS Compute Optimizer](https://aws.amazon.com/compute-optimizer/) 来确定合理调整大小的机会。
  +  有关更多详细信息，请参阅《[合理调整大小：预置实例以匹配工作负载](https://docs.aws.amazon.com/whitepapers/latest/cost-optimization-right-sizing/cost-optimization-right-sizing.html)》。

## 资源
<a name="resources"></a>

 **相关文档：**
+  [What is 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) 
+  [将 AWS Lambda 与 Amazon SQS 结合使用](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)
+ [异步消息模式 \$1 AWS 事件](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)