How can I detect and survive being “Slashdotted”?

前端 未结 24 1832
半阙折子戏
半阙折子戏 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: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.

提交回复
热议问题