airbnb / hypernova

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

Memory leaks in the use of SSR #131

Open mvcruzata opened 6 years ago

mvcruzata commented 6 years ago

Hi, we have a system in which we set up our websites using SSR, with a flow over 2000 rpm in production environment. Actually, we are facing memory leaks issues by rendering react component throught SSR. We are looking for alternatives for handling SSR efficiently by avoiding possible memory leaks generated by the react compoenents to render. We are evaluating the use of hypernova as framework for SSR. Have you face similar memory leaks issues before? Does Hypernova have mechanism to avoid those memory leaks? Thank you so much for your support.

goatslacker commented 6 years ago

There is no silver bullet when dealing with memory leaks. You can use createVM to sandbox your code and guard against possible leaks but you'll be trading off performance since creating a VM has some considerable overhead.

You can create a VM on each request which is the safest and most expensive approach or you can create a VM on startup and re-use for subsequent requests which saves on some of the overhead at the cost of possibly leaking memory overtime on that VM.

My advice is to set up some memory watching tools on your node servers to find the source of the memory leaks and remove them.