𝗧𝗵𝗶𝘀 𝗮𝘀𝘆𝗻𝗰 𝗰𝗼𝗱𝗲 𝗶𝘀 𝗰𝗼𝘀𝘁𝗶𝗻𝗴 𝘆𝗼𝘂 𝘁𝗵𝗼𝘂𝘀𝗮𝗻𝗱𝘀 Async/await has been in .NET for over a decade, yet production systems still suffer from the same three mistakes that destroy performance and inflate cloud costs. These patterns appear innocent. Code reviews approve them. They pass all tests. But under load, they become system killers. The symptoms are always the same: → Thread pool starvation with low CPU usage → Random deadlocks in production → Response times growing exponentially with load → Cloud costs mysteriously tripling The most dangerous part? Standard monitoring often shows the system as "healthy" with 20% CPU usage. The problem isn't CPU - it's thread exhaustion. Each blocking call consumes a thread. With default thread pool settings, just 100 concurrent requests can bring an API to its knees. Async void swallows exceptions, causing silent failures that only surface during peak traffic. Unnecessary Task.Run calls double thread usage for zero benefit. These aren't edge cases. They're in most codebases right now, waiting for the next traffic spike. 𝗧𝗼𝗺𝗼𝗿𝗿𝗼𝘄: The fixes that enable 100x throughput improvements with the same infrastructure. 𝗛𝗮𝘃𝗲 𝘆𝗼𝘂 𝘀𝗲𝗲𝗻 𝘁𝗵𝗲𝘀𝗲 𝗽𝗮𝘁𝘁𝗲𝗿𝗻𝘀 𝗶𝗻 𝘆𝗼𝘂𝗿 𝗰𝗼𝗱𝗲𝗯𝗮𝘀𝗲? Did you noticed potential issue in mistake 2? #AsyncAwait #Dotnet #CSharp #PerformanceOptimization #SoftwareEngineering
Evil in async code: - async voide - using .Result or GetAwaiter().GetResult() - mixing Thred.Sleep with async code - not using CancellationToken
async looks simple but the traps are everywhere., Dawid Pereira In mistake #2 (async void), isn’t the bigger issue that exceptions get swallowed, making debugging almost impossible?
Who calls Result or GetAwaiter() ? Not many people i have seen
Yes! Mistake 2 is likely using async void, which swallows exceptions and makes failures silent. This can cause deadlocks and unpredictable behavior under load.
Nice tip. Properly scheduling I/O-bound tasks lets your thread pool grow only when needed, keeping your app snappy under heavy load without extra costs
This hits hard async/await isn't just about syntax; misuse silently cripples performance and budgets. Thread exhaustion hides in plain sight while your system "looks healthy." Time to audit that async code.
Well put—these patterns often sneak past reviews and testing but show their real cost under load. Faced them myself, and debugging isn’t straightforward. Would be interesting to see your implementation of the fixes. Dawid Pereira
For the 2nd, there is no way of waiting for an async void method to complete.
Problem-Solving Engineer | .NET Craftsman | Rust Explorer | DDD & System Design Expert | Technical Speaker & Mentor
2moAs promised here you can find my solution to those issues :) https://www.linkedin.com/posts/pereiradawid_asyncawait-dotnet-csharp-activity-7368893013982351360-eTka?utm_source=share&utm_medium=member_desktop&rcm=ACoAABXvG2sBlfeLjz--NekL5bP_j5EUBOA62ak