How can I detect and survive being “Slashdotted”?

前端 未结 24 1825
半阙折子戏
半阙折子戏 2021-01-29 21:19

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: swi

相关标签:
24条回答
  • 2021-01-29 21:37

    Increase the level of caching from the DB so that the content might me slightly more out of date but faster accessed. Naturally, this only applies if the content does not have to be 100% consistent.

    0 讨论(0)
  • 2021-01-29 21:38

    The basics:

    1. Don't try to host high-volume sites on Windows unless you are a true Windows guru. It can be done, but it's a time versus cost issue.
    2. Use static content (i.e., no database queries) everywhere you can.
    3. Learn about cache-control headers and use them properly for images and other static assets.
    4. At the very least, use Apache, but if you can, use lighttpd or another high-performance webserver.

    The real answers:

    1. Really know your SQL, and spend time analyzing slow queries. Most page loads shouldn't require more than a second of straight queries.
    2. Determine where your load really is. If it's a media-heavy site, consider hosting content elsewhere (like Akamai, or some other service). If it's a database-heavy site, consider replication.
    3. Know what kind of replication will work for you. If you have a read-heavy site, standard MySQL master/slave replication should be fine. If you have a lot of writes going on, you'll need some kind of multi-master setup, like MySQL Cluster (or investigate 'cascading' or 'waterfall' replication).
    4. If you can, avoid calling PHP - i.e. have a cached static (HTML) copy of the page (which is what most of the Wordpress caching plugins do). Apache is much faster serving static files than even the simplest hello world PHP script.
    0 讨论(0)
  • 2021-01-29 21:40

    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.

    0 讨论(0)
  • 2021-01-29 21:41

    Make sure all pages you build are static, no database, and don't use images.

    Actually, this place isn't doing THAT bad.

    0 讨论(0)
  • 2021-01-29 21:42

    Here's a rather lengthy but highly informative article about surviving "flash crowds".

    Here's their scenario for the situation their proposed solutions address:

    In this paper, we consider the question of scaling through the eyes of a character we call the garage innovator. The garage innovator is creative, technically savvy, and ambitious. She has a great idea for the Next Big Thing on the web and implements it using some spare servers sitting out in the garage. The service is up and running, draws new visitors from time to time, and makes some meager income from advertising and subscriptions. Someday, perhaps, her site will hit the jackpot. Maybe it will reach the front page of Slashdot or Digg; maybe Valleywag or the New York Times will mention it.

    Our innovator may get only one shot at widespread publicity. If and when that happens, tens of thousands of people will visit her site. Since her idea is so novel, many will become revenue-generating customers and refer friends. But a flash crowd is notoriously fickle; the outcome won't be nearly as idyllic if the site crashes under its load. Many people won't bother to return if the site doesn't work the first time. Still, it is hard to justify paying tens of thousands of dollars for resources just in case the site experiences a sudden load spike. Flash crowds are both the garage innovator's bane and her goal.

    One way out of this conundrum has been enabled by contemporary utility computing.

    The article then proposed a number of steps the garage innovator can take, such as using storage delivery networks and implementing highly-scalable databases.

    0 讨论(0)
  • 2021-01-29 21:44

    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??
    0 讨论(0)
提交回复
热议问题