简体   繁体   English

Azure Web App 和 React SSR:初始加载时加载时间极慢

[英]Azure Web App and React SSR: Extremely slow loading times on initial load

I'm really intrigued by this, I've set up a Node 12 Azure Web App, with server-side rendering in React.我对此很感兴趣,我设置了一个 Node 12 Azure Web 应用程序,在 React 中进行服务器端渲染。

However, I fail to understand why the initial response time is slow (more than 3 minutes), but after this, the response time falls to about 1/2 seconds.但是,我无法理解为什么初始响应时间很慢(超过 3 分钟),但是在此之后,响应时间下降到大约 1/2 秒。

Why is the initial response so slow?为什么初始响应这么慢? I'm new to Azure and SSR web applications, but is the node server just shutting off from inactivity, and starting up the build again every few minutes?我是 Azure 和 SSR web 应用程序的新手,但是节点服务器是否只是从不活动状态关闭,每隔几分钟再次启动构建?

Are there any ways to fix this, apart from scaling the web app up?除了放大 web 应用程序之外,还有什么方法可以解决这个问题吗?

Here's the graph on the response time:这是响应时间的图表: 在此处输入图像描述

The common cause for long application start times is a high number of files in the node_modules.应用程序启动时间长的常见原因是 node_modules 中有大量文件。 The application tries to load most of these files when starting.应用程序会在启动时尝试加载其中的大部分文件。 By default, on App Service all the files are stored on the.network share (so loading many files can take time).默认情况下,在 App Service 上,所有文件都存储在 .network 共享上(因此加载许多文件可能需要时间)。

1.If you haven't done this already, you may try to lazy load your node_modules and not load all of the modules at application start. 1.如果您还没有这样做,您可以尝试延迟加载您的node_modules而不是在应用程序启动时加载所有模块。 To Lazy load modules, the call to require('module') should be made when you actually need the module within the function before the first execution of module code.要延迟加载模块,应在首次执行模块代码之前在 function 内实际需要模块时调用 require('module') 。 See, if this makes any difference.看,这是否有任何区别。

  1. Kindly check if Always On -Settings/feature is enabled and if it loads as expected.请检查Always On - 设置/功能是否已启用以及是否按预期加载。

  2. If feasible, enable Local cache (firstly test, and then leverage if required)如果可行,启用本地缓存(首先测试,然后在需要时利用)

Local cache -copies the content from the.network share to the local disk on the VM.本地缓存 - 将内容从 .network 共享复制到 VM 上的本地磁盘。 Since the files are local, the load time of node_modules is much faster.由于文件是本地的,因此node_modules的加载时间要快得多。

Note: Local cache is not supported in function apps or containerized App Service apps, such as in Windows Containers or in App Service on Linux.注意:function 应用或容器化应用服务应用不支持本地缓存,例如 Windows 容器或 Linux 上的应用服务。

  1. You may leverage, App Service diagnostic to fetch more details on the issue.您可以利用应用服务诊断来获取有关该问题的更多详细信息。 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular Azure应用服务SSR配置 - Angular SSR configuration on Azure app service 在 Azure 中部署 Django 和 React 应用程序加载失败 - Deploying Django & React app in Azure failing to load AWS Application Load Balancing:看到极长的初始连接时间 - AWS Application Load Balancing: Seeing extremely long initial connection time Azure Static Web App - Function App API - 如何加载 IOptions? - Azure Static Web App - Function App API - How to load IOptions? 部署在 azure web 应用程序上时找不到 React 应用程序上的字体 - Font on React app not found when deployed on azure web app .NET 5 在 Azure 中托管的服务有时非常慢 - .NET 5 Service hosted in Azure very slow at times 将 .NET 核心控制台应用程序部署到 Azure 后加载我的 web 应用程序时出错 - Error loading my web app after deploying .NET Core console app to Azure Firebase 存储极慢获取 - Firebase storage extremely slow fetching 从 Azure 文件共享加载内容到 Azure Static Web App,管理用户访问权限 - Loading content onto Azure Static Web App from Azure File Share, managing user access permissions 如何在 nodejs linux 上启用 gzip 压缩 react Azure Web App with nginx - How do I enable gzip compression on a nodejs linux react Azure Web App with nginx
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM