-: The next technique is rate limit.
Now, using rate limit will limit the maximum
concurrent requests the API handles.
So let's understand what it means.
Say we have the API
and requests start coming
to the API
and more request, and more request
and more request.
And at some point the load on the API is
so big
that the API simply crashes and it is not useful anymore
and no other user can access the API and make requests.
So to avoid this situation
we have the rate limit with the rate limit pattern.
We put a Rate Limiter in
front of the API
and the various requests are first coming
to the Rate Limiter.
And then what happens is that requests start coming
and when there are too many requests to the Rate Limiter
it simply blocks the request
and returns a response code signaling
that the server is too busy
and cannot accept anymore requests.
But note that the API is still up and running
and fully functional.
After the API will complete the processing of
all the requests he received
then he's able to receive new requests.