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.
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:
https://headshop-next.netlify.app/us/en/ssr/
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.
Any update on this? I’m running gatsby@4.11.2
with gatsby-plugin-netlify@4.2.0
and v3 of the Essential Gatsby plugin. I’ve got one page that uses getServerData
and I’ve stripped out all external API calls so that it just returns an empty object for props, and still I get very long response times and it often times out. When you mention “the Gatsby plugin for SSR”, do you mean Gatsby itself or gatsby-plugin-netlify
?
Hi @rossbrown,
I meant @netlify/plugin-gatsby
. It should be working fine at this point. Would you be able to share the site name?
I’ll follow up in a support request.
Hey there, @rossbrown
Just confirming-- will you be following up via email support, or here? I do not currently see other requests from you, and I want to make sure we are not missing anything.
Sorry for the confusion! I’ve contacted email support with some details around the issue. Basically just trying to figure out if it’s possible that one page render could take more than the 10 second timeout limit.
I’m using the latest Netlify plugins and version of Gatsby, but still seeing that the SSR response is very slow. Any updates or work arounds?
Did you read my previous message:
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.
In short, this has nothing to do with plugin versions.