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: scripts/docs/en/userver/congestion_control.md
+36-23Lines changed: 36 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,38 +2,48 @@
2
2
3
3
## Introduction
4
4
5
-
congestion_control::Component (aka CC) limits the active requests count. CC has a RPS (request per second) limit mechanism that turns on
6
-
and off automatically depending on the main task processor workload. In case of overload CC responds with HTTP 429 codes to some requests,
7
-
allowing your service to properly process the rest. The RPS limit is determined by a heuristic algorithm inside CC.
8
-
All the significant parts of the component are configured by dynamic config options USERVER_RPS_CCONTROL and USERVER_RPS_CCONTROL_ENABLED.
5
+
@ref congestion_control::Component (aka CC) limits the active requests count. CC has a RPS (request per second)
6
+
limit mechanism that turns on and off automatically depending on the main task processor workload. In case of overload
7
+
CC responds with HTTP 429 codes to some requests, allowing your service to properly process the rest. The RPS limit
8
+
is determined by a heuristic algorithm inside CC. All the significant parts of the component are configured
9
+
by dynamic config options @ref USERVER_RPS_CCONTROL and @ref USERVER_RPS_CCONTROL_ENABLED.
9
10
10
11
CC can run in `fake-mode` with no RPS limit (but FSM works). CC goes into `fake-mode` in the following cases:
11
12
12
13
* there are no reliable guarantees on CPU, in this case RPS-limit would be triggered too often,
13
-
* service has no HTTP-handles others than server::handlers::Ping.
14
+
* service has no HTTP-handles others than @refserver::handlers::Ping.
14
15
15
-
`fake-mode` can be useful for more flexible traffic restriction settings, according to it's more complex logic, which can be implemented in a middleware.
16
+
`fake-mode` can be useful for more flexible traffic restriction settings, according to it's more complex logic, which
17
+
can be implemented in a middleware.
16
18
17
19
## Usage
18
20
19
-
congestion_control::Component can be useful if your service stops handling requests when overloaded, significantly increasing response time, responding with HTTP 500 codes to requests, eating memory.
21
+
@ref congestion_control::Component can be useful if your service stops handling requests when overloaded, significantly
22
+
increasing response time, responding with HTTP 500 codes to requests, eating memory.
23
+
20
24
Including CC in your service will help you handle some reasonable request flow returning HTTP error codes to the rest.
21
25
22
26
### Usage restrictions
23
27
24
-
congestion_control::Component cannot be useful if:
28
+
@refcongestion_control::Component cannot be useful if:
25
29
26
-
1. Your service has an exact RPS limit requirement. The heuristic algorithm depends on how much and in what mode the CPU is used in the current container.
30
+
1. Your service has an exact RPS limit requirement. The heuristic algorithm depends on how much and in what mode the
31
+
CPU is used in the current container.
27
32
28
33
2. CPU is not a limiting resource.
29
34
30
-
3. Stable response time is not needed. Some services do not need stable response time. They process events in batches which can come at random times. Despite peak overload may be reached there is enough resources to process event flow on average. For example services like PUBSUB subscriber or message broker consumer cannot benefit from a CC component.
35
+
3. Stable response time is not needed. Some services do not need stable response time. They process events in batches
36
+
which can come at random times. Despite peak overload may be reached there is enough resources to process event flow
37
+
on average. For example services like PUBSUB subscriber or message broker consumer cannot benefit from a
38
+
CC component.
31
39
32
-
4. CPU request processing lasts a considerable time. The RPS limit mechanism assumes that the handler processing time is short and RPC limit change affects CPU workload (seconds or less). If the handler takes a long time to process a request then the feedback will be stalling and maximum RPS convergence is not guaranteed.
40
+
4. CPU request processing lasts a considerable time. The RPS limit mechanism assumes that the handler processing time
41
+
is short and RPC limit change affects CPU workload (seconds or less). If the handler takes a long time to process
42
+
a request then the feedback will be stalling and maximum RPS convergence is not guaranteed.
33
43
34
44
## Example configuration
35
45
36
-
1. Add congestion_control::Component in the static config:
46
+
1. Add @refcongestion_control::Component in the static config:
37
47
```
38
48
# yaml
39
49
components_manager:
@@ -43,11 +53,12 @@ components_manager:
43
53
load-enabled: true
44
54
```
45
55
46
-
2.Enable USERVER_RPS_CCONTROL_ENABLED.
56
+
2.Set to `true` the value of @refUSERVER_RPS_CCONTROL_ENABLED dynamic config.
47
57
48
-
3. Adjust the heuristic settings in USERVER_RPS_CCONTROL if needed.
58
+
3. Adjust the heuristic settings in @refUSERVER_RPS_CCONTROL if needed.
49
59
50
-
It is a good idea to disable congestion_control::Component in unit tests to avoid getting HTTP 429 on an overloaded CI server.
60
+
It is a good idea to disable @ref congestion_control::Component in unit tests to avoid getting HTTP 429 on an
61
+
overloaded CI server.
51
62
52
63
## Settings
53
64
@@ -59,15 +70,16 @@ In some situations default settings are ineffective. For example:
59
70
60
71
in those situations congestion_control::Component settings need adjusting.
61
72
62
-
Basic configuration files:
73
+
Basic dynamic configuration options:
63
74
64
-
* USERVER_RPS_CCONTROL_ENABLED - turning CC on and off
75
+
*@refUSERVER_RPS_CCONTROL_ENABLED - turning CC on and off
0 commit comments