> For the complete documentation index, see [llms.txt](https://docs.ipwo.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipwo.net/kai-fa-zhe-wen-dang/api-shi-yong-zhi-nan/qing-qiu-zui-jia-shi-jian.md).

# 请求最佳实践

为了提高代理使用稳定性、降低失败率，并提升业务成功率（如数据采集、账号登录、API 调用等），建议在开发过程中遵循以下最佳实践。

***

### 一、合理控制请求频率

避免短时间内发送大量请求。

建议：

* 控制并发数量
* 增加请求间隔
* 使用队列或任务调度

示例：

```
单线程循环请求优于高频并发爆发
```

***

### 二、合理使用 Session

在需要保持登录状态或固定 IP 的场景中，必须使用 Session。

推荐：

* 一个账号 = 一个 Session
* 一个 Session = 一个 IP
* 不要频繁更换 Session ID

***

错误示例：

```
每次请求都生成新的 Session ❌
```

正确示例：

```
user_1001_session_tiktok → 固定使用 ✔
```

***

### 三、避免频繁切换国家地区

频繁切换国家 IP 容易触发风控或导致登录异常。

建议：

* 一个业务固定一个国家
* 不要在短时间内跨国家切换
* 多账号使用不同国家时隔离 Session

***

### 四、合理设置超时时间

建议在代码中设置合理 timeout：

* 推荐：10–30 秒
* 不建议：低于 5 秒

示例（Python）：

```
timeout=15
```

***

### 五、使用稳定的重试机制

网络请求可能会失败，建议增加重试逻辑：

* 最多重试 2–3 次
* 每次间隔逐渐增加（退避策略）

示例：

```
第1次失败 → 等待1秒
第2次失败 → 等待3秒
第3次失败 → 放弃或记录日志
```

***

### 六、避免高并发冲击代理

虽然代理支持高并发，但建议逐步增加负载。

建议：

* 从低并发开始测试
* 逐步提升请求量
* 监控成功率

***

### 七、合理选择国家地区

根据业务目标选择 IP：

| 场景                                                        | 推荐国家         |
| --------------------------------------------------------- | ------------ |
| [TikTok](/ying-yong-chang-jing/tiktok-yun-ying.md)        | US / JP / UK |
| [Facebook](/ying-yong-chang-jing/facebook-guang-gao.md)   | US / UK      |
| [Amazon](/ying-yong-chang-jing/amazon-dian-pu-guan-li.md) | US / DE      |
| [SEO](/ying-yong-chang-jing/seo-jian-kong.md)             | US / 全球      |
| [数据采集](/ying-yong-chang-jing/shu-ju-cai-ji.md)            | US / 多国家轮换   |

***

### 八、避免指纹与 IP 不一致

在浏览器或自动化环境中：

* IP 国家
* 浏览器语言
* 时区
* UA 信息

尽量保持一致，避免异常风控。

***

### 九、日志与错误记录

建议记录：

* 请求时间
* 代理 IP
* 返回状态码
* 错误信息

用于快速定位问题。

***

### 十、推荐基础请求流程

```
1. 获取代理信息
↓
2. 设置 Session（如需要）
↓
3. 发起请求
↓
4. 检查 IP 是否正确
↓
5. 记录日志
↓
6. 失败重试
```

***

### 十一、常见错误避免

❌ 高频切换 IP\
❌ 不使用 Session 做登录业务\
❌ 并发过高未控制\
❌ timeout 设置过低\
❌ 未做重试机制

***

### 十二、相关文章

* [Session 使用说明](/kai-fa-zhe-wen-dang/api-shi-yong-zhi-nan/session-shi-yong-shuo-ming.md)
* [国家地区参数说明](/kai-fa-zhe-wen-dang/api-shi-yong-zhi-nan/guo-jia-di-qu-can-shu-shuo-ming.md)
* [如何检测代理是否生效](/dai-li-jian-ce-yu-yin-si-an-quan/ru-he-jian-ce-dai-li-shi-fou-sheng-xiao.md)
* [代理连接失败](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/dai-li-lian-jie-shi-bai.md)
* [407 Proxy Authentication Required](/kai-fa-zhe-wen-dang/chang-jian-cuo-wu/407-proxy-authentication-required.md)
* [如何降低封禁风险](/dai-li-ji-chu-zhi-shi/ru-he-jiang-di-feng-jin-feng-xian.md)
* [API 调用与批量采集](/dai-li-ji-chu-zhi-shi/api-diao-yong-yu-pi-liang-cai-ji.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ipwo.net/kai-fa-zhe-wen-dang/api-shi-yong-zhi-nan/qing-qiu-zui-jia-shi-jian.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
