对于未知或意外事件,例如需求或流量的突然激增,您可以使用自动扩缩功能来触发基于指标的弹性扩缩。这些指标可能包括 CPU 利用率、负载平衡器传送容量、延迟时间,甚至是您在 Cloud Monitoring 中定义的自定义指标。
例如,假设某个应用在 Compute Engine 托管式实例组 (MIG) 上运行。此应用要求每个实例以最佳性能运行,直到平均 CPU 利用率达到 75%。在此示例中,您可以定义一个自动扩缩政策,以便在 CPU 利用率达到阈值时创建更多实例。这些新创建的实例有助于吸收负载,这有助于确保平均 CPU 利用率保持在最佳速率,直到达到您为 MIG 配置的实例数上限。当需求减少时,自动扩缩政策会移除不再需要的实例。
如果您的系统组件包含 Compute Engine,则必须评估预测性自动扩缩是否适合您的工作负载。预测性自动扩缩功能会根据指标的历史趋势(例如 CPU 利用率)来预测未来的负载。预测每隔几分钟重新计算一次,因此自动扩缩器会根据最近的负载变化快速调整预测。如果没有预测性自动扩缩,自动扩缩器只能根据观察到的实时负载变化被动扩缩组。预测性自动扩缩可处理实时数据和历史数据,以响应当前负载和预测负载。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2024-12-06。"],[[["Elasticity allows systems to dynamically adjust resources based on workload changes, enabling independent scaling of different components for improved performance and cost efficiency."],["Systems should be designed to scale both horizontally by adding replica nodes and vertically by increasing capacity, memory, and storage, in response to increases and decreases in load."],["Planning for peak load periods involves manually scaling systems ahead of known high-traffic events, and using autoscaling for unexpected surges, triggered by metrics like CPU utilization."],["Predictive autoscaling can be used in Compute Engine, which forecasts future load based on historical trends and adapts rapidly to recent changes in load, improving responsiveness."],["Implementing serverless architectures, such as Cloud Run, BigQuery, and Spanner, provides inherent elasticity with instant autoscaling that can scale down to zero resources, and using Autopilot mode in GKE provides automation and scalability by default."]]],[]]