title: High performance server side rendering with Node.js in Kubernetes
body: <p>We're currently in an evaluation phase for <strong>S</strong>erver <strong>S</strong>ide <strong>R</strong>endering with <a href="https://reactjs.org/" rel="nofollow noreferrer">React</a>.</p>
  <p>Our current rendering stack is based on the JVM and provides us a performance of <strong>~2k req/sec</strong> with a mean <strong>~150-200 ms/req</strong>. This is the performance we want to achieve at least with the new stack.</p>
  <p>We deployed prototypes (React + express.js &amp; and with next.js) with a reasonable amount of components (10k elements in DOM) in our Kubernetes cluster and measured their performance with <a href="https://github.com/mcollina/autocannon" rel="nofollow noreferrer">autocannon</a>.</p>
  <p>For simplicity, focus on the next.js prototype.</p>
  <p>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.</p>
  <p>While thinking about to protect the event loop of the service with libraries such <a href="https://github.com/davidmarkclements/overload-protection" rel="nofollow noreferrer">overload-protection</a> we asks ourselfs if this is really the way to go?</p>
  <p>For example, the <a href="https://nextjs.org/docs/api-reference/next.config.js/build-target" rel="nofollow noreferrer">documentation</a> of next.js says that 'serverless' is the recommended build target.</p>
  <p>What is your experience in rendering React components a high-performance way on the server side? Any advice on using the <code>serverless</code> build target? Or should we stick on next.js's default build target <code>server</code>? If so, what is a good strategy to handle a overloading event loop in the cluster? How to load balance that?</p>
  <p>We really appreciate if you can share your knowledge! Really! :)</p>
  <p>Cheers,
  Chris</p>