2 ms·
The big idea is to write the comments as static HTML, only when comments change, instead of doing a database query to display them every time. This prevents the
by userbinator 4y ago
The big idea is to write the comments as static HTML, only when comments change, instead of doing a database query to display them every time. This prevents the “hug of death” if you get a burst of traffic.
I believe this was the technique used (and still being used?) by 2chan, the ancestor of the infamous 4chan. It didn't even need a database, as it was entirely file-based and simply appended each post to the appropriate file. Visitors were served static HTML with no JS required.
- masklinn 4y agoYep, I'm surprised the OP doesn't use such a scheme, possibly with something SSE-ish so you don't mix the content and comments on-disk but they're both retrieved as a single request. This way all you need is a POST endpoint (which might just be a cgi script) to receive the comment and update the comment file. Gets more complicated if you support threaded comments or pagination, but for a linear comment system it should be more than enough.
- russelg 4y agoThe main 4chan open source clone project (tinyboard -> vichan -> infinitychan) works this way.