Skip to content

Commit 9017975

Browse files
committed
Update README.md
1 parent 87093cf commit 9017975

File tree

5 files changed

+14
-94
lines changed

5 files changed

+14
-94
lines changed

throttling/README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,25 @@ tags:
1010
---
1111

1212
## Intent
13+
1314
Ensure that a given client is not able to access service resources more than the assigned limit.
1415

1516
## Explanation
17+
1618
Real world example
1719

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.
1922
2023
In plain words
2124

2225
> Throttling pattern is used to rate-limit access to a resource.
2326
2427
[Microsoft documentation](https://docs.microsoft.com/en-us/azure/architecture/patterns/throttling) says
2528

26-
> 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.
2732
2833
**Programmatic Example**
2934

@@ -77,7 +82,8 @@ public final class CallsCount {
7782
}
7883
```
7984

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.
8187

8288
```java
8389
public interface Throttler {
@@ -134,7 +140,8 @@ class B2BService {
134140
}
135141
```
136142

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.
138145

139146
```java
140147
public static void main(String[] args) {
@@ -171,9 +178,11 @@ Now we are ready to see the full example in action. Tenant Adidas is rate-limite
171178

172179

173180
## Class diagram
174-
![alt text](./etc/throttling-pattern.png "Throttling pattern class diagram")
181+
182+
![alt text](./etc/throttling_urm.png "Throttling pattern class diagram")
175183

176184
## Applicability
185+
177186
The Throttling pattern should be used:
178187

179188
* When a service access needs to be restricted to not have high impacts on the performance of the service.

throttling/etc/throttling-pattern.png

-49 KB
Binary file not shown.

throttling/etc/throttling-pattern.ucls

Lines changed: 0 additions & 88 deletions
This file was deleted.

throttling/etc/throttling_urm.png

52.5 KB
Loading

throttling/src/main/java/com/iluwatar/throttling/CallsCount.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package com.iluwatar.throttling;
2525

2626
import java.util.Map;
27-
import java.util.Map.Entry;
2827
import java.util.concurrent.ConcurrentHashMap;
2928
import java.util.concurrent.atomic.AtomicLong;
3029
import org.slf4j.Logger;

0 commit comments

Comments
 (0)