可扩展性和弹性
SaaS 中的自动扩展是什么?
什么是自动伸缩?
自动伸缩是一项功能,它会根据当前使用情况调整 SaaS 应用程序的资源,向上或向下调整。当用户增加时,自动伸缩会增加可用资源;反之,在空闲时段会减少资源。 Kubernetes’ Horizontal Pod Autoscaler, for example, checks usage every 15 seconds by default.
SaaS 自动扩展是如何工作的?
SaaS companies need auto-scaling because they often don’t know when traffic is going up or down. While it’s sometimes predictable (e.g., a product launch), sudden global events and unexpected spikes are where auto-scaling should be deployed.
自动扩展对SaaS企业及其客户的主要好处是什么?
Reasons 为了 use auto-scaling in your SaaS business include:
- 性能: 使用自动扩展,以便您的网站或应用程序在繁忙时段能够最佳运行;如果没有它,您可能会遇到服务中断。
- 可用性: Auto-scaling supports the reachability of sites, products, and services as demand fluctuates, while a load balancer manages traffic distribution among auto-scaled servers.
- 成本优化: 使用自动扩展根据实时使用情况进行向上和向下扩展——如果您使用其他方法,则会面临不必要的费用风险。
通常使用哪些指标来触发自动扩展事件?
Auto-scaling is triggered by cloud performance metrics, checked at intervals (every 15 seconds by default in Kubernetes), such as:
- CPU 利用率: 在任何给定时间正在使用的 CPU 量。
- 内存使用量: 应用程序或网站实时使用的内存量。
- 网络流量: Data received and sent over the network.
- 请求延迟: Response times to user requests; this partly depends on how many users are on the same server.
- 队列长度: 待处理的队列请求;当此值较高时,会触发自动向上扩展。
自动扩展策略有哪些不同类型,以及何时使用每种类型?
不同的自动扩展策略适用于不同的场景。以下是一些常见的策略以及您应该何时使用它们:
- 目标追踪: Moves resources based on a metric like average queue length; AWS strongly recommends it for EC2 Auto Scaling (AWS).
- 步进式扩展: Scales within thresholds you set, in steps sized to the breach; use when target tracking is not enough.
- 计划扩缩: 根据计划的时间进行扩展;如果您了解每日或每周的流量模式,请使用此选项。
| 策略类型 | 主要特征 | 最佳用例 |
|
扩展方法 |
||
| 目标跟踪 | 根据特定指标(如平均队列长度)调整资源 | Most cases, per AWS’s EC2 Auto Scaling guide |
| 步进式扩展 | 在用户预设阈值内扩展资源 | When target tracking is not enough |
| 计划扩展 | 在预定时间扩展资源 | 当每日或每周流量模式一致时 |
|
可扩展性注意事项 |
||
| 灵活性 | 目标跟踪:适应性最强 | 计划扩展:灵活性最差 |
有哪些 SaaS 企业成功利用自动扩展来满足波动需求的真实案例?
以下是使用基于需求的自动扩展的 SaaS 公司示例:
- Shopify: Runs microservices on Google Kubernetes Engine, which Google says scales during traffic spikes such as Black Friday (Google Cloud).
- Slack: Autoscales its web app tier quickly when workers become saturated (Slack Engineering, 2020).
- Netflix: Auto-scaling parameters are set to manage traffic when more viewers are online (e.g., evenings,作为 Netflix patent on predictive scaling filed in 2013 describes).
结论
SaaS公司应使用自动扩展来管理高低活动期间的资源。Amazon Web Services、Pepperdata和Google Cloud是三个具有自动扩展功能的工具。请考虑您是否需要目标跟踪、步进扩展或计划扩展。