

# REL01-BP04 监控和管理配额
<a name="rel_manage_service_limits_monitor_manage_limits"></a>

 评估可能的使用情况，并适当提高配额，支持使用量按计划增长。

 **期望结果：**部署了可进行管理和监控的主动和自动化系统。这些操作解决方案可确保接近达到配额使用阈值。根据请求的配额更改主动修复这些问题。

 **常见反模式：**
+ 没有配置监控来检查服务配额阈值。
+ 没有为硬限制配置监控，即使这些值不能更改。
+  假定请求和确立软配额变化所需的时间是即时或短时间。
+  配置警报在快达到服务配额时发出警报，但没有关于如何对警报做出响应的流程。
+  只为 AWS 服务配额支持的服务配置警报，不监控其他 AWS 服务。
+  不考虑多区域韧性设计（如“主动/主动”、“主动/被动 – 热”、“主动/被动 – 冷”和“主动/被动 – 指示灯”方法）的配额管理。
+  不评测区域之间的配额差异。
+  不评测每个区域对特定配额提高请求的需求。
+  不利用[模板进行多区域配额管理](https://docs.aws.amazon.com/servicequotas/latest/userguide/organization-templates.html)。

 **建立此最佳实践的好处：**自动跟踪 AWS 服务配额，并根据这些配额监控使用情况，以便了解何时会达到配额限制。您还可以使用此监控数据帮助限制由于配额耗尽而导致的性能下降。

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

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

 对于支持的服务，您可以配置各种能进行评测的不同服务，再通过发送提醒或警报来监控配额。这有助于监控使用情况，并可在接近配额时发出提醒。这些警报可以从 AWS Config、Lambda 函数、Amazon CloudWatch 或 AWS Trusted Advisor 调用。您还可以使用 CloudWatch Logs 上的指标筛选条件来搜索与提取日志中的模式，确定使用量是否快达到配额阈值。

 **实施步骤** 

 监控：
+  获取当前资源使用情况（例如存储桶或实例）。使用 Amazon EC2 `DescribeInstances` API 等服务 API 操作来收集当前资源使用情况信息。
+  使用以下资源获得必要且适用于服务的当前配额：
  +  AWS 服务限额 
  +  AWS Trusted Advisor 
  +  AWS 文档 
  +  AWS 服务特定页面 
  +  AWS Command Line Interface (AWS CLI) 
  +  AWS Cloud Development Kit (AWS CDK) 
+  使用 AWS 服务配额（一项 AWS 服务），帮助您从一个地方管理超过 250 项 AWS 服务的配额。
+  使用 Trusted Advisor 服务限制来监控在各种阈值下的当前服务限制。
+  使用服务配额历史记录（控制台或 AWS CLI）来检查区域增长情况。
+  如果需要，比较每个区域和每个账户中的服务配额变化，形成等效关系。

 管理：
+  自动：设置 AWS Config 自定义规则以扫描各个区域的服务配额，并比较它们之间的差异。
+  自动：设置计划好的 Lambda 函数以扫描各个区域的服务配额，并比较它们之间的差异。
+  手动：通过 AWS CLI、API 或 AWS 控制台来扫描各个区域的服务配额，并比较它们之间的差异。报告差异。
+  如果在不同区域之间发现配额差异，则根据需要请求更改配额。
+  检查所有请求的结果。

## 资源
<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-BP03 通过架构适应固定服务配额和约束](rel_manage_service_limits_aware_fixed_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)