<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[ProxyVerge]]></title><description><![CDATA[ProxyVerge]]></description><link>https://proxyverge.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sun, 29 Nov 2026 22:40:28 GMT</lastBuildDate><atom:link href="https://proxyverge.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Sticky vs. Per-Request Rotating Proxies in Python, Node.js, and Playwright: A Practical Field Guide]]></title><description><![CDATA[How session binding works under the hood, plus production snippets for requests, httpx, undici, and Playwright.]]></description><link>https://proxyverge.hashnode.dev/sticky-vs-per-request-rotating-proxies-in-python-node-js-and-playwright-a-practical-field-guide</link><guid isPermaLink="true">https://proxyverge.hashnode.dev/sticky-vs-per-request-rotating-proxies-in-python-node-js-and-playwright-a-practical-field-guide</guid><category><![CDATA[web scraping]]></category><category><![CDATA[Python]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[playwright]]></category><dc:creator><![CDATA[Oleg Vasilov]]></dc:creator><pubDate>Sat, 28 Nov 2026 09:23:45 GMT</pubDate><content:encoded><![CDATA[<p>Most scraper failures blamed on "bad IPs" are actually session-lifecycle bugs: rotating an exit IP mid-checkout, reusing a sticky token past its TTL, or leaking connection pools across workers.</p>
<p>In this guide, we'll break down the practical mechanics of <strong>per-request rotating</strong>, <strong>sticky TTL</strong>, and <strong>static ISP</strong> routing—along with copy-paste code for Python (<code>requests</code> &amp; <code>httpx</code>), Node.js (<code>undici</code>), and Playwright.</p>
<hr />
<h2>1. Choosing the Right Session Mode</h2>
<p>Before writing any proxy wrapper, match the session lifetime to the target workflow:</p>
<table>
<thead>
<tr>
<th>Workload</th>
<th>Best Session Mode</th>
<th>Why</th>
<th>Typical Failure If Misconfigured</th>
</tr>
</thead>
<tbody><tr>
<td>Public SERP, product catalog pages, sitemaps</td>
<td><strong>Per-request rotation</strong></td>
<td>Every HTTP request (or TLS handshake) exits via a fresh IP, distributing rate limits horizontally.</td>
<td>Over-using sticky IPs triggers per-IP rate limits (<code>429</code>) quickly.</td>
</tr>
<tr>
<td>Pagination with stateful cursors, search filters, CSRF tokens</td>
<td><strong>Short sticky session (5–20 min)</strong></td>
<td>Preserves IP affinity long enough for multi-step fetches without exhausting a single exit node.</td>
<td>Rotating mid-pagination invalidates signed cursor/CSRF tokens (<code>403</code>/<code>419</code>).</td>
</tr>
<tr>
<td>Authenticated dashboards, cart flows, browser sessions</td>
<td><strong>Long sticky session (15–1440 min) or Static ISP</strong></td>
<td>Matches real user session lifetimes; keeps cookie jar + TLS fingerprint + IP aligned.</td>
<td>Mid-flow IP flips trigger security re-challenges or instant session logout.</td>
</tr>
<tr>
<td>Long-lived headless workers, high-concurrency VM fleets</td>
<td><strong>Static ISP (IP Whitelist)</strong></td>
<td>Unlimited bandwidth, dedicated IPv4s, zero <code>user:pass</code> header overhead on every CONNECT tunnel.</td>
<td>Paying per-GB for heavy media/asset loads in browser farms destroys unit economics.</td>
</tr>
</tbody></table>
<blockquote>
<p><strong>Rule of thumb:</strong> If your target validates session cookies against client IP (<code>X-Forwarded-For</code> / remote peer), <strong>never</strong> use per-request rotation. Bind one sticky session ID per worker/account and isolate cookies in its own client or <code>BrowserContext</code>.</p>
</blockquote>
<hr />
<h2>2. Configuring Proxy Routing Without Proprietary SDKs</h2>
<p>Instead of pulling in heavy third-party proxy SDKs, generate standard HTTP or SOCKS5 endpoints in the dashboard Proxy Builder and inject them via environment variables (<code>PV_STICKY_PROXY_URL</code>, <code>PV_ROTATING_PROXY_URL</code>, <code>PV_RESI_PROXY_URL</code>).</p>
<p>On <strong>ProxyVerge</strong>, there are three gateway layers depending on your workload:</p>
<ol>
<li><strong><code>gate.proxyverge.com</code></strong> (Unified <strong>Proxy Trio</strong> pool — Residential, Mobile, and Datacenter from a single GB balance):<ul>
<li><strong>Ports:</strong> HTTP <code>:10080</code>, SOCKS5 <code>:10800</code> (with optional UDP over SOCKS5 on Residential and Mobile pools, toggled in the Proxy Builder).</li>
<li><strong>Proxy Builder options:</strong> Pool type (<code>Residential</code> / <code>Mobile</code> / <code>Datacenter</code>), Country + State <strong>or</strong> City (mutually exclusive), or ASN (Residential &amp; Mobile only), optional Session ID, and rotation mode: <strong>Per-Request</strong>, <strong>Sticky until exit drops</strong>, or <strong>5 / 10 / 15 / 20 / 60 min</strong> sticky presets.</li>
<li><strong>Output formats:</strong> Copy ready-to-use <code>http://...</code>, <code>socks5://...</code>, <code>host:port:user:pass</code>, or <code>cURL</code> strings straight from <code>/account</code>.</li>
</ul>
</li>
<li><strong><code>resi.proxyverge.com:5555</code></strong> (<strong>Residential Pro</strong> — 190+ countries, HTTP &amp; SOCKS5) &amp; <strong><code>mobile.proxyverge.com</code></strong> (<strong>Mobile 4G/5G Pro</strong> — 155 countries, HTTP &amp; SOCKS5, host/port generated in the Proxy Builder):<ul>
<li>Both support per-request rotation or configurable sticky sessions with <strong>TTL from 1 to 1440 minutes (24 hours)</strong>.</li>
<li>Residential Pro supports country, region/state, city, or ASN targeting (ASN and region/city are mutually exclusive).</li>
<li>Mobile 4G/5G Pro supports country + carrier ASN targeting.</li>
<li>Exact formatted credentials (<code>host:port:user:pass</code>, <code>user:pass@host:port</code>, <code>http://</code>, <code>socks5://</code>, <code>cURL</code>, and <code>JSON</code>) are exported directly from the dashboard Proxy Builder.</li>
</ul>
</li>
</ol>
<blockquote>
<p><strong>Tip — normalize raw proxy lists locally:</strong> Before exporting credentials into env vars or Playwright configs, use our free browser-local <strong><a href="https://proxyverge.com/tools/proxy-converter?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">ProxyVerge Proxy Format Converter</a></strong> to convert <code>host:port:user:pass</code>, <code>user:pass@host:port</code>, HTTP/SOCKS5 URIs, cURL, Python (<code>requests</code>/<code>httpx</code>), Node.js (<code>undici</code>), and Playwright JSON (runs 100% client-side in your browser—credentials never touch a server).</p>
</blockquote>
<hr />
<h2>3. Production Code Examples</h2>
<h3>A. Python (<code>requests</code>) — Per-Request vs. Sticky Session Isolation</h3>
<p>When using <code>requests.Session()</code>, remember that <strong>connection pooling (<code>urllib3</code>) reuses open TCP tunnels</strong>. For sticky scraping, keep one <code>requests.Session()</code> per worker bound to a sticky Proxy Builder URL; for per-request rotation, export a Per-Request URL from the Proxy Builder and send <code>Connection: close</code> (or avoid pooling) so every call opens a fresh tunnel.</p>
<pre><code class="language-python">import os
import requests

# Export complete URLs generated by the ProxyVerge Proxy Builder:
# - PV_STICKY_PROXY_URL: e.g. http://USER:PASS@gate.proxyverge.com:10080 (sticky preset + session ID)
# - PV_ROTATING_PROXY_URL: e.g. http://USER:PASS@gate.proxyverge.com:10080 (Per-Request mode)
STICKY_PROXY_URL = os.environ["PV_STICKY_PROXY_URL"]
ROTATING_PROXY_URL = os.environ["PV_ROTATING_PROXY_URL"]

# 1) Sticky session: same exit IP across multi-step login / CSRF requests
with requests.Session() as s:
    s.proxies.update({"http": STICKY_PROXY_URL, "https": STICKY_PROXY_URL})
    r1 = s.get("https://api.ipify.org?format=json", timeout=20)
    r2 = s.get("https://api.ipify.org?format=json", timeout=20)
    print("Sticky IP 1:", r1.json(), "Sticky IP 2:", r2.json())

# 2) Per-request rotation: close the tunnel after each call
r3 = requests.get(
    "https://api.ipify.org?format=json",
    proxies={"http": ROTATING_PROXY_URL, "https": ROTATING_PROXY_URL},
    headers={"Connection": "close"},
    timeout=20,
)
print("Rotated IP:", r3.json())
</code></pre>
<h3>B. Python (<code>httpx</code> Async) — High-Concurrency Residential Pro Worker</h3>
<p>For async pipelines (<code>httpx &gt;= 0.28</code>, use <code>proxy=</code>; on older <code>&lt;0.28</code> use <code>proxies=</code>), instantiate one <code>httpx.AsyncClient</code> per sticky worker using the URL exported from <code>resi.proxyverge.com:5555</code> or <code>mobile.proxyverge.com</code> (via Proxy Builder):</p>
<pre><code class="language-python">import asyncio
import os
import httpx

# Generated in ProxyVerge Proxy Builder (e.g. Residential Pro on resi.proxyverge.com:5555)
RESI_PROXY_URL = os.environ["PV_RESI_PROXY_URL"]
# Example shape: "http://USERNAME:PASSWORD@resi.proxyverge.com:5555"

async def fetch_target(worker_id: int, url: str) -&gt; dict:
    async with httpx.AsyncClient(proxy=RESI_PROXY_URL, timeout=20.0) as client:
        resp = await client.get(url)
        resp.raise_for_status()
        return {"worker": worker_id, "ip": resp.json()}

async def main():
    results = await asyncio.gather(
        fetch_target(1, "https://api.ipify.org?format=json"),
        fetch_target(2, "https://api.ipify.org?format=json"),
    )
    print(results)

asyncio.run(main())
</code></pre>
<h3>C. Node.js (<code>undici</code>) — Explicit <code>ProxyAgent</code> per Worker</h3>
<p>Node's built-in <code>fetch</code> does not read <code>HTTP_PROXY</code> automatically. Using <code>undici</code>'s <code>ProxyAgent</code> gives you strict isolation and zero global env surprises:</p>
<pre><code class="language-js">import { ProxyAgent, fetch } from 'undici';

// Complete URL exported from the ProxyVerge Proxy Builder (e.g. gate.proxyverge.com:10080 or resi.proxyverge.com:5555)
const proxyUrl = process.env.PV_STICKY_PROXY_URL || 'http://USER:PASS@gate.proxyverge.com:10080';

const dispatcher = new ProxyAgent({
  uri: proxyUrl,
  // Keep keep-alive conservative when targeting rotating exits
  keepAliveTimeout: 5_000,
});

try {
  const res = await fetch('https://api.ipify.org?format=json', {
    dispatcher,
    signal: AbortSignal.timeout(20_000),
  });
  console.log(await res.json());
} finally {
  await dispatcher.close();
}
</code></pre>
<h3>D. Playwright (Chromium) — Per-Context Sticky Isolation</h3>
<p>If you launch multiple scraping jobs inside one Chromium process, passing proxy credentials only to <code>chromium.launch()</code> forces all contexts through one exit. In Chromium, pass a placeholder server at launch so each <code>newContext()</code> can bind its own sticky Proxy Builder credentials and cookie jar:</p>
<pre><code class="language-js">import { chromium } from 'playwright';

const browser = await chromium.launch({
  headless: true,
  // Required in Chromium to allow distinct proxy settings per BrowserContext
  proxy: { server: 'http://per-context' },
});

async function runWorker(workerLabel, username, password) {
  const context = await browser.newContext({
    proxy: {
      server: 'http://gate.proxyverge.com:10080',
      username, // Sticky credential generated for this worker in the Proxy Builder
      password,
    },
  });
  const page = await context.newPage();
  await page.goto('https://api.ipify.org?format=json', { waitUntil: 'domcontentloaded', timeout: 25_000 });
  const text = await page.textContent('body');
  await context.close();
  return { workerLabel, body: text };
}

try {
  const out = await Promise.all([
    runWorker('ctx_1', process.env.PV_STICKY_USER_1, process.env.PV_STICKY_PASS_1),
    runWorker('ctx_2', process.env.PV_STICKY_USER_2, process.env.PV_STICKY_PASS_2),
  ]);
  console.log(out);
} finally {
  await browser.close();
}
</code></pre>
<hr />
<h2>4. Troubleshooting Checklist When Exit IPs Behave Unexpectedly</h2>
<ol>
<li><strong>Both state and city selected together:</strong> The Proxy Builder treats state/region and city targeting as mutually exclusive—pick one level of granularity (or switch to ASN targeting without state/city).</li>
<li><strong>Keep-alive masking per-request rotation:</strong> When using per-request rotation mode, persistent HTTP/1.1 keep-alive tunnels keep routing over the already-opened TCP socket. Set <code>Connection: close</code> or close/recreate pooled connections whenever every single HTTP request must switch exit IP.</li>
<li><strong>Browser media eating GBs:</strong> Headless browsers pull fonts, images, and analytics beacons unless blocked (<code>page.route('**/*.{png,jpg,woff2}', route =&gt; route.abort())</code>) or shifted onto unlimited-bandwidth <strong><a href="https://proxyverge.com/proxies/static-isp?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">Static ISP</a></strong> IPs.</li>
<li><strong>Cloud VM auth friction:</strong> If your scrapers run from fixed <strong><a href="https://proxyverge.com/servers/vps-vds?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">VPS/VDS</a></strong> hosts, switching Static ISP proxies from <code>user:pass</code> to <strong>IP Whitelist</strong> eliminates Chromium proxy auth prompts and simplifies container configs.</li>
</ol>
<hr />
<h2>5. Transparent Pricing Snapshot (If You Need a Unified Sandbox + Production Pool)</h2>
<p>All pools on <strong><a href="https://proxyverge.com/?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">ProxyVerge</a></strong> share one USD wallet balance with crypto checkout (NOWPayments) and instant dashboard builders:</p>
<ul>
<li><strong><a href="https://proxyverge.com/proxies/residential?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">Residential Pro</a> (<code>resi.proxyverge.com:5555</code>):</strong> <strong>$1.40 / GB</strong> (non-expiring, starts at <strong>5 GB = $7.00</strong>, 190+ countries, country/region/city or ASN, sticky TTL 1–1440 min).</li>
<li><strong>Proxy Trio (<code>gate.proxyverge.com</code>):</strong> <strong>$1.30 / GB</strong> (30-day) or <strong>$1.95 / GB</strong> (non-expiring), starts at <strong>19 GB</strong> — shared pool across Residential (148 countries), Mobile (150 countries), and Datacenter (71 countries), HTTP <code>:10080</code> &amp; SOCKS5 <code>:10800</code> (+ optional UDP).</li>
<li><strong><a href="https://proxyverge.com/proxies/mobile?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">Mobile 4G/5G Pro</a> (<code>mobile.proxyverge.com</code>):</strong> <strong>$2.35 / GB</strong> (non-expiring, starts at <strong>5 GB = $11.75</strong>, 155 countries, carrier ASN targeting, host/port in Proxy Builder).</li>
<li><strong><a href="https://proxyverge.com/proxies/static-isp?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">Premium Static ISP</a>:</strong> <strong>$1.79 / IP</strong> (min 5 IPs = <strong>$8.95</strong>; AT&amp;T <strong>$2.75 / IP</strong>), unlimited bandwidth, instant <strong>HTTP / SOCKS5 / IP Whitelist (up to 20 IPs)</strong> switching.</li>
<li><strong><a href="https://proxyverge.com/servers/vps-vds?utm_source=hashnode&amp;utm_medium=article&amp;utm_campaign=scraping_guide">Co-located Virginia Compute</a>:</strong> <strong>AMD EPYC DDR5 NVMe VPS</strong> from <strong>$32.90/mo</strong> (4 vCPU / 8 GB; Ubuntu 24.04 / Debian 11 / Windows Server 2019 at checkout + power controls) and <strong>100 Gbps VDS</strong> from <strong>$169.00/mo</strong> (with self-service OS reinstall) on the same wallet balance.</li>
</ul>
<p>Happy scraping—and always isolate sticky sessions per cookie jar!</p>
]]></content:encoded></item></channel></rss>