Introduction

The world is moving towards a micro-service oriented Systems. It’s really important to prevent web services from attacks such as DOS(Denial of service). Rate limiting is generally put in place as a defensive measure for services. To protect services from excessive use whether intended or unintended. It also helps to ensure service availability to all the clients in a fair manner.

While this capability can be easily integrated using Reverse proxy servers with the applications. Generally, Reverse Proxy servers do rate limiting based on the number of times client has hit the service. But, there might be scenarios where you want to enable rate-limiting based on other attributes. For e.g. say, you might want to rate-limit a client based on the number of records requested by the client from the database. So, it’s always an add on to understand how this capability can be extended in the applications.

Let’s try to create a custom implementation of Rate Limiting.

Prerequisites

Having a fair understanding of:

  • GoLang
  • Docker
  • Redis — For caching IP to count mapping

#golang #redis #rate-limiting #docker

Custom Rate Limiting in GoLang using Redis with Docker
22.30 GEEK