airbnb / hypernova

A service for server-side rendering your JavaScript views
MIT License
5.82k stars 212 forks source link

Render using multiple threads #27

Closed thedrow closed 8 years ago

thedrow commented 8 years ago

Rendering is a CPU bound task which might be problematic for Node js during spikes. We could use something like https://github.com/xk/node-threads-a-gogo to create a thread pool of workers that render React components to HTML and use the event loop just for I/O.

ljharb commented 8 years ago

The solution in node to handle CPU-bound tasks is to scale using separate processes - not threads, which is how hypernova is designed to be used.

goatslacker commented 8 years ago

We are already using Node.js' cluster module here to achieve the same goal.

I think that Hypernova isn't opinionated on your clustering architecture so you're free to skip out on using cluster and instead implement something that uses threads-a-gogo.

Thanks for sharing though :) It looks like you can probably use threads and skip out on using cluster AND vms since it seems like the code is also sandboxed. I'm not sure what the performance implications would be of using this sort of thing (is this faster than VMs or not?) but it looks interesting.