How can I detect and survive being “Slashdotted”?

2019-03-07 15:11发布

What's a good way to survive abnormally high traffic spikes?

My thought is that at some trigger, my website should temporarily switch into a "low bandwidth" mode: switch to basic HTML pages, minimal graphics, disable widgets that might put unnecessary load on the database, and so-on.

My thoughts are:

  • Monitor CPU usage
  • Monitor bandwidth
  • Monitor requests / minute

Edit: I am familiar with options like caching, switching to static content or a content delivery network, and so on as a means to survive, so perhaps the question should focus more on how one detects when the website is about to become overloaded. (Although answers on other survival methods are of course still more than welcome.) Lets say that the website is running Apache on Linux and PHP. This is probably the most common configuration and should allow the maximum number of people to gain assistance from the answers. Lets also assume that expensive options like buying another server and load balancing are unavailable - for most of us at least, a mention on Slashdot is going to be a once-in-a-lifetime occurrence, and not something we can spend money preparing for.

30条回答
▲ chillily
2楼-- · 2019-03-07 15:38

Cache data.

Unnecessary Trips to database to display something that gets displayed the same every load is what kills a server. Write its output to a file and use that instead. Most CMSs and frameworks have caching built in (but you have to turn it on) but rolling your own is not the most challenging task.

查看更多
乱世女痞
3楼-- · 2019-03-07 15:39

I think the premise is wrong: you really really want to get slashdotted, otherwise you wouldn't have a web site in the first place. A much better question is how do you handle the extra traffic? And even that is really two questions:

  1. How do you technically manage the additional server load?
  2. How do you greet the new users, so that you can hopefully get some of them to stick around??
查看更多
虎瘦雄心在
4楼-- · 2019-03-07 15:40

I know with Digg you can contact them and request they blacklist your site. You can probably do the same with Slashdot.

查看更多
Root(大扎)
5楼-- · 2019-03-07 15:40
  1. Don't give anyone the URL
  2. Build something so useless that if rule 1 gets broken nobody will come anyway.
查看更多
Emotional °昔
6楼-- · 2019-03-07 15:40
  1. install munin to monitor load/memory consumption etc and notify on overloads.
  2. install monit to restart apache2 if it crashes
  3. install nginx as apache2 frontend, it will massively decrease memory requirements under heavy load
查看更多
啃猪蹄的小仙女
7楼-- · 2019-03-07 15:43

Make sure your pages support Last-Modified & If-Modified-Since and/or ETag & If-None-Match headers. With these you can avoid many computations and transfers totally.

Search for HTTP conditional GET for more information.

查看更多
登录 后发表回答