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
|`DefaultRateLimiterOptions`|`PermitLimit` set to 1000 and `QueueLimit` set to 0. | The options for the default concurrency limiter that will be used when `RateLimiter` is `null`. |
75
75
|`OnRejected`|`null`| Event that is raised when the execution is rejected by the rate limiter. |
76
76
77
+
## Diagrams
78
+
79
+
### Rate Limiter
80
+
81
+
Let's suppose we have a rate limiter strategy with `PermitLimit` : `1` and `Window` : `10 seconds`.
82
+
83
+
### Rate Limiter: happy path sequence diagram
84
+
85
+
```mermaid
86
+
%%{init: {'theme':'dark'}}%%
87
+
sequenceDiagram
88
+
actor C as Caller
89
+
participant P as Pipeline
90
+
participant RL as RateLimiter
91
+
participant D as DecoratedUserCallback
92
+
93
+
C->>P: Calls ExecuteAsync
94
+
P->>RL: Calls ExecuteCore
95
+
Note over RL,D: Window start
96
+
RL->>+D: Invokes
97
+
D->>-RL: Returns result
98
+
RL->>P: Returns result
99
+
P->>C: Returns result
100
+
Note over C: Several seconds later...
101
+
Note over RL,D: Window end
102
+
C->>P: Calls ExecuteAsync
103
+
P->>RL: Calls ExecuteCore
104
+
Note over RL,D: Window start
105
+
RL->>+D: Invokes
106
+
D->>-RL: Returns result
107
+
RL->>P: Returns result
108
+
P->>C: Returns result
109
+
Note over RL,D: Window end
110
+
```
111
+
112
+
#### Rate limiter: unhappy path sequence diagram
113
+
114
+
```mermaid
115
+
%%{init: {'theme':'dark'}}%%
116
+
sequenceDiagram
117
+
actor C as Caller
118
+
participant P as Pipeline
119
+
participant RL as RateLimiter
120
+
participant D as DecoratedUserCallback
121
+
122
+
C->>P: Calls ExecuteAsync
123
+
P->>RL: Calls ExecuteCore
124
+
Note over RL,D: Window start
125
+
RL->>+D: Invokes
126
+
D->>-RL: Returns result
127
+
RL->>P: Returns result
128
+
P->>C: Returns result
129
+
Note over C: Few seconds later...
130
+
C->>P: Calls ExecuteAsync
131
+
P->>RL: Calls ExecuteCore
132
+
RL->>RL: Rejects request
133
+
RL->>P: Throws <br/>RateLimiterRejectedException
134
+
P->>C: Propagates exception
135
+
Note over RL,D: Window end
136
+
```
137
+
138
+
### Concurrency Limiter
139
+
140
+
Let's suppose we have a concurrency limiter strategy with `PermitLimit` : `1` and `QueueLimit` : `1`.
The `RateLimiter` is a disposable resource. When you explicitly create a `RateLimiter` instance, it's good practice to dispose of it once it's no longer needed. This is usually not an issue when manually creating resilience pipelines using the `ResiliencePipelineBuilder`. However, when dynamic reloads are enabled, failing to dispose of discarded rate limiters can lead to excessive resource consumption. Fortunately, Polly provides a way to dispose of discarded rate limiters, as demonstrated in the example below:
0 commit comments