Skip to content

petesramek/dotnet-production-diagnostics-lab

Repository files navigation

.NET Production Diagnostics Lab

A small ASP.NET Core diagnostics lab showing common production-style problems, how to detect them, and how to improve reliability, performance, and observability.

This repository is a hands-on lab, not a production template and not an architecture showcase.

What this repo demonstrates

  • Slow data access caused by inefficient queries
  • N+1 / chatty data access caused by per-row database calls
  • Missing cancellation and timeout behavior
  • Sync-over-async / blocking request handling
  • Poor observability and weak logging
  • Reliability issues caused by unsafe external dependency calls
  • Retry storms caused by uncontrolled retries
  • Memory pressure caused by building large responses in memory
  • Configuration problems detected too late instead of at startup
  • Missing health checks for operational visibility
  • Startup work that fails silently instead of failing fast
  • Logging or audit sink failures leaking into business operations
  • Request body memory pressure caused by buffering large uploads

How to run

dotnet restore
dotnet run --project src/DiagnosticsLab.Api

The API uses SQLite and creates local seed data automatically.

Scenarios

  • Problem: GET /api/orders/slow?customerId=42
  • Improved: GET /api/orders/improved?customerId=42
  • Problem: GET /api/reports/slow
  • Improved: GET /api/reports/cancellable
  • Problem: POST /api/payments/problem
  • Improved: POST /api/payments/observable
  • Problem: GET /api/shipping/problem?country=CZ
  • Improved: GET /api/shipping/resilient?country=CZ
  • Problem: GET /api/customers/problem?take=25
  • Improved: GET /api/customers/improved?take=25
  • Problem: GET /api/blocking/problem?delayMs=500
  • Improved: GET /api/blocking/improved?delayMs=500
  • Problem: GET /api/inventory/problem?sku=FAIL
  • Improved: GET /api/inventory/improved?sku=FAIL
  • Problem: GET /api/exports/problem?rows=1000
  • Improved: GET /api/exports/improved?rows=1000
  • Problem: GET /api/config/problem
  • Improved: application startup validates ExternalServices:BillingApiBaseUrl
  • Improved: GET /health/live and GET /health/ready
  • Problem: GET /api/startup/problem
  • Improved: GET /api/startup/improved
  • Problem: POST /api/audit/problem
  • Improved: POST /api/audit/improved
  • Problem: POST /api/uploads/problem
  • Improved: POST /api/uploads/improved

Tests

dotnet test

The tests include smoke checks, scenario checks, startup validation checks, and endpoint behavior checks.

Notes

The examples are intentionally small. The goal is to make production-style problems easy to see, explain, and improve.

About

ASP.NET Core diagnostics lab showing common production-style problems and practical improvements for reliability, performance, and observability.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages