Hi Everyone ( @04821556 , @julian ,@Remy Villain ,@Alvin Ho & others who are facing similar issue),
I have debugged the reported issue with Universal Angular Web App with SSR & making HTTP Requests where you have reported random slowness & after thorough testing, we have identified that the issue is only happening when using Codeless integration of Application insights.
The reason for same is that for Nodejs SDK for Application Insights (when using SSR in Angular, it is used by default), the value of maxBatchIntervalMs is specified as 15000ms (15 seconds) by default, if no other value is specified as shown below:
maxBatchIntervalMs: The maximum amount of time to wait to for a payload to reach maxBatchSize (Default 15000 ms or 15 seconds).
Please refer to following link for more information:
Monitor Node.js services with Azure Application Insights - Azure Monitor | Microsoft Learn
So,unless the payload size reaches maxBatchSize the http requests are blocked to be sent to telemetry end point (Azure). This causes intermittent delays.
Resolution:
The issue is resolved after specifying a custom value for maxBatchIntervalMs (example 100 ms) as shown in the code sample below:
https://github.com/shuanand/angularuniversalSSRApplicationInsight/blob/main/server.ts
To configure the same, firstly disable the Application Insights from the Azure portal of the Webapp after copying Instrumentation key from the App Insights Dashboard by clicking on Overview blade as shown below:
You can then update the instrumentation key for your application in server.ts file as shown below:
appInsights.setup("PLEASE_ENTER_YOUR_APPLICATION_INSIGHTS_INSTRUMENTATION_KEY_HERE")
Once, it’s done, there is no random delay even after using the Application Insights as shown below and all the metrics are available in Application Insights Dashboard:
Angular universal App using SSR & Http Requests on Linux App Service:
angularssrdemo.azurewebsites.net
The code is working on Windows & Container App Service too after making the mentioned changes.
Thanks to @julian for sharing the sample code to quick do a repro for the issue.
Please comment, if you are still facing the issue with sample code and I will check the same.