question

ArildBjerkenes-8807 avatar image
0 Votes"
ArildBjerkenes-8807 asked ajkuma-MSFT answered

Azure App Service - prevent timeout after 230s

We have migrated a .net web-application to Azure App Service. Some requests may take longer than 230 seconds, and result in timeout. Is there any way to prevent this? We have tried to add <httpProtocol allowKeepAlive="true"> in the web-config, but with no luck. We know that we should reimplement the solution to avoid long running request, but this will take some time.

We have Azure Front door in front of the app-service.

azure-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlanKinane avatar image
1 Vote"
AlanKinane answered

I'm not sure that this can be extended. There is a 4 minute limit on the Azure Load Balancer.

There's a recommendation here to use WebJobs instead.

https://docs.microsoft.com/en-us/troubleshoot/azure/general/web-apps-performance-faqs#why-does-my-request-time-out-after-230-seconds

196193-image.png



Another thread on this here:
https://techcommunity.microsoft.com/t5/apps-on-azure/app-service-timeout-in-230-sec/m-p/1526934


image.png (35.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ajkuma-MSFT avatar image
1 Vote"
ajkuma-MSFT answered

@ArildBjerkenes-8807, Just following-up, as Alan mentioned, the timeout is not configurable, and cannot be changed.


Just to highlight more on this, the 4-minute idle timeout on the TCP level and this is implemented on the Azure hardware load balancer. This timeout is not configurable, and this cannot be changed.
Note that the idle timeout is at the TCP level which means that if the connection is idle only and no data transfer happening, then this timeout is hit.

--Timeout will hit if the web application got the request and kept processing the request for > 4minutes without sending any data back.
Ideally, in a web application, it is not good to keep the underlying HTTP request open and 4 minutes is a decent amount of time.

A few things to try based on your requirement:

--If you have a requirement about background processing within your web application, then as Alan mentioned – the recommended solution is to use Azure WebJobs/or Azure Function App.
--For longer processing times, consider using the Durable Functions async pattern or defer the actual work and return an immediate response.

--I understand you have mentioned about KeepAlive implementation already-
--You could keep the connection active for a longer period is to use TCP Keep-alive. Packets are sent when no activity is detected on the connection. By keeping on-going network activity, the idle timeout value is never hit, and the connection is maintained for a long period. Try something like this:

• First request starts the script and returns an http 202
• Subsequent requests from client check the work, and eventually return 200 when it's done.


Checkout these reference discussion threads. Once again I understand you have looked into approachs for reimplementing the solution to tackle timeout. Kindly checkout the above and let us know if you have any further questions.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.