*"How I Fixed a 300ms API Latency Spike—Without Touching the Database"*
DEV Community
*"How I Fixed a 300ms API Latency Spike—Without Touching the Database"*
A seemingly minor change in a .NET 8 API (adding a new validation rule) caused a sudden 300ms latency spike under load—despite no database queries or external calls being affected. The culprit? A hidden `IAsyncEnumerable` leak in a middleware pipeline, combined with `CancellationToken` misuse in a background task. Here’s how I diagnosed it with `dotnet-trace`, fixed the leak, and restored sub-100ms response times—without rewriting the business logic or scaling the database.
0 comments
No comments yet.