Travis Reeder在Spikability一文中给出了四种应对突发访问的方法:
1. 资源充裕。预先评估峰值,部署足够多的服务器,保证系统可靠运行在任何环境下。缺点是系统空闲时资源利用率低。
2. 功能降级。禁用部分不太重要的功能,保证基本功能的可用性。
3. 自动扩容。当系统繁忙时自动向系统中添加新的服务器并部署应用。缺点是部署复杂,响应不迅速。另外还有一个缺点,当系统访问量不稳定时,可能导致颠簸,有服务器反复上线下线。
4. 请求队列。在突发请求出现的时候,队列会充满。利用充满队列的时间差,可以启用更多的服务器来处理队列上的请求。这么做的好处是不会浪费资源,峰值出现的时候服务器会满负荷运转。缺点是延迟增加了。
参考英文:
2.http://highscalability.com/blog/2012/7/12/4-strategies-for-punching-down-traffic-spikes.html
Travis Reeder in
Spikability - An Application's Ability to Handle Unknown and/or Inconsistent Load
gives four good ways of handling spikey loads:
- Have more resources than you'll ever need. Estimate the maximum traffic you'll need and keep that many servers running. Downside is you are paying for capacity you aren't using.
- Disable features during high loads. Reduce load by disabling features or substituting in lighter weight features. Downside is users to have access to features.
- Auto scaling. Launch new servers in response to load. Downsidesare it's complicated to setup and slow to respond. Random spikes will cause cycling of instances going up and down.
- Use message queues. Queues soak up work requests during traffic spikes. More servers can be started to process work from the queue. Resources aren't wasted and features are disabled. Downside is increased latency.