跳到正文

动态住宅代理并发数、线程数:怎么设才合适

先按目标请求速率算出线程数,再一步步加,边加边看报错。

并发数、线程数限制是什么意思

并发连接(线程)限制,是指套餐允许你同时保持打开的连接数。比如套餐允许 50,你开 80 个,多出来的连接会被拒绝或排队,具体看各家。它限制的是「同一时刻」,不是你总共能用多少 GB 或多少请求。

各家在套餐页里的叫法不一样(线程、会话、同时连接),比较时要看原话,别只看数字。

按目标速率算并发

按目标速率算并发
项目每分钟请求数单次平均耗时在途连接数
轻量检查601 秒60 ÷ 60 × 1 = 1
稳定采集6002 秒600 ÷ 60 × 2 = 20
目标响应慢6005 秒600 ÷ 60 × 5 = 50
高频率3,0002 秒3,000 ÷ 60 × 2 = 100

在途连接数 = 每秒请求数 × 单次请求平均秒数。数字只是算式示例,耗时请用你自己走代理的实测值,并为重试留一点余量。

Python:通过代理跑线程池

import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from urllib.parse import quote

import requests

user = quote("USERNAME", safe="")
password = quote("PASSWORD", safe="")
proxy = f"http://{user}:{password}@proxy.proxy302.com:2222"
proxies = {"http": proxy, "https": proxy}

WORKERS = 20   # start from your calculation, not from the maximum

def fetch(url):
    started = time.monotonic()
    r = requests.get(url, proxies=proxies, timeout=(5, 20))
    return r.status_code, time.monotonic() - started

urls = ["https://example.com/"] * 200   # replace with your own URLs

with ThreadPoolExecutor(max_workers=WORKERS) as pool:
    futures = [pool.submit(fetch, u) for u in urls]
    for f in as_completed(futures):
        try:
            status, seconds = f.result()
        except requests.RequestException as exc:
            print("error", type(exc).__name__)
        else:
            print(status, round(seconds, 2))

仅为示例。USERNAME、PASSWORD 换成「我的资产」里的值。ThreadPoolExecutor(max_workers=N) 最多同时跑 N 个调用。每次 requests.get 都会新建连接,所以在轮换设置下,新连接可能对应新 IP。

Node.js 和其他语言

思路在 Node.js 里一样:固定在途请求数,一个结束再发下一个。Node.js 的代理设置(含 HTTP 和 SOCKS5)见 Node.js 代理指南。

不管用什么语言,都要在代码里给在途请求设硬上限,不要一次全部发出。

怎么安全地加并发

  1. 第 1 步

    从表里算出的数开始,不要直接用最大值。先发几百个请求,记录状态码和耗时。

  2. 第 2 步

    线程数翻倍再测一轮。一旦超时、HTTP 429 或 403 开始增多就别再加:这是目标网站在告诉你它的上限。

  3. 第 3 步

    遇到 429 和 5xx 要退避,网站返回 Retry-After 头就照它等,并遵守网站条款和频率限制。线程再多,也不会让网站允许更多请求。

Proxy302 的并发

Proxy302 动态住宅线路不设并发连接上限,2026 年 11 月 11 日的测试里,同时打开 100 个连接都正常。这只说明没有上限,不是速度承诺。

两点实用提示。并发越高,GB 消耗越快,因为不管多少线程都按 GB 计费。另外不开会话时,每个新连接换一个新 IP,开很多连接的线程池就会用到很多 IP;复用的(keep-alive)连接保持原来的 IP。

常见问题

我需要多少并发连接?

每秒请求数乘以单次请求平均秒数。每秒 10 个请求、每个 2 秒,大约 20 个。

Proxy302 动态住宅代理限制并发连接吗?

住宅线路没有设上限。我们测试过同时打开 100 个连接,都正常。这不是速度承诺。

加线程后为什么出现 429?

目标网站在限制你的请求频率。降低线程数、加延迟或退避,并看网站的规则。

并发越高越贵吗?

每 GB 价格不变,但同样时间发出的请求更多,GB 用得更快。

参考资料

3
  1. Proxy302 product facts and price list

    产品观察 · 确认日期:

    Product facts file of the site, checked 10 November 2026 against the console, the backend and the price table: rotating residential Budget and Premium per-GB prices and packages (1 PTC = US$1), no expiry of purchased traffic, protocols and ports, no free trial.

  2. Python documentation: concurrent.futures

    官方文档 · 确认日期:

    Read on 12 November 2026: ThreadPoolExecutor runs calls on a pool of at most max_workers threads; the default is min(32, os.cpu_count() + 4) since Python 3.8; as_completed yields futures as they finish; thread pools are meant to overlap I/O.

  3. Proxy302 concurrency test

    产品观察 · 确认日期:

    Test of 11 November 2026 on rotating residential: 100 connections open at the same time, all of them worked. No concurrent-connection cap is set on the residential lines. This says nothing about speed.

准备好试试了吗?

注册账号、充值一次,就能选动态住宅、静态 ISP 或数据中心 IP,几分钟配进你的浏览器。