Support Forums

Bad performance with new Gatsby 4 SSR pages

Hello, we are trying to implement the new Gatsby 4 server side rendering feature on our website. You can see the news about this feature on Netlify here: Run Gatsby 4 with DSG and SSR on Netlify today | Netlify.

So we did everything right, installed the latest beta of @netlify/plugin-gatsby & gatsby-plugin-netlify.

The problem is that it takes over 1 and even 2 seconds just to receive the html response from Netlify.

We dont even fetch anything inside the getServerData page function. No complex computation is being done.

We cannot afford to have >2 seconds html response time on our website.

The Netlify servers also randomly respond with a timeout error: (Trying refresh multiple times to reproduce)

{"errorMessage":"2021-11-17T21:12:29.785Z 9272f675-178c-4dda-b62c-e4bbecf9839e Task timed out after 10.01 seconds"}

Are we doing something wrong? Or is it normal that the Netlify server take so much time to build the page and respond to the requests?

Here is the test page:

export async function getServerData(context) {
  return {
    props: {
      isAuthenticated: !!context.headers["Authorization"]

Thank you

Hi @laurentlaporte,

SSR pages are served by Functions and Function servers are not globally distributed. By default they are only executed in US. So, the further you’re from there, the longer the transfer takes.

We can change the location to Europe or Asia for pro and above accounts, but that would make it slower for users in other regions.

Also, on a related note, the Gatsby plugin for SSR is not perfectly optimised which is another cause of this problem. Once the plugin is production-ready it will probably improve performance.