
Ask HN: How are HN's comments rendered at scale (server-side)? - gigatexal
HN, as we all know, is a super popular website. I heard, randomly, that it&#x27;s hosted on rather low-end hardware but somehow it is capable of handling all the load we rabid HN checkers give it. So without something like disqus how are the comments powered?
======
nostrademons
Everything is served out of RAM and then when RAM fills up, the oldest threads
are written out as static files. (Note that when you visit a super-old thread
[1], there's no "reply" link and voting redirects you to a voteclosed page.)

Computers are stupidly fast at serving out of RAM - it's not unusual to be
able to serve 100K requests/ _sec_ if a request never needs to touch disk (see
eg. the JSON serialization test on the TechEmpower benchmarks, on physical
hardware [2] - top frameworks can get 500K request/sec on a hello-world
serialization task). They're also stupidly fast at serving static files
(which, if the server is implemented right, can be served straight out of the
filesystem cache in the kernel without any memory copies through user space).
100K requests/sec is a budget of 20,000 cycles/request, which is eminently
doable if most of the page contents is in RAM (or better yet, cache...on a
slow day, the entire front page of HN can fit in L3 cache).

The same approach has been used to good effect on other websites like Google,
Facebook, PlentyOfFish, Mailinator, etc. Eschew databases, serve out of RAM
(and now SSDs) entirely.

[1]
[https://news.ycombinator.com/item?id=8863](https://news.ycombinator.com/item?id=8863)

[2]
[https://www.techempower.com/benchmarks/#section=data-r14&hw=...](https://www.techempower.com/benchmarks/#section=data-r14&hw=ph&test=json)

~~~
gigatexal
Thank you so much for the info. Makes sense and helped to scratch the itch I
was having for a while now.

