YARP vs Envoy vs Ocelot: Choosing an API Gateway for .NET Microservice
A deep comparison of YARP, Envoy, and Ocelot for .NET microservices, covering architecture, internals, performance, use cases, and implementation examples with code.
YARP vs Envoy vs Ocelot: Choosing an API Gateway for .NET Microservices
Last Updated: July 9, 2026
Target Platform: .NET 8, .NET 9, .NET 10, Kubernetes, Cloud-Native Applications
Introduction
As applications evolve from monoliths into distributed systems, an API Gateway becomes a critical component of a microservices architecture. Instead of exposing every service directly to clients, the gateway acts as a single entry point that centralizes cross-cutting concerns such as routing, authentication, rate limiting, observability, and traffic management.
Client
↓
API Gateway
↓
────────────────────
User Service
Order Service
Product Service
Payment Service
────────────────────A modern API Gateway typically provides:
- Request routing
- Load balancing
- Authentication and authorization
- Rate limiting and throttling
- Service discovery
- Circuit breaking and retries
- Logging and observability
- API aggregation
- Protocol translation (HTTP, gRPC, WebSocket)
For .NET developers, three gateway technologies are commonly discussed:
- YARP (Yet Another Reverse Proxy)
- Envoy Proxy
- Ocelot
This article compares them from the perspectives of architecture, internal principles, performance, use cases, and implementation.
---
Overview
| Gateway | Language | Category | Best For |
|---|---|---|---|
| YARP | C# | Reverse Proxy Library | Modern .NET Microservices |
| Envoy | C++ | High-Performance Proxy | Cloud-Native Platforms |
| Ocelot | C# | API Gateway Framework | Legacy and Small Projects |
---
Architecture and Internal Design
YARP
YARP is Microsoft's open-source reverse proxy built on top of ASP.NET Core.
Architecture
Client
↓
Kestrel
↓
YARP Middleware
↓
Routing
↓
Load Balancer
↓
Transforms
↓
Destination ServiceCore Principles
- Built on the ASP.NET Core middleware pipeline.
- Fully managed .NET implementation.
- Uses asynchronous I/O and the
HttpClientpipeline. - Supports dependency injection and middleware extensions.
- Configuration can be loaded dynamically.
Advantages
- Native .NET integration
- Excellent extensibility
- Strong performance
- Easy customization
Limitations
- No built-in service mesh capabilities.
- Some advanced traffic management features require custom development.
---
Envoy
Envoy is a high-performance proxy originally developed by Lyft and is now a CNCF graduated project.
Architecture
Client
↓
Listener
↓
Filter Chain
↓
HTTP Connection Manager
↓
Cluster
↓
EndpointCore Principles
- Event-driven and multi-threaded architecture.
- Written in C++ for maximum performance.
- Dynamic configuration through xDS APIs.
- Designed for service mesh and cloud-native environments.
Advantages
- Extremely high throughput
- Advanced traffic management
- Native gRPC support
- Excellent observability
- Service mesh foundation
Limitations
- Steep learning curve
- More operational complexity
- Less developer-friendly for pure .NET teams
---
Ocelot
Ocelot is one of the earliest API gateway frameworks built specifically for .NET microservices.
Architecture
Client
↓
Middleware Pipeline
↓
Authentication
↓
Authorization
↓
Load Balancer
↓
Downstream ServiceCore Principles
- Configuration-driven gateway.
- Built on ASP.NET Core middleware.
- Focuses on simplicity and quick setup.
Advantages
- Easy to learn
- Minimal setup
- Good for small systems
Limitations
- Lower performance
- Reduced community activity
- Limited extensibility compared to YARP
---
Performance Comparison
Performance varies depending on workload, hardware, and configuration, but the following trends are commonly observed.
| Metric | YARP | Envoy | Ocelot |
|---|---|---|---|
| Throughput | High | Very High | Medium |
| Latency | Low | Very Low | Moderate |
| Memory Usage | Medium | Low | Medium |
| Scalability | High | Extremely High | Moderate |
| Concurrent Connections | 100K+ | Millions | Tens of Thousands |
Performance Ranking
Envoy > YARP >>> Ocelot---
Feature Comparison
| Capability | YARP | Envoy | Ocelot |
|---|---|---|---|
| HTTP/1.1 | ✅ | ✅ | ✅ |
| HTTP/2 | ✅ | ✅ | ✅ |
| HTTP/3 | ❌ | ✅ | ❌ |
| gRPC | ✅ | ✅ | Limited |
| Service Discovery | ✅ | ✅ | ✅ |
| Dynamic Configuration | ✅ | ✅ | Limited |
| Rate Limiting | ✅ | ✅ | ✅ |
| Traffic Splitting | Limited | ✅ | ❌ |
| Service Mesh | ❌ | ✅ | ❌ |
| Kubernetes Native | Moderate | Excellent | Poor |
---
Implementation Examples
YARP
Installation
dotnet add package Yarp.ReverseProxyConfiguration
{
"ReverseProxy": {
"Routes": {
"users": {
"ClusterId": "users-cluster",
"Match": {
"Path": "/users/{**catch-all}"
}
}
},
"Clusters": {
"users-cluster": {
"Destinations": {
"destination1": {
"Address": "https://localhost:7001/"
}
}
}
}
}
}Startup
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddReverseProxy()
.LoadFromConfig(
builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.MapReverseProxy();
app.Run();---
Envoy
envoy.yaml
static_resources:
listeners:
- name: listener_0
address:
socket_address:
address: 0.0.0.0
port_value: 8080
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
route_config:
virtual_hosts:
- name: backend
routes:
- match:
prefix: "/"
route:
cluster: user-service
clusters:
- name: user-service
connect_timeout: 5s
type: STRICT_DNS
lb_policy: ROUND_ROBIN---
Ocelot
Installation
dotnet add package OcelotConfiguration
{
"Routes": [
{
"DownstreamPathTemplate": "/api/users",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 7001
}
],
"UpstreamPathTemplate": "/users",
"UpstreamHttpMethod": ["Get"]
}
]
}Startup
builder.Services.AddOcelot();
var app = builder.Build();
await app.UseOcelot();
app.Run();---
Recommended Use Cases
YARP
Best for:
- Modern .NET microservices
- Internal enterprise systems
- SaaS applications
- Backend-for-Frontend (BFF) architectures
---
Envoy
Best for:
- Kubernetes platforms
- Service mesh environments
- High-throughput systems
- Large-scale distributed applications
---
Ocelot
Best for:
- Learning microservices
- Legacy .NET projects
- Small and medium applications
---
Which Gateway Should You Choose?
| Scenario | Recommendation |
|---|---|
| Pure .NET Team | YARP |
| Enterprise SaaS | YARP |
| Kubernetes Platform | Envoy |
| Service Mesh | Envoy |
| Legacy Project | Ocelot |
| Learning Purpose | Ocelot or YARP |
---
Recommended Learning Path
ASP.NET Core
↓
YARP
↓
.NET Aspire
↓
OpenTelemetry
↓
Dapr
↓
Kubernetes
↓
Envoy
↓
Istio
↓
Service Mesh---
Final Thoughts
For most modern .NET applications, YARP has become the default choice because it integrates naturally with ASP.NET Core and provides excellent performance and flexibility.
If your architecture is moving toward Kubernetes, multi-cluster deployments, or service mesh, Envoy becomes increasingly important and is worth investing time to learn.
Ocelot still has value for maintaining existing systems, but for new projects, YARP is generally the better long-term investment.
In short:
YARP for .NET developers, Envoy for cloud-native platforms, and Ocelot for legacy systems.
About petercontinue
peter love study
Comments
Sign in to leave a comment.