# 速度过慢

"慢"很少是网关本身——多半是住宅/移动网络、你的客户端配置、或目标站点。按下面流程逐项诊断。

## 基线预期

| 产品  | 首字节        | 单连接吞吐             |
| --- | ---------- | ----------------- |
| 住宅  | 300–800 ms | 10–50 Mbps        |
| 移动  | 500 ms–3 s | 5–20 Mbps         |
| ISP | 50–150 ms  | 100 Mbps – 1 Gbps |

看到这些数值并觉得应该更快——请重设预期。住宅就是**真实住宅**网速。

## 第 1 步：度量耗时分布

```bash
curl -w "\nDNS:%{time_namelookup}s Connect:%{time_connect}s TLS:%{time_appconnect}s TTFB:%{time_starttransfer}s Total:%{time_total}s\n" \
     -o /dev/null -s \
     --proxy http://USER:PASS@gate.helodata.io:7777 \
     https://example.com
```

字段解读：

| 字段                   | 含义                   |
| -------------------- | -------------------- |
| `time_connect`       | TCP 到**网关**          |
| `time_appconnect`    | 到**目标**的 TLS 握手（隧道内） |
| `time_starttransfer` | 目标首字节                |
| `time_total`         | 端到端                  |

时间花哪儿了：

* `time_connect` 高（>500 ms）→ 你到 `gate.helodata.io` 的网络。换区域网关（`na.gate.helodata.io`、`eu.…`、`ap.…`）。
* `time_appconnect` 高 → 目标慢，或目标离出口 IP 远。
* 握手后 `time_starttransfer` 仍高 → 目标服务器处理，非网络。

## 第 2 步：消除重复连接

复用 TCP / TLS（HTTP keep-alive、HTTP/2）省下握手成本。`requests`：

```python
s = requests.Session()                   # 持久连接
```

Node 用 undici 默认 dispatcher 会自动连接池——只要别每请求都新建 `ProxyAgent`。

## 第 3 步：检查并发是否撞墙

可能已撞到子账号并发上限：

```
HTTP/1.1 429
X-Helodata-Error-Code: concurrent-limit
```

详见 [限流](/helodata-zh/api-can-kao/rate-limits.md)。降并发或升级套餐。

## 第 4 步：换出口 IP 试试

被选中的住宅 IP 今天就是慢（毕竟是别人家宽带）。去掉 `session` 换 IP。

## 第 5 步：换产品

住宅吞吐满足不了，ISP 单 IP 吞吐高 10–50 倍，是另一种成本模型。

## 真的是**网关**慢

罕见但确实发生。先看状态页：

* <https://status.helodata.com>

状态正常但 `time_connect` 持续偏高——提交工单附 `traceroute gate.helodata.io` 输出与某条慢请求的 `X-Helodata-Request-Id`。

## 常见陷阱

* **SOCKS5 本地 DNS** — 本地解析增加延迟，请用 `socks5h://`。
* **TLS 包裹连接到网关** — 在目标自身 TLS 之上又多一次握手；仅在网络要求 TLS 出口时使用。
* **DNS 缓存冷** — `time_namelookup` >100 ms 说明本地 DNS 不缓存，配本地解析器。
* **客户端日志拖慢** — 小请求场景 verbose 日志可能主导墙钟时间。

## 正确做基准

对比代理速度要测**多请求**，不是单次：

```bash
for i in $(seq 100); do
  curl -w "%{time_total}\n" -o /dev/null -s \
       --proxy http://USER:PASS@gate.helodata.io:7777 \
       https://example.com/sitemap.xml
done | sort -n | awk 'NR==50{print "median:",$1} END{print "max:",$1}'
```

中位数 > 95 分位——后者才是反爬关心的。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helodata.com/helodata-zh/gu-zhang-pai-cha/slow-speeds.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
