5 ms·
what should a website do to not get hugged?
by extrememacaroni 3y ago
what should a website do to not get hugged?
- MobiusHorizons 3y agoBe less interesting? Seriously though, for static content like an article, caching and cdn’s can handle fairly large traffic.
- thephyber 3y agoHugged is an euphemism that describes when demand is higher than supply for server/bandwidth resources. Solution: increase supply and/or reduce demand. Reducing the dynamic content (reduce the number of HTTP requests and the time taken for the server to respond to each request) goes a long way, but CDNs are good for increasing supply if that is ultimately necessary.
- Kamq 3y agoWhile CDNs are useful, you really shouldn't need them to handle HN traffic. Someone posted what the otherside of a hug looks like[0], and it's somewhere around a unique visitor every 1-2 seconds, which really shouldn't be too much of a problem for... well anyone. The poster themselves got through it with a $7/month heroku server (albeit not without some manual intervention). And, y'know, if sometimes a hobby project gets taken down, that's fair. You could end up getting 100 requests in a single second on a server you strung together off blog posts as a learning exercise over a weekend. But any time any professional organization gets taken down by the amount of traffic HN generates, I'm always a little embarrassed for them. [0] https://herman.bearblog.dev/the-hacker-news-hug/ https://herman.bearblog.dev/the-hacker-news-hug/
- littlestymaar 3y agoYeah, at such a load, it's almost always something like too many DB connections/queries. If you somehow use one DB connection per query and make multiple queries for every user, no wonder your website struggles under even a tiny bit of load.
- Kamq 3y agoThe number of times I've been bitten by an orm and the n+1 problem... Which, I guess is fine for some internal thing that needs to handle 8 requests a day. I've kinda stopped using orms at this point. The sql is usually clearer than whatever dsl has been shoved into the orm. If you ever change databases, it requires slightly more work (assuming you haven't gone too crazy with db specific functionality), but burning a day or two to update the sql in your project is usually still quicker than orchestrating the migration.
- diego_sandoval 3y agoNot run off algae, for starters.
- littlestymaar 3y agoDo not query the database upon each and every request (and use a CDN for media assets, but it's secondary) and you'll basically never die from being hugged. Heck, a few month ago someone shared their website hosted on an old Android phone and it didn't have any issues handling the load from the HN crowd (which isn't really that big anyway).