High performance server side rendering with Node.js in Kubernetes

Viewed 923

We're currently in an evaluation phase for Server Side Rendering with React.

Our current rendering stack is based on the JVM and provides us a performance of ~2k req/sec with a mean ~150-200 ms/req. This is the performance we want to achieve at least with the new stack.

We deployed prototypes (React + express.js & and with next.js) with a reasonable amount of components (10k elements in DOM) in our Kubernetes cluster and measured their performance with autocannon.

For simplicity, focus on the next.js prototype.

While our first tests with one concurrent user were quite good, we saw dramatically drops in response times when increasing the concurrency level. With our knowledge on how Node.js works (single-threaded event-loop) we assume this is because of a lagging event loop.

While thinking about to protect the event loop of the service with libraries such overload-protection we asks ourselfs if this is really the way to go?

For example, the documentation of next.js says that 'serverless' is the recommended build target.

What is your experience in rendering React components a high-performance way on the server side? Any advice on using the serverless build target? Or should we stick on next.js's default build target server? If so, what is a good strategy to handle a overloading event loop in the cluster? How to load balance that?

We really appreciate if you can share your knowledge! Really! :)

Cheers, Chris

0 Answers
Related