A hands-on ASP.NET Core lab for practicing production diagnostics with realistic failure modes.
This repository is intentionally small and focused. It is not a production template, architecture reference, or framework showcase. The goal is to make common production problems easy to trigger, observe, explain, and fix.
This lab demonstrates practical .NET and ASP.NET Core diagnostics scenarios across reliability, performance, memory, data access, observability, and deployment behavior.
You will work with examples of:
- inefficient data access that materializes too much data or performs too many database round-trips
- missing cancellation, missing timeouts, and repeated dependency failures
- blocking request execution and ThreadPool pressure
- weak logging context and missing health probes
- unsafe side effects, such as logging or audit failures breaking business operations
- request and response buffering that creates memory pressure
- socket exhaustion caused by poor HTTP client lifetime management
- Large Object Heap pressure and fragmentation
- Native AOT serialization failures caused by reflection-based JSON metadata
Each scenario has two paths:
- Problem — demonstrates the anti-pattern or failure mode.
- Mitigation — demonstrates the safer implementation or operationally better behavior.
.
├── docs/
│ ├── 01-excessive-data-materialization.md
│ ├── ...
│ ├── 19-repeated-dependency-failures.md
│ └── tools/README.md
├── src/
│ └── DiagnosticsLab.Api/
├── tests/
│ └── DiagnosticsLab.Tests/
└── README.md
The exact project names may evolve, but the intent stays the same: one API project hosts the scenarios, and the test project validates endpoint behavior.
Restore dependencies:
dotnet restoreRun the API:
dotnet run --project src/DiagnosticsLab.ApiRun tests:
dotnet testThe API uses SQLite and creates local seed data automatically.
- Open one scenario document from the list below.
- Run the problem endpoint and observe the behavior.
- Run the mitigation endpoint and compare the result.
- Use logs, response payloads, tests, or diagnostic tools to confirm the difference.
- Read the source file linked from the scenario document to see the implementation.
Most scenarios can be understood from endpoint behavior and logs. Some scenarios become clearer under repeated requests or load.
For optional diagnostic tooling, see docs/tools/README.md.
- Scenario 02: Missing Cancellation Propagation
- Scenario 06: Blocking Request Thread
- Scenario 15: ThreadPool Starvation
- Scenario 03: Missing Log Context
- Scenario 10: Missing Health Probes
- Scenario 12: Logging and Audit Failure Propagation
- Scenario 04: Missing Dependency Timeouts
- Scenario 07: Unbounded Retries
- Scenario 14: Socket Exhaustion
- Scenario 17: Cache Stampede
- Scenario 19: Repeated Dependency Failures
- Scenario 08: Large Response Buffering
- Scenario 13: Request Body Memory Pressure
- Scenario 16: LOH Fragmentation
- Scenario 09: Invalid Configuration
- Scenario 11: Silent Startup Failure
- Scenario 18: Native AOT Serialization Failure
External tools are optional. Use them when you want to observe runtime behavior under load or inspect a process more deeply.
The tools guide covers:
dotnet-countersdotnet-tracedotnet-dumpdotnet-gcdumpdotnet-stackwrkbombardiernetstatss
See docs/tools/README.md for installation and minimal commands.
Run all tests:
dotnet testThe tests include:
- smoke checks
- scenario behavior checks
- startup validation checks
- endpoint response checks
Use tests as a safety net when renaming routes, changing scenario behavior, or consolidating documentation.
Scenario names are problem-first. The title should describe the failure mode, not the mitigation.
Good examples:
- Missing Dependency Timeouts
- Socket Exhaustion
- Cache Stampede
- Repeated Dependency Failures
Each scenario document should include:
- goal
- why the problem matters
- problem endpoint behavior
- mitigation endpoint behavior
- how to try it
- what to observe
- source files
- related scenarios
- external references where useful
The examples are intentionally compact. They are designed for learning and diagnostics practice, not for direct copy-paste into production systems.
The important part is the comparison between the problem path and the mitigation path. That comparison makes the production failure mode visible and testable.