235 published guides

Explore the library

Browse The .NET Weekly archive →
  • Resilience

    Chaos Engineering in .NET With Simmy

    You have retries, circuit breakers, and timeouts configured. Have you ever seen them fire? Simmy injects faults, latency, and bad responses into your Polly pipelines so you can prove your resilience policies work before a real outage tests them. Fault injection often turns up a policy that was a misconfigured no-op.

  • Resilience

    Exponential Backoff and Jitter in .NET

    When a service blips, every client that failed retries on the same schedule: 2 seconds, 4 seconds, 8 seconds. The result is synchronized waves of traffic hammering a recovering dependency. Jitter breaks the synchronization, and Polly v8 supports it with a single property.

  • Resilience

    Readiness vs Liveness Probes in ASP.NET Core

    Put a database check in your liveness probe and a database outage becomes a restart storm: Kubernetes kills every healthy pod in the fleet, over and over, until the database returns. The fix is a tag-based split of your health checks. Here is the setup, and the reasoning for which check goes where.

  • Resilience

    Retry vs Circuit Breaker: When to Use Each

    Retry and circuit breaker assume opposite things about a failure. Retries assume it is transient and try again; breakers assume it is systemic and stop calling the dependency. When you use both, the order decides which one sees a failure first. Here is the Polly v8 pipeline that composes them, with the breaker inside the retry.

  • Resilience

    The Bulkhead Pattern in .NET

    One slow downstream service can take out your entire application without returning a single error, by tying up the connections, memory, and blocked threads every other request needs. The bulkhead pattern caps how much of your capacity any single dependency can use. Here is how to build bulkheads in .NET with semaphores, Polly concurrency limiters, and partitioned HttpClients.

  • Resilience

    The Fallback Pattern With Polly

    Retries and circuit breakers decide how to fail. The fallback decides what the user sees when everything else has failed. A good fallback returns a visibly degraded answer instead of a fake success. Here is how to build fallbacks with Polly v8, where they belong in the pipeline, and what to log when they fire.

  • Resilience

    Timeout Strategies in .NET: Per-Call, Per-Request, and Total Budget

    A single "timeout" setting hides three different things: how long one attempt may take, how long the whole retry sequence may take, and how long the inbound request may take. Set them independently and they stack, which can turn a 30-second timeout into a multi-minute wait. Here is the layered model, a request-budget approach that stops the stacking, and the .NET code for each layer.

  • Resilience

    Polly v8: Resilience Pipelines Explained

    Polly v8 replaced policies with resilience pipelines: a rewritten core with allocation-free execution, built-in telemetry, and one composition model instead of PolicyWrap. Here is how the new API maps to the old one, how to register pipelines with DI, and why the order you add strategies changes what your pipeline does.

AI for .NET

  • AI for .NET

    I Let Nine AI Agents Rebuild My Unfinished .NET App

    I gave Factory one prompt to finish a .NET app I started in 2022. Nine AI agents moved it to .NET 11, rebuilt the Result type on C# 15 unions, replaced EF Core with Dapper, added a React UI, and wrote 1,048 backend tests. One of them also deleted a file from my machine.

  • AI for .NET

    Building a RAG System in .NET

    Every RAG demo works until you point it at your own documents and it confidently makes things up. Chunking, embeddings, and retrieval quality decide whether the answer comes from your data or from thin air. Here is a complete RAG pipeline in .NET with Microsoft.Extensions.AI, PostgreSQL with pgvector, hybrid search, re-ranking, and source attribution.

C#

  • C#

    C# Union Types vs the Result Pattern: Performance

    I benchmarked four return types for a command handler on .NET 11: the Result class, a union of records, a generic union, and a hand-written non-boxing union. Every union beat the Result class without async, and behind an async handler the Task allocation outweighed all four.

Caching

  • Caching

    Content-Addressed Caching in .NET: Cache Keys That Never Go Stale

    Cache invalidation is hard because we name cache entries after locations. Name them after a hash of their inputs instead, and the whole class of stale-read bugs stops being possible, because changing any input produces a different key. Git, Docker, and NuGet all run on this idea, and it works just as well inside your own application.

  • Caching

    Multi-Level Caching in .NET With FusionCache

    Rolling your own IMemoryCache plus Redis gets you 80% of a caching stack but skips three hard problems: cross-instance invalidation, cache stampede, and serving stale data when the source is down. FusionCache gives you L1, L2, a backplane, and all three behaviors out of the box.

Messaging

  • Messaging

    How I Use NATS JetStream as a Job Queue in .NET

    My first job queue was a Redis list, and it had two ways to lose a job: a worker crash after LPOP, and a broker restart. NATS JetStream closed both with a work-queue stream, a durable pull consumer, and one ordering rule: publish the result before you ack the job. Here is the whole design.

  • Messaging

    RabbitMQ vs Kafka for .NET Applications

    RabbitMQ deletes messages once consumed; Kafka keeps them and moves a cursor. That single design decision explains almost every difference between them: replay, fan-out, ordering, routing, and scaling. Classify your messages as jobs or as facts and you know which one your .NET system needs.

Observability

  • Observability

    OpenTelemetry Collectors: The Agent + Gateway Pattern

    One OpenTelemetry Collector is easy. The design changes once your apps run on more than one machine: a small agent collector on every box, forwarding to one gateway collector that fans out to Tempo, Loki, and Prometheus. Here is the two-tier setup I run in production, including the two config lines that keep the collector's memory in check on the box it shares with real workloads.

Testing

  • Testing

    Architecture Fitness Functions in .NET With ArchUnitNET

    An architecture rule nobody enforces depends on reviewers catching every violation. A fitness function turns it into a build failure that names the offending type. Here is how to write them with ArchUnitNET, including slice cycle detection, three ways a fitness function stays green while the code breaks the rule, and what to do when your rule set outgrows code.

  • Testing

    Unit Testing Best Practices in .NET

    Poorly written unit tests break on every refactor and slow development down. These .NET practices cover test structure, naming, test data builders, mocking boundaries, and testing behavior instead of implementation details.

API Design

  • API Design

    Choosing the Right HTTP Status Codes for Your API

    Nobody argues about 200 and 500. The fights are in the middle: 400 vs 422, 401 vs 403, 404 vs 410, and whether 200-with-an-error-body is ever acceptable (it is not). A decision tree for the ambiguous cases, with the ASP.NET Core mappings.

ASP.NET Core

  • ASP.NET Core

    Minimal APIs in .NET: Complete Guide

    Minimal APIs are a lightweight way to build HTTP APIs in .NET without controllers, startup classes, or conventions. This guide covers routing, validation, authentication, and structuring Minimal APIs at scale.

DevOps

Microservices

  • Microservices

    Microservices in .NET: Getting Started Guide

    A .NET microservice system needs more than separately deployed APIs: each service owns its data, communication survives partial failure, and traces cross every boundary. This guide builds a small end-to-end system and makes the cost visible before you choose it.

Performance

  • Performance

    Async/Await Performance Pitfalls in .NET

    Async improves throughput only while the work stays nonblocking. Sync-over-async, accidental serialization, unnecessary state machines, and unbounded fan-out can make an asynchronous endpoint slower or deadlock it entirely.

Real-Time

Security