Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

Next.JS Static Web App Backend is sometimes incredibly slow #1485

Open BenjaminIrwin opened 3 weeks ago

BenjaminIrwin commented 3 weeks ago

I'm using Enterprise Edge Mode and our (Next.JS 12) backend is still extremely slow. I'm facing latency of up to 15s for straightforward GET request that takes <400ms locally. I'm seeing similar latency (intermittently) across the board, making our app virtually unusable.

Feels like we've exhausted every option in terms of optimisations and are having to consider moving away from Azure/SWA.

ChristianAyala commented 3 weeks ago

I'm experiencing the same thing. There are two fundamentally "broken" things with SWA now, if you're using NextJS hybrid apps (pages router in my case, but I suspect app router would be similar):

  1. The build pipelines time out all the time, and you have to trigger a rebuild a few times to get it to finish a deployment. #1471 , #1404 , #1488 , #1440 all show people having the same issue, where after 10 minutes of waiting the deployment fails. After a couple retries, it ends up working, meaning this isn't a code issue.
  2. We've setup availability alerts through Application Insights, polling a health route every 2-3 minutes. I get availability alerts on an almost nightly basis with the app never resolving any page loads / API calls. The solution ends up being a re-deploy and the app becomes responsive again.

Like @BenjaminIrwin said, we're going to start looking into Web Apps rather than Static Web Apps, or some Container Service solution, which a few other threads have mentioned as alternatives. SWA + NextJS is just too unstable. Should something go wrong and a hotfix is needed, I have no confidence that I can deploy a fix on the first try. That, coupled with the fact that there is no way to get insight into the backend Functions themselves (since they're managed functions), means we're left in the dark as to why it isn't responding.

In theory this service would be incredibly useful, but in practice it's too unreliable to recommend on a production application.

grajdeanserghei commented 3 weeks ago

We have the same issues as described by @BenjaminIrwin and @ChristianAyala — poor performance and deployment timeouts. Started to look into alternative hosting solutions.

mvenaas commented 3 weeks ago

We are experiencing the same issue. We are transitioning from a fully static build to a hybrid one and initially considered Azure Static Web Apps with Next.js hybrid rendering as a solution. However, this approach has proven to be impractical for both development and production environments. We are now exploring alternative solutions.

joeklin commented 2 weeks ago

Same here but it goes from incredibly slow to a 500 server error and just presents the message "Backend server error" We are using the managed instance of the function app.

ChristianAyala commented 2 weeks ago

Now getting "Backend call failure" yet again. See App Insights graph below. Periods of traffic (mostly health check route calls), and periods where the app is completely non-responsive. @thomasgauvin this is a similar series of issues we ran into with #1417, where deployments were failing but now the app is just... down.

image
ChristianAyala commented 2 weeks ago

New error, see below. The link takes me to the following URL: https://staticwebapps-4d4f67ef-9b0f-4748-92f9-bef6b089bdb0.scm.azurewebsites.net/detectors, which seems to be an internal-to-Microsoft site and not one that I have access to.

image image
alasdairmackenzie commented 2 weeks ago

I've also experienced it being incredibly slow with the message "Backend server error" occasionally like @joeklin. The deployments also timeout like described above. My guess is that these are all related to the functions being unavailable.

haider-evident commented 2 weeks ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues:

Screenshot 2024-06-13 at 19 04 12

Also getting this intermittent issue on the front-end:

Screenshot 2024-06-13 at 14 51 14

We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

t-NuoWenLei commented 1 week ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues: Screenshot 2024-06-13 at 19 04 12

Also getting this intermittent issue on the front-end: Screenshot 2024-06-13 at 14 51 14

We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

I had the same issue but it seems like this example and this section of the tutorial helped me at least get past this error.

haider-evident commented 1 week ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues: Screenshot 2024-06-13 at 19 04 12 Also getting this intermittent issue on the front-end: Screenshot 2024-06-13 at 14 51 14 We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

I had the same issue but it seems like this example and this section of the tutorial helped me at least get past this error.

Hi there, thank you for this. Would the standalone feature still keep the App as a hybrid app? For context, I am using Next.js draftMode feature for allowing draft content previews so I would need the app to still behave in a hybrid manner.

haider-evident commented 1 week ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues: Screenshot 2024-06-13 at 19 04 12 Also getting this intermittent issue on the front-end: Screenshot 2024-06-13 at 14 51 14 We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

I had the same issue but it seems like this example and this section of the tutorial helped me at least get past this error.

Hi there, thank you for this. Would the standalone feature still keep the App as a hybrid app? For context, I am using Next.js draftMode feature for allowing draft content previews so I would need the app to still behave in a hybrid manner.

Looking at this article: https://focusreactive.com/standalone-next-js-when-serverless-is-not-an-option/#:~:text=%E2%9C%85-,Draft%20mode,%E2%9D%8C,-RSC, it appears enabling standalone may mean "Draft mode" may not work for hosting providers other than Vercel.

t-NuoWenLei commented 1 week ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues: Screenshot 2024-06-13 at 19 04 12 Also getting this intermittent issue on the front-end: Screenshot 2024-06-13 at 14 51 14 We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

I had the same issue but it seems like this example and this section of the tutorial helped me at least get past this error.

Hi there, thank you for this. Would the standalone feature still keep the App as a hybrid app? For context, I am using Next.js draftMode feature for allowing draft content previews so I would need the app to still behave in a hybrid manner.

Looking at this article: https://focusreactive.com/standalone-next-js-when-serverless-is-not-an-option/#:~:text=%E2%9C%85-,Draft%20mode,%E2%9D%8C,-RSC, it appears enabling standalone may mean "Draft mode" may not work for hosting providers other than Vercel.

I see, sorry I do not know too much about Next.js Draft Mode.

haider-evident commented 1 week ago

We are trying to deploy Next.js Hybrid app and getting intermittent failed pipeline deployments due to timeout issues: Screenshot 2024-06-13 at 19 04 12 Also getting this intermittent issue on the front-end: Screenshot 2024-06-13 at 14 51 14 We may have to go for an alternative like Vercel or Netlify. Pretty annoying, If Azure SWA isn't ready to support Hybrid Next.js apps, they should make it clear that its currently experimental as the term "Preview" in their docs is rather vague.

I had the same issue but it seems like this example and this section of the tutorial helped me at least get past this error.

Hi there, thank you for this. Would the standalone feature still keep the App as a hybrid app? For context, I am using Next.js draftMode feature for allowing draft content previews so I would need the app to still behave in a hybrid manner.

Looking at this article: https://focusreactive.com/standalone-next-js-when-serverless-is-not-an-option/#:~:text=%E2%9C%85-,Draft%20mode,%E2%9D%8C,-RSC, it appears enabling standalone may mean "Draft mode" may not work for hosting providers other than Vercel.

I see, sorry I do not know too much about Next.js Draft Mode.

No problem, thank you for your help anyway :)

haider-evident commented 3 days ago

Took me 2 minutes to set-up repository in Vercel and 1 minute 27 seconds to build and deploy the site. Wow. These old dogs like Azure are going to end-up in history books.