docs: document connection limit, async fetch, and connection pool

Update USAGE, CHEATSHEET, README, PROJECT, and TASKS for the three
performance improvements: max_connections semaphore, async HTTP
source fetching, and first-hop TCP connection pool.
This commit is contained in:
user
2026-02-15 17:56:08 +01:00
parent 248f5c3306
commit 40560ef6dd
5 changed files with 63 additions and 2 deletions

View File

@@ -43,6 +43,9 @@ listen: 127.0.0.1:1080
timeout: 10
retries: 3
log_level: info
max_connections: 256 # concurrent connection limit (backpressure)
pool_size: 0 # pre-warmed TCP connections to first hop (0 = disabled)
pool_max_idle: 30 # max idle time for pooled connections (seconds)
chain:
- socks5://127.0.0.1:9050
@@ -245,9 +248,10 @@ Settings reloaded on SIGHUP:
| `timeout` | Per-connection timeout |
| `retries` | Max retry attempts |
| `log_level` | Logging verbosity |
| `max_connections` | Concurrent connection limit |
| `proxy_pool.*` | Sources, intervals, thresholds |
Settings that require a restart: `listen`, `chain`.
Settings that require a restart: `listen`, `chain`, `pool_size`, `pool_max_idle`.
Requires `-c` / `--config` to know which file to re-read. Without a
config file, SIGHUP is ignored with a warning.
@@ -304,6 +308,40 @@ curl --proxy socks5h://127.0.0.1:1080 https://example.com
Note: use `socks5h://` (not `socks5://`) with curl to send DNS through the proxy.
## Connection Limit
s5p caps concurrent connections with an `asyncio.Semaphore`. When all
slots are taken, new clients backpressure at TCP accept (the connection
is accepted but the handler waits for a slot).
```yaml
max_connections: 256 # default
```
```bash
s5p -m 512 # override via CLI
```
The `max_connections` value is reloaded on SIGHUP. Connections already
in flight are not affected -- new limits take effect as active connections
close.
## First-Hop Connection Pool
Pre-warms TCP connections to the first hop in the chain, avoiding the
TCP handshake latency on each client request. Only the raw TCP
connection is pooled -- once SOCKS/HTTP CONNECT negotiation begins,
the connection is consumed.
```yaml
pool_size: 8 # 0 = disabled (default)
pool_max_idle: 30 # seconds before a pooled connection is evicted
```
Connections idle longer than `pool_max_idle` are discarded and replaced.
A background task tops up the pool at half the idle interval. Requires
at least one hop in `chain` -- ignored if chain is empty.
## Chain Order
Hops are traversed left-to-right: