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.

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.

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.