8

We have an App Service Plan (P2v2: 1) that has 6 .Net Core Web API's & 2 Web Jobs deployed.

Of late, 1 of the Web API periodically starts emitting (502) Bad Gateway error. The error seems to resolve on it's own or we need to restart the App Service.

The Avg CPU % we saw was 42.x % and Avg Memory % was around 32.x %

This is really driving us nuts because we don't see any Application errors.

We are badly in need of hints to resolve this issue because this is running in Production.

Dan Lee BTS
  • 81
  • 1
  • 1
  • 2

1 Answers1

4

502 errors can be multiple things.

  • there's a chance you're exceeding the maximum tcp connections for the plan (standard s3 while has an older hardware it contains the double of p2v2)

  • it can be timeout in your app too.

  • also check if you're using HttpClientFactory rather than HttpClient as it will reuse connections from the pool

The maximum IP connections are per instance and depend on the instance size: 1,920 per B1/S1/P1V2 instance, 3,968 per B2/S2/P2V2 instance, 8,064 per B3/S3/P3V2 instance.

https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/azure-subscription-service-limits#app-service-limits

The best thing you can do is inspect the diagnose and solve issue and select 500x error and analyze the report.

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90
  • Thanks Noah Stahl and Thiago Custodio. We will pursue both the approaches considering our dire situation. The insight really helps! – Dan Lee BTS Jul 21 '20 at 15:01
  • We see the following in Diagnose & solve problems section: AspNetCoreModule 502.5 10 ASP.NET Core Process Startup Error. This error is returned when ASP.NET Core Module attempts to start the .Net core process but the process fails to start. This can happen if the app is taking more time to start than configured in the startupTimeLimit in the web.config or there is an unhandled exception happening in the app code or .net core runtime. Not sure why this comes intermittently because after some time the issues resolves on its own or after IIS reset. – Dan Lee BTS Jul 21 '20 at 15:39