Designing for Failure: Chaos Engineering in .NET

Netflix popularized Chaos Engineering. In 2022, it should be standard practice. We deliberately inject failures to verify our systems handle them gracefully.

Simmy Library

Polly’s Simmy extension allows injecting faults in .NET.

C#6 lines
var chaosPolicy = MonkeyPolicy.InjectException(with =>
    with.Fault(new HttpRequestException("Simulated failure"))
        .InjectionRate(0.05) // 5% of requests fail
        .Enabled(IsChaosEnabled));

var result = await chaosPolicy.ExecuteAsync(() => _httpClient.GetAsync("/api/orders"));

Run this in a staging environment and verify your retry logic, circuit breakers, and fallback mechanisms work correctly.


Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Written by

Nithin Mohan TK

Hello Namaste! 👋🏻 I'm an accomplished Enterprise Solution Architect & Engineering Leader with 20+ years of progressive experience architecting, building, and scaling transformative enterprise solutions. ⚜️ Solution Architect / AI & Cloud 📌 Galway, Ireland

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.