

# REL01-BP03 通过架构适应固定服务配额和约束
<a name="rel_manage_service_limits_aware_fixed_limits"></a>

了解不可更改的服务配额、服务约束和物理资源限制。为应用程序和服务设计架构，防止这些限制影响可靠性。

示例包括网络带宽、无服务器函数调用有效负载大小、API Gateway 的节流突发速率，以及并发用户连接至数据库。

 **期望结果：**应用程序或服务在正常流量和高流量条件下按预期执行。它们被设计为在相应资源的固定约束或服务配额的限制范围内工作。

 **常见反模式：**
+ 选择使用一项服务资源的设计时，没有意识到设计存在约束，这些约束将导致扩展时设计失败。
+ 执行不现实的基准测试，并且在测试期间将达到服务固定配额。例如，以突发限制运行测试，但运行时间较长。
+  选择的设计在超过固定服务配额时无法扩展或修改。例如，SQS 有效负载大小为 256 KB。
+  没有设计和实施可观测性，无法监控在高流量事件期间可能面临风险的服务配额阈值并发出警报。

 **建立此最佳实践的好处：**确认应用程序会在所有预计的服务负载水平下运行，不会出现中断或性能下降。

 **在未建立这种最佳实践的情况下暴露的风险等级：**中 

## 实施指导
<a name="implementation-guidance"></a>

 与软服务配额或替换为更高容量单位的资源不同，无法更改 AWS 服务的固定配额。这意味着，在应用程序设计中使用所有这些类型的 AWS 服务时，必须评估是否存在潜在的硬容量限制。

 服务配额控制台中显示了硬限制。如果列显示 `ADJUSTABLE = No`，表示服务存在硬限制。一些资源配置页中也显示了硬限制。像是 Lambda 就具有无法调整的特定硬限制。

 例如，在设计要在 Lambda 函数中运行的 Python 应用程序时，应评估应用程序，确定 Lambda 是否有可能运行超过 15 分钟。如果代码可能运行超过此服务配额限制，则必须考虑替代技术或设计。如果在生产部署后达到此限制，则应用程序将遭受性能下降和中断，直到可以补救为止。与软配额不同，即使出现严重性为 1 的紧急事件，也无法更改这些限制。

 应用程序部署到测试环境之后，应使用策略来查明是否会达到任何硬限制。引入测试计划中应包括压力测试、负载测试和混沌测试。

 **实施步骤** 
+  查看可在应用程序设计阶段使用的 AWS 服务的完整列表。
+  查看所有这些服务的软配额限制和硬配额限制。并非所有限制都会在服务配额控制台中显示。有些服务[在备用位置描述了这些限制](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html)。
+  在设计应用程序时，检查工作负载的业务和技术驱动因素，例如业务成果、应用场景、相依系统、可用性目标和灾难恢复对象。让业务和技术驱动因素指导流程，以确定适合工作负载的分布式系统。
+  分析各个区域和账户的服务负载。服务的许多硬限制基于区域，但有些限制基于账户。
+  分析韧性架构，了解在分区故障和区域故障期间的资源使用情况。在使用“主动/主动”、“主动/被动 – 热”、“主动/被动 – 冷”和“主动/被动 – 指示灯”方法的多区域设计过程中，这些故障情况会导致使用率更高。这会形成达到硬限制的潜在应用场景。

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

 **相关最佳实践：**
+  [REL01-BP01 了解服务配额和约束](rel_manage_service_limits_aware_quotas_and_constraints.md) 
+  [REL01-BP02 跨多个账户和区域管理服务配额](rel_manage_service_limits_limits_considered.md) 
+  [REL01-BP04 监控和管理配额](rel_manage_service_limits_monitor_manage_limits.md) 
+  [REL01-BP05 自动管理配额](rel_manage_service_limits_automated_monitor_limits.md) 
+  [REL01-BP06 确保当前配额与最大使用量之间存在足够的差距来应对失效转移](rel_manage_service_limits_suff_buffer_limits.md) 
+  [REL03-BP01 选择如何划分工作负载](rel_service_architecture_monolith_soa_microservice.md) 
+  [REL10-BP01 将工作负载部署到多个位置](rel_fault_isolation_multiaz_region_system.md) 
+  [REL11-BP01 监控工作负载的所有组件以检测故障](rel_withstand_component_failures_monitoring_health.md) 
+  [REL11-BP03 自动修复所有层](rel_withstand_component_failures_auto_healing_system.md) 
+  [REL12-BP04 使用混沌工程测试韧性](rel_testing_resiliency_failure_injection_resiliency.md) 

 **相关文档：**
+ [AWS Well-Archited Framework 的可靠性支柱：可用性](https://docs.aws.amazon.com/wellarchitected/latest/reliability-pillar/availability.html)
+  [AWS Service Quotas (formerly referred to as service limits)](https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html) 
+  [AWS Trusted Advisor Best Practice Checks](https://aws.amazon.com/premiumsupport/technology/trusted-advisor/best-practice-checklist/)（参见“Service limits”小节） 
+  [AWS Answers 上的 AWS Limit Monitor](https://aws.amazon.com/answers/account-management/limit-monitor/) 
+  [Amazon EC2 Service Limits](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-resource-limits.html) 
+  [What is Service Quotas?](https://docs.aws.amazon.com/servicequotas/latest/userguide/intro.html)
+ [How to Request Quota Increase](https://docs.aws.amazon.com/servicequotas/latest/userguide/request-quota-increase.html)
+ [Service endpoints and quotas](https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html)
+  [Service Quotas User Guide](https://docs.aws.amazon.com/servicequotas/latest/userguide/intro.html) 
+ [适用于 AWS 的配额监控程序](https://aws.amazon.com/solutions/implementations/quota-monitor/)
+ [AWS Fault Isolation Boundaries](https://docs.aws.amazon.com/whitepapers/latest/aws-fault-isolation-boundaries/abstract-and-introduction.html)
+ [Availability with redundancy](https://docs.aws.amazon.com/whitepapers/latest/availability-and-beyond-improving-resilience/availability-with-redundancy.html)
+ [AWS 数据解决方案](https://aws.amazon.com/data/)
+ [什么是持续集成？](https://aws.amazon.com/devops/continuous-integration/)
+ [什么是持续交付？](https://aws.amazon.com/devops/continuous-delivery/)
+ [APN 合作伙伴：可帮助进行配置管理的合作伙伴](https://partners.amazonaws.com/search/partners?keyword=Configuration+Management&ref=wellarchitected)
+ [Managing the account lifecycle in account-per-tenant SaaS environments on AWS](https://aws.amazon.com/blogs/mt/managing-the-account-lifecycle-in-account-per-tenant-saas-environments-on-aws/)
+ [Managing and monitoring API throttling in your workloads](https://aws.amazon.com/blogs/mt/managing-monitoring-api-throttling-in-workloads/)
+ [View AWS Trusted Advisor recommendations at scale with AWS Organizations](https://aws.amazon.com/blogs/mt/organizational-view-for-trusted-advisor/)
+ [Automating Service Limit Increases and Enterprise Support with AWS Control Tower](https://aws.amazon.com/blogs/mt/automating-service-limit-increases-enterprise-support-aws-control-tower/)
+ [ Actions, resources, and condition keys for Service Quotas](https://docs.aws.amazon.com/service-authorization/latest/reference/list_servicequotas.html)

 **相关视频：**
+  [AWS Live re:Inforce 2019 - Service Quotas](https://youtu.be/O9R5dWgtrVo) 
+ [View and Manage Quotas for AWS Services Using Service Quotas](https://www.youtube.com/watch?v=ZTwfIIf35Wc)
+ [AWS IAM Quotas Demo](https://www.youtube.com/watch?v=srJ4jr6M9YQ)
+ [AWS re:Invent 2018: Close Loops and Opening Minds: How to Take Control of Systems, Big and Small](https://www.youtube.com/watch?v=O8xLxNje30M)

 **相关工具：**
+ [AWS CodeDeploy](https://aws.amazon.com/codedeploy/)
+ [AWS CloudTrail](https://aws.amazon.com/cloudtrail/)
+ [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/)
+ [Amazon EventBridge](https://aws.amazon.com/eventbridge/)
+ [Amazon DevOps Guru](https://aws.amazon.com/devops-guru/)
+ [AWS Config](https://aws.amazon.com/config/)
+ [AWS Trusted Advisor](https://aws.amazon.com/premiumsupport/technology/trusted-advisor/)
+ [AWS CDK](https://aws.amazon.com/cdk/)
+ [AWS Systems Manager](https://aws.amazon.com/systems-manager/)
+ [AWS Marketplace](https://aws.amazon.com/marketplace/search/results?searchTerms=CMDB)