|
|
@@ -42,6 +42,29 @@ GET /stats
|
|
42
|
42
|
}
|
|
43
|
43
|
```
|
|
44
|
44
|
|
|
|
45
|
+**Connection throttling.** Automatic per-user connection limits to protect the server from overload. A background goroutine recomputes caps every few seconds using a fair-share algorithm: small users keep their connections, remaining budget is split equally among heavy consumers. New connections from over-cap users are rejected; existing connections are not killed.
|
|
|
46
|
+
|
|
|
47
|
+```toml
|
|
|
48
|
+[throttle]
|
|
|
49
|
+max-connections = 5000
|
|
|
50
|
+check-interval = "5s"
|
|
|
51
|
+```
|
|
|
52
|
+
|
|
|
53
|
+Example: limit = 100, users A=1, B=1, C=90, D=110.
|
|
|
54
|
+A and B stay at 1. Remaining budget 98 is split: C and D are capped at 49 each.
|
|
|
55
|
+
|
|
|
56
|
+Throttle state is exposed via the Stats API:
|
|
|
57
|
+
|
|
|
58
|
+```json
|
|
|
59
|
+{
|
|
|
60
|
+ "throttle": {
|
|
|
61
|
+ "active": true,
|
|
|
62
|
+ "limit": 5000,
|
|
|
63
|
+ "caps": { "heavy-user": 2450 }
|
|
|
64
|
+ }
|
|
|
65
|
+}
|
|
|
66
|
+```
|
|
|
67
|
+
|
|
45
|
68
|
**Public IP override.** Useful when auto-detection via ifconfig.co is unavailable.
|
|
46
|
69
|
|
|
47
|
70
|
```toml
|
|
|
@@ -73,6 +96,9 @@ Minimal config:
|
|
73
|
96
|
bind-to = "0.0.0.0:443"
|
|
74
|
97
|
api-bind-to = "127.0.0.1:9090"
|
|
75
|
98
|
|
|
|
99
|
+[throttle]
|
|
|
100
|
+max-connections = 5000
|
|
|
101
|
+
|
|
76
|
102
|
# [secrets] must be the last section in the global scope —
|
|
77
|
103
|
# in TOML, all keys after a [section] become part of that table.
|
|
78
|
104
|
[secrets]
|
|
|
@@ -126,6 +152,29 @@ GET /stats
|
|
126
|
152
|
}
|
|
127
|
153
|
```
|
|
128
|
154
|
|
|
|
155
|
+**Троттлинг подключений.** Автоматические per-user лимиты для защиты сервера от перегрузки. Фоновая горутина каждые несколько секунд пересчитывает капы по алгоритму fair-share: маленькие пользователи сохраняют свои подключения, оставшийся бюджет делится поровну между крупными потребителями. Новые подключения сверх капа отклоняются; существующие не разрываются.
|
|
|
156
|
+
|
|
|
157
|
+```toml
|
|
|
158
|
+[throttle]
|
|
|
159
|
+max-connections = 5000
|
|
|
160
|
+check-interval = "5s"
|
|
|
161
|
+```
|
|
|
162
|
+
|
|
|
163
|
+Пример: лимит = 100, пользователи A=1, B=1, C=90, D=110.
|
|
|
164
|
+A и B остаются на 1. Оставшийся бюджет 98 делится: C и D получают кап 49.
|
|
|
165
|
+
|
|
|
166
|
+Состояние троттлинга доступно через Stats API:
|
|
|
167
|
+
|
|
|
168
|
+```json
|
|
|
169
|
+{
|
|
|
170
|
+ "throttle": {
|
|
|
171
|
+ "active": true,
|
|
|
172
|
+ "limit": 5000,
|
|
|
173
|
+ "caps": { "heavy-user": 2450 }
|
|
|
174
|
+ }
|
|
|
175
|
+}
|
|
|
176
|
+```
|
|
|
177
|
+
|
|
129
|
178
|
**Ручное указание публичного IP.** Для случаев, когда ifconfig.co недоступен с сервера.
|
|
130
|
179
|
|
|
131
|
180
|
```toml
|
|
|
@@ -157,6 +206,9 @@ mtg-multi generate-secret --hex storage.googleapis.com
|
|
157
|
206
|
bind-to = "0.0.0.0:443"
|
|
158
|
207
|
api-bind-to = "127.0.0.1:9090"
|
|
159
|
208
|
|
|
|
209
|
+[throttle]
|
|
|
210
|
+max-connections = 5000
|
|
|
211
|
+
|
|
160
|
212
|
# [secrets] должен быть последней секцией в глобальном scope —
|
|
161
|
213
|
# в TOML все ключи после [section] становятся частью этой таблицы.
|
|
162
|
214
|
[secrets]
|