Introducing MicroMediator
A Lightweight High-Performance Mediator for .NET
I’ve just published a new NuGet package: TechnicalDogsbody.MicroMediator. It’s a lightweight, performance-focused mediator pattern implementation for .NET. This library will simplify how components talk to each other and remove boilerplate wiring. You can get it on NuGet or explore the source on GitHub.
The mediator pattern puts an object in the middle to handle communication between parts of your system instead of letting them depend directly on each other. This reduces coupling and makes code easier to maintain and test. The pattern is well known in software design, especially when you want cleaner control over interactions across services and handlers. (Wikipedia)
What MicroMediator Does
MicroMediator gives you a simple API for building request/response and streaming flows without dumping lots of dependencies into your project. Unlike some alternatives, it focuses on performance and minimal overhead.
Key capabilities include built-in support for:
- Validation of requests before they are handled.
- Logging of handler execution.
- Caching responses efficiently.
- Streaming large data sets using
IAsyncEnumerable. - Zero commercial licensing cost. (NuGet)
Benchmarks show it runs 2x–8x faster and uses less memory than some popular mediator libraries. (NuGet)
Why This Matters in Real Projects
When you build back-end systems or APIs, you often end up with services and controllers referencing lots of other services directly. That makes tests harder and refactoring riskier. With a mediator approach, you define a request type and a handler that processes it. Your controllers or jobs just call the mediator. This splits communication logic where it belongs and makes components easier to swap or mock.
MicroMediator with Optimizely CMS
In Optimizely CMS projects, especially complex ones built on the platform as a service (PaaS) model, you often have custom business logic outside the core content APIs. For example rendering logic for dynamic content areas, flattening query handlers, or dealing with rich content APIs in headless solutions. Patterns like this help you keep controllers and page models light and maintainable. (Andy Blyth - Technical Dogsbody)
Optimizely CMS itself runs on .NET and lets you write backend services using standard ASP.NET pipelines. A mediator fits neatly into that architecture. You can apply MicroMediator to handle commands that act on your CMS data, queries that fetch content or related business data, or custom jobs that run alongside your CMS. You register handlers with dependency injection and keep your logic separated in cohesive units.
This approach helps when:
- You deal with many distinct operations and want clean separation.
- You are building multi-site solutions with shared and site-specific logic.
- You need testable, maintainable backend code in a content-driven application.
Getting Started
Install the package:
dotnet add package TechnicalDogsbody.MicroMediator
Create a request and handler for your operation, register them with your IServiceCollection, and inject the mediator wherever you need it. It’s simple and removes a lot of wiring code.
Where Next
I’d like to write follow-up posts showing real Optimizely CMS use cases with MicroMediator. That includes how to structure handlers for CMS page data, how to stream large data sets efficiently, and how to add caching behaviours around content queries.
You’ll find full docs, examples, and benchmarks on the GitHub repo.
Andy Blyth
Andy Blyth, an Optimizely MVP (OMVP) and Technical Architect at 26 DX with a keen interest in martial arts, occasionally ventures into blogging when memory serves.



