💀Rate Limit by IP address

What is an IP address?

In short terms, an IP address stands for Internet Protocol address. It is a unique numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication.

An IP address serves two main purposes:

  1. Device identification: It identifies and distinguishes a device (such as a computer, smartphone, or router) on a network. Similar to a phone number or a postal address, an IP address enables devices to send and receive data across the internet.

  2. Location addressing: An IP address helps in routing data packets between different devices and networks. It indicates the source and destination of data, allowing it to be transmitted from one device to another over the internet.

IP addresses are very useful for rate limiting as they help limit the amount resources a particular device consumes. Let's see how to rate limit by IP address with Sixth.

Step 1

Go to you desired dashboard and select the rate limiting option, after that all a page appears of all your listed endpoint, select your desired endpoint and you should have something like this.

Step 2

Before proceeding with step 2, let us explain what the 3rd and 4th field are and why they are so important to us at this point.

  • Unique ID to monitor for rate limiting: This field holds details about something unique to every client making a request to the particular endpoint in question, this can be field in the request payload e.g user_id, username, token, api keys e.t.c, that is unique to every client sending a request. This field is used under the hood to track who exactly is making the request so they can be rate limited if they exceed the rate limit conditions

  • Rate limit by: This field is used specify where the unique id is and it has 4 different values which are listed as follows

    • Ip address: This is used to indicate that the endpoint is being rate limited by the Ip address of the client. Ps: To make use Ip address as the preferred option for rate limiting, always set the Unique ID field to host

    • header: This is used to indicate that the endpoint is being rate limited by a value present in the header. The unique id is then set to the name of the header, For example let's take a look at a sample header json

      { 
          'name': 'John Doe', 
          'Content-Type': 'application/json'
        }

      If we want to rate limit by the "name" field present in the header json such that for every name, they can only make 1 request in 60 seconds, then for the Unique ID field, we would simply enter name as the field to monitor and choose the header field in the Rate Limit by options.

    • body: This is used to indicate that the endpoint is being rate limited by a field in the body of the incoming request being made to that endpoint.

Now that we know what these two fields do, you can go ahead to edit these fields. To rate limit by IP address set the Unique id to host and the Rate Limit by field to ip-address, you should have something identical to the below image when you aree done

And viola! you are all good to go!

Last updated