Skip to content

Commit 89ce2b0

Browse files
committed
feat docs: more links and cleaner docs for CongestionControl
Tests: на прод не влияет commit_hash:2d7ff10c527b1ed10120d4803c40d8cd217a6f9e
1 parent 149b0a7 commit 89ce2b0

File tree

1 file changed

+36
-23
lines changed

1 file changed

+36
-23
lines changed

scripts/docs/en/userver/congestion_control.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,48 @@
22

33
## Introduction
44

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

1011
CC can run in `fake-mode` with no RPS limit (but FSM works). CC goes into `fake-mode` in the following cases:
1112

1213
* 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 @ref server::handlers::Ping.
1415

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

1719
## Usage
1820

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+
2024
Including CC in your service will help you handle some reasonable request flow returning HTTP error codes to the rest.
2125

2226
### Usage restrictions
2327

24-
congestion_control::Component cannot be useful if:
28+
@ref congestion_control::Component cannot be useful if:
2529

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

2833
2. CPU is not a limiting resource.
2934

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

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

3444
## Example configuration
3545

36-
1. Add congestion_control::Component in the static config:
46+
1. Add @ref congestion_control::Component in the static config:
3747
```
3848
# yaml
3949
components_manager:
@@ -43,11 +53,12 @@ components_manager:
4353
load-enabled: true
4454
```
4555

46-
2. Enable USERVER_RPS_CCONTROL_ENABLED.
56+
2. Set to `true` the value of @ref USERVER_RPS_CCONTROL_ENABLED dynamic config.
4757

48-
3. Adjust the heuristic settings in USERVER_RPS_CCONTROL if needed.
58+
3. Adjust the heuristic settings in @ref USERVER_RPS_CCONTROL if needed.
4959

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

5263
## Settings
5364

@@ -59,15 +70,16 @@ In some situations default settings are ineffective. For example:
5970

6071
in those situations congestion_control::Component settings need adjusting.
6172

62-
Basic configuration files:
73+
Basic dynamic configuration options:
6374

64-
* USERVER_RPS_CCONTROL_ENABLED - turning CC on and off
75+
* @ref USERVER_RPS_CCONTROL_ENABLED - turning CC on and off
6576

66-
* USERVER_RPS_CCONTROL - basic CC settings
77+
* @ref USERVER_RPS_CCONTROL - basic CC settings
6778

68-
* USERVER_TASK_PROCESSOR_QOS - note `default-service.default-task-processor.wait_queue_overload.sensor_time_limit_us`.
69-
This setting defines wait in queue time after which the overload events for RPS congestion control are generated.
70-
It is recommended to set this setting >= 2000 (2 ms) because system scheduler (CFS) time unit by default equals 2 ms.
79+
* @ref USERVER_TASK_PROCESSOR_QOS - note
80+
`default-service.default-task-processor.wait_queue_overload.sensor_time_limit_us`.
81+
This setting defines wait in queue time after which the overload events for RPS congestion control are generated.
82+
It is recommended to set this setting >= 2000 (2 ms) because system scheduler (CFS) time unit by default equals 2 ms.
7183

7284
## Diagnostics
7385

@@ -83,8 +95,9 @@ Most likely your service has synchronous operations that block the coroutine flo
8395

8496
* Try to find synchronous system calls which block the corountine flow.
8597

86-
* Try to find slow coroutines. To do this you can use coroutine profiling. See the dynamic configuration file USERVER_TASK_PROCESSOR_PROFILER_DEBUG
87-
that stores profiling settings. After finding such coroutines you need to locate trouble-making code with log analysis etc.
98+
* Try to find slow coroutines. To do this you can use coroutine profiling. See the dynamic configuration
99+
@ref USERVER_TASK_PROCESSOR_PROFILER_DEBUG that stores profiling settings. After finding such coroutines you need
100+
to locate trouble-making code with log analysis etc.
88101

89102
----------
90103

0 commit comments

Comments
 (0)