Ask HN: How do you prepare a site to handle being on HN's frontpage?
I'm wondering if anyone can point myself and others to a list of best practices to prevent such a thing from happening.
I'm wondering if anyone can point myself and others to a list of best practices to prevent such a thing from happening.
They're trivial to set up and they'll stand up to just about any amount of web traffic, even on a tiny VPS.
Look into a static site generator like Jekyll[1] or Pelican[2] to get started.
[1]: http://jekyllrb.com/
Some obvious remedies:
1. Don't post anything interesting to HN.
2. Buy a service that can handle ten times a normal access load, and arrange for incremental capacity increases as the need arises.
I've been in the position of having my server overwhelmed on a number of occasions because of "successful" posts to various social media, and it turned out that no reasonable advance precautions would have made much difference. It's a matter of minimizing the server downtime, not of eliminating it entirely.
From that monitor the requests to see what's taking up most of the time (NewRelic is one tool that can help with that, or just analyzing your log files ia fine too). For me, I've noticed caching database queries or just caching entire pages helps the most.
Then rerun the ab tool to see how much you've improved. Repeat as necessary.
https://wordpress.org/plugins/wp-super-cache/
Basic mod_rewrite caching will stand up to HN; for Reddit, you'll need to go to direct-access caching. Source: accidentally writing something popular a couple of times.
Loadtesting helps to determinate this features is and how your site will react under load.
Caching is probably the first step if you're not already doing that.