Skip to content

Repository files navigation

YERP

YARP (Yet Another Reverse Proxy) is a high-performance reverse proxy library developed by Microsoft for ASP.NET Core. It enables API Gateway scenarios such as load balancing, request routing, authentication, rate limiting, health checks, and service discovery while remaining fully customizable through .NET code.

Load Balancing Policies

Round Robin

Requests are distributed sequentially across all available instances. This approach provides an even load distribution and is simple to understand and implement.

Random

Each incoming request is routed to a randomly selected backend instance. While simple, the distribution may become uneven over short periods of time.

Power Of Two Choices

Two backend instances are selected at random, and the request is routed to the one with fewer active requests. This strategy typically achieves better load distribution and lower latency than pure Round Robin or Random balancing.

How to test

Run all 3 services and then open https://localhost:7181/api

image

FastEndpoints

FastEndpoints is a lightweight alternative to the traditional ASP.NET Core MVC Controllers and Minimal APIs, focused on building fast, modular, and strongly typed HTTP endpoints. It uses a vertical slice approach where request, handler, validation, and response models can be organized together, reducing boilerplate and improving maintainability. Key features include built-in validation, strongly typed requests and responses, endpoint grouping, authorization, Swagger/OpenAPI integration, and support for command/handler-style processing.

Minimal Api's

Minimal APIs provide a lightweight way to build HTTP APIs in ASP.NET Core without the controllers, attributes, and much of the ceremony of MVC. They support routing, dependency injection, validation, authorization, filters, route groups, and endpoint metadata, making them a good choice for small APIs and microservices.

RateLimiting

Rate limiting controls how many requests a client can make within a specific period or how many requests can be processed concurrently. It helps protect services from excessive traffic, prevents resource exhaustion, and ensures fair access to APIs.

Fixed Window

Fixed Window divides time into fixed intervals and allows a predefined number of requests within each interval. It is simple and efficient, but can allow traffic bursts at the boundary between two windows.

image

Sliding Window

Sliding Window evaluates requests over a continuously moving time window instead of resetting the counter at fixed boundaries. It provides smoother traffic control and reduces the boundary burst problem of Fixed Window.

image

Token Bucket

Token Bucket stores a limited number of tokens, where each request consumes one token and new tokens are added at a fixed rate. It allows controlled bursts while maintaining a long-term request rate.

CorrelationId Middleware

Correlation ID Middleware assigns a unique identifier to each HTTP request, allowing the request to be tracked across logs and multiple microservices. It reuses the X-Correlation-ID provided by the client or generates a new one when it is missing, then returns it in the response headers. This makes troubleshooting and tracing distributed requests much easier.

About

No description or website provided.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages