Minimal API is taking too long

Falanga, Rod, DOH 1,255 Reputation points
2026-02-23T21:15:26.89+00:00

We're getting close to the end of rewriting a legacy ASP.NET WebForms app using Blazor and Minimal APIs. Both are written using .NET 9. A coworker builds and puts both the Blazor app and Minimal API into their respective websites. According to him, it takes ~4 seconds for any minimal API endpoint to respond. I'll have to do some of my own testing, to verify that. Nevertheless, if this holds true, then we'll have some unhappy users.

So, what do you suggest we do to speed up the API's response time?

Developer technologies | ASP.NET Core | ASP.NET API

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

Answer accepted by question author
Paul Thomas 80 Reputation points
2026-10-08T13:05:00.3466667+00:00

Since you can't use Postman, here's a way to settle "is it the API, the network or the tool?" with numbers instead of guesses, using only what's already on a Windows machine.

1. Break one request into its parts with curl

curl.exe is built into Windows 10 and 11. In PowerShell, type curl.exe (plain curl is an alias for Invoke-WebRequest in Windows PowerShell 5.1):

curl.exe -s -o NUL -D - -w "dns=%{time_namelookup} connect=%{time_connect} tls=%{time_appconnect} firstbyte=%{time_starttransfer} total=%{time_total}`n" https://your-api-host/your-endpoint

Each value is the number of seconds since the request started:

Value What it covers If this is where the ~4 s appears
dns Looking up the host name Name resolution (DNS, proxy auto-config)
-------- -------- --------
dns Looking up the host name Name resolution (DNS, proxy auto-config)
connect TCP connection Network path, firewall or proxy
tls HTTPS handshake TLS or certificate checks
firstbyte Until the first byte of the response The server: your API code, or authentication before it
total Whole request

If the endpoints use Windows authentication, add --negotiate -u : so curl authenticates like a browser. That also shows whether the Kerberos/NTLM negotiation Bruce mentioned is adding the time.

Run it from the machine where the slowness happens: your PC for the Bruno comparison, and the Blazor server for calls the app itself makes.

2. Time the request inside the API

Add this as the first middleware in Program.cs. It returns the server's own processing time in a Server-Timing header:

using System.Diagnostics;

app.Use(async (context, next) =>
{
    var stopwatch = Stopwatch.StartNew();
    context.Response.OnStarting(() =>
    {
        context.Response.Headers["Server-Timing"] = $"app;dur={stopwatch.Elapsed.TotalMilliseconds:0}";
        return Task.CompletedTask;
    });
    await next(context);
});

The -D - in the curl command prints response headers, so you'll see a line like Server-Timing: app;dur=12 (milliseconds). Browser developer tools also show it in the Timing tab of a request.

Reading the results together

  • app;dur is small but firstbyte is about 4 s: the time is spent before your code runs (authentication, IIS, a proxy or the network). The API logic isn't the problem.

app;dur is about 4 s: the time is in your endpoint code or its dependencies, such as a database call. Time those next.

curl is fast from your machine but Bruno is slow: it's the tool or its proxy settings, which matches what you saw with Postman off-site.

I tested this with a .NET 9 minimal API: an endpoint that waits 1.5 s showed Server-Timing: app;dur=1503 and firstbyte=1.50, with DNS and connect near zero, while a trivial endpoint showed app;dur=0.

Was this answer helpful?

1 person found this answer helpful.

3 additional answers

Sort by: Newest
  1. Bruce (SqlWork.com) 85,536 Reputation points
    2026-03-01T19:45:47.5633333+00:00

    If they all have. 4 second overhead, it must likely you webapi is timing out connecting to the Kerberos server. And falling back to windows Ntlm. Have your network people do a trace.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments
  2. Jack Dang (WICLOUD CORPORATION) 18,975 Reputation points Microsoft External Staff Moderator
    2026-02-24T04:26:03.15+00:00

    Hi @Falanga, Rod, DOH ,

    Thanks for reaching out.

    A few things you can try to speed it up:

    • Warm up the API: Keep the app loaded in memory so it doesn’t have to “wake up” every time. That first request can feel slow if the app hasn’t been used in a while.
    • Optimize per-request work: If your API opens database connections, loads big files, or does heavy calculations on every call, try to reduce that. Do the heavy lifting once if you can, then reuse it.
    • Check the hosting environment: Make sure the server has enough resources, and the app is set up for responsiveness. Even tiny misconfigurations can add a second or two.
    • Measure where the slowdown really is: Sometimes the API itself is fast, but a database call or file operation is the culprit. Logging and performance tools can help pinpoint it.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    Was this answer helpful?

  3. AI answer

    2026-02-23T21:15:35.8466667+00:00

    To improve the response time of your Minimal API endpoints, consider the following strategies:

    1. Optimize Code: Review the implementation of your API endpoints to ensure they are efficient. Look for any unnecessary computations or blocking calls that could be slowing down the response time.
    2. Asynchronous Programming: Utilize asynchronous programming patterns to avoid blocking threads while waiting for I/O operations, such as database calls or external API requests. This can significantly improve performance under load.
    3. Caching: Implement caching strategies for frequently accessed data. This can reduce the need to recompute or fetch data from a database for every request, thus speeding up response times.
    4. Load Testing: Use tools like Bombardier to simulate load and identify bottlenecks in your API. This will help you understand how your API performs under stress and where optimizations are needed.
    5. ThreadPool Management: Ensure that your application is not experiencing ThreadPool starvation, which can lead to slow performance. Monitor the ThreadPool usage and adjust your application’s threading model if necessary.
    6. Profiling and Diagnostics: Use profiling tools to analyze the performance of your API. This can help identify slow parts of your code and provide insights into where optimizations can be made.
    7. Minimal APIs Benefits: Remember that Minimal APIs are designed for better performance with reduced overhead compared to traditional controller-based APIs. Ensure you are leveraging their advantages effectively.

    By implementing these strategies, you should be able to reduce the response time of your Minimal API endpoints and enhance the overall user experience.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?