MVP Server Side Rendering
Experiments for server-side rendering. Namely, the current implementation uses node's worker threads module.
Worker threads are using v8 isolates under the hood, node spawns each worker in different OS threads. This is shared-nothing architecture, and communication
is handled via message passing (postMessage()
).
Using different worker threads is particullary useful in SSR, where the work is CPU-bound. One can spawn 1 worke per CPU and scale the load to all cores.
There is some message passing and copying large string/buffers around with this
setup, we'd have to see the perf impact in practice.
Getting Started
$ nodejs ./ssr-server.mjs
$ curl http://localhost:3030
<div data-hypernova-key="SSRTest" data-hypernova-id="5bdca17e-ecb1-4f2a-afef-af298ac7dc0d"><div data-reactroot=""><p>React-rendered</p></div></div>
<script type="application/json" data-hypernova-key="SSRTest" data-hypernova-id="5bdca17e-ecb1-4f2a-afef-af298ac7dc0d"><!--e30=--></script>