1
00:00:00,870 --> 00:00:04,140
-: The next technique is rate limit.

2
00:00:04,140 --> 00:00:07,200
Now, using rate limit will limit the maximum

3
00:00:07,200 --> 00:00:09,900
concurrent requests the API handles.

4
00:00:09,900 --> 00:00:11,613
So let's understand what it means.

5
00:00:12,831 --> 00:00:14,430
Say we have the API

6
00:00:14,430 --> 00:00:16,650
and requests start coming

7
00:00:16,650 --> 00:00:18,060
to the API

8
00:00:18,060 --> 00:00:19,680
and more request, and more request

9
00:00:19,680 --> 00:00:21,210
and more request.

10
00:00:21,210 --> 00:00:25,020
And at some point the load on the API is

11
00:00:25,020 --> 00:00:26,340
so big

12
00:00:26,340 --> 00:00:30,420
that the API simply crashes and it is not useful anymore

13
00:00:30,420 --> 00:00:34,950
and no other user can access the API and make requests.

14
00:00:34,950 --> 00:00:36,600
So to avoid this situation

15
00:00:36,600 --> 00:00:40,380
we have the rate limit with the rate limit pattern.

16
00:00:40,380 --> 00:00:42,240
We put a Rate Limiter in

17
00:00:42,240 --> 00:00:43,890
front of the API

18
00:00:43,890 --> 00:00:46,740
and the various requests are first coming

19
00:00:46,740 --> 00:00:48,000
to the Rate Limiter.

20
00:00:48,000 --> 00:00:51,450
And then what happens is that requests start coming

21
00:00:51,450 --> 00:00:55,380
and when there are too many requests to the Rate Limiter

22
00:00:55,380 --> 00:00:57,540
it simply blocks the request

23
00:00:57,540 --> 00:01:00,390
and returns a response code signaling

24
00:01:00,390 --> 00:01:02,070
that the server is too busy

25
00:01:02,070 --> 00:01:04,560
and cannot accept anymore requests.

26
00:01:04,560 --> 00:01:07,890
But note that the API is still up and running

27
00:01:07,890 --> 00:01:09,750
and fully functional.

28
00:01:09,750 --> 00:01:12,420
After the API will complete the processing of

29
00:01:12,420 --> 00:01:14,310
all the requests he received

30
00:01:14,310 --> 00:01:17,073
then he's able to receive new requests.

