You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: throttling/README.md
+14-5Lines changed: 14 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,25 @@ tags:
10
10
---
11
11
12
12
## Intent
13
+
13
14
Ensure that a given client is not able to access service resources more than the assigned limit.
14
15
15
16
## Explanation
17
+
16
18
Real world example
17
19
18
-
> A large multinational corporation offers API to its customers. The API is rate-limited and each customer can only make certain amount of calls per second.
20
+
> A large multinational corporation offers API to its customers. The API is rate-limited and each
21
+
> customer can only make certain amount of calls per second.
19
22
20
23
In plain words
21
24
22
25
> Throttling pattern is used to rate-limit access to a resource.
> Control the consumption of resources used by an instance of an application, an individual tenant, or an entire service. This can allow the system to continue to function and meet service level agreements, even when an increase in demand places an extreme load on resources.
29
+
> Control the consumption of resources used by an instance of an application, an individual tenant,
30
+
> or an entire service. This can allow the system to continue to function and meet service level
31
+
> agreements, even when an increase in demand places an extreme load on resources.
27
32
28
33
**Programmatic Example**
29
34
@@ -77,7 +82,8 @@ public final class CallsCount {
77
82
}
78
83
```
79
84
80
-
Next we introduce the service that the tenants are calling. To track the call count we use the throttler timer.
85
+
Next we introduce the service that the tenants are calling. To track the call count we use the
86
+
throttler timer.
81
87
82
88
```java
83
89
publicinterfaceThrottler {
@@ -134,7 +140,8 @@ class B2BService {
134
140
}
135
141
```
136
142
137
-
Now we are ready to see the full example in action. Tenant Adidas is rate-limited to 5 calls per second and Nike to 6.
143
+
Now we are ready to see the full example in action. Tenant Adidas is rate-limited to 5 calls per
144
+
second and Nike to 6.
138
145
139
146
```java
140
147
publicstaticvoid main(String[] args) {
@@ -171,9 +178,11 @@ Now we are ready to see the full example in action. Tenant Adidas is rate-limite
171
178
172
179
173
180
## Class diagram
174
-

181
+
182
+

175
183
176
184
## Applicability
185
+
177
186
The Throttling pattern should be used:
178
187
179
188
* When a service access needs to be restricted to not have high impacts on the performance of the service.
0 commit comments