Member-only story
REST API Best Practices — Decouple Long-running Tasks from HTTP Request Processing
Part 1 : Discuss how to design and complete long-running tasks outside of HTTP requests in RESP API, as recommended by Microsoft on ASP.NET Core Performance Best Practices.
Background
Most applications have some tasks that take longer than normal to complete. These tasks can be to generate a complex ad-hoc report for downloading, to trigger and wait for a CPU-intense computation, or to perform a series of small tasks that add up the whole processing time. Although there is no absolute definition on the processing time for a normal HTTP request, the expectation of modern applications is just high from the end users. While the default ASP.NET Core HTTP timeout is 100 seconds, it’s not something we want to rely on. Anything that takes more than a few seconds seem to be too long for a regular user, me included.
Microsoft documentation has a great article covering ASP.NET Core Performance Best Practices, and one specific subject is on Complete long-running Tasks outside of HTTP requests. Here is a link if you’d like to read the full article. In a nutshell, the recommendation is “Do not wait for long-running tasks to complete as part of…

