Introduction

This is a series of two articles that will help you to learn about rate limiting and how can it be applied in a microservice or .net core API.

This series will cover the following things:

What is Rate limiting?

Why do we use Rate limiting?

Real-world use-case of Rate limiting

Public APIs use rate-limiting for commercial purposes to generate revenue. A common business model is to pay a certain subscription amount for leveraging the API. So, they can only make so many API calls before paying more for an upgraded plan.

Hands-on Lab – Create a WebAPI project and execute the API using swagger

Steps to be followed:

Hands-on Lab – Implement Rate limiting using the AspNetCoreRateLimit Nuget Package

Steps to be followed:

This is how we implemented rate limiting using AspNetCoreRateLimit Nuget Package, although the second approach will be covered in the next article on implementing rate limiting using custom middleware.

I've attached the source code for your reference.

Happy learning!