C# Interview Question #120

How would you diagnose a slow C# or ASP.NET Core application?

Concurrency, Performance & Design Senior Advanced

Quick Interview Answer

Performance diagnosis should begin with measurement rather than random code changes.

Detailed Explanation

Performance diagnosis should begin with measurement rather than random code changes.

First identify whether the bottleneck is CPU, memory allocation, garbage collection, database access, external HTTP calls, file I/O, locking, thread-pool starvation, or network latency. Use structured logs, distributed tracing, application metrics, profilers, database execution plans, and benchmarking tools where appropriate.

For database-heavy applications, inspect generated SQL, indexes, N+1 queries, query projections, pagination, tracking behavior, and the amount of data transferred. For application code, inspect allocations, repeated enumeration, blocking calls, excessive serialization, lock contention, and unnecessary work.

In ASP.NET Core, async I/O should be used end-to-end where appropriate. Expensive stable data may benefit from caching. After making a change, measure again to verify that performance actually improved and that correctness was not affected.