Skip to content
Blog

Rotating vs Sticky Proxy Sessions: How They Work and When to Use Each

Rotating vs sticky residential proxy sessions: how each works, when to use which, session ids per worker, lifetimes, and what happens when a sticky IP drops.

Exitway team··6 min read

Rotating means a new IP for every new connection. Sticky means the same IP for the lifetime you set (1 to 1440 minutes), as long as that exit stays online. On Exitway the difference is one parameter in the proxy username:

Rotating (default) Sticky
Username USERNAME-country-us USERNAME-country-us-session-cart42-lifetime-30
IP changes On every new TCP connection When the lifetime ends, or if the exit goes offline
Best for Independent requests: listings, search results, catalogs Multi-step flows that tie state to the IP
A failed request Retry and you’re on a new IP Retry on the same IP, or restart the flow

Use rotating unless a sequence of requests has to look like one visitor. The rest of this guide covers how each mode behaves, how to assign session ids to workers, and what to do when a sticky IP disappears.

See the difference with curl

# Rotating: every new connection gets a new IP
for i in 1 2 3; do
  curl -sS -x "http://$EXITWAY_USER-country-us:$EXITWAY_PASS@gw.exitway.net:7777" https://ipinfo.io/ip; echo
done

# Sticky: same session id, same IP for up to 30 minutes
for i in 1 2 3; do
  curl -sS -x "http://$EXITWAY_USER-country-us-session-cart42-lifetime-30:$EXITWAY_PASS@gw.exitway.net:7777" https://ipinfo.io/ip; echo
done

The first loop prints three different US addresses, because each curl run is a new connection. The second prints the same address three times. If both loops fail with a 402 from the proxy (CONNECT tunnel failed, response 402 in curl 8, Received HTTP code 402 from proxy after CONNECT in older versions), your syntax is correct and the residential product is simply out of bandwidth.

Rotating: new IP per connection, not per request

The gateway picks a fresh exit whenever your client opens a new TCP connection. Keep-alive changes what that means in practice. A requests.Session, an httpx.Client, an aiohttp session and Scrapy all reuse an open tunnel for the next request to the same host, so consecutive requests can share an IP. That is usually what you want: it is faster and cheaper. When it isn’t, disable reuse in the client. The Python guide has the exact setting for each library.

Rotate when:

  • each request stands alone (product pages, search result pages, category listings, price checks);
  • you want retries to land on a different IP automatically;
  • you are spreading a large crawl so that no single IP carries much of it.

Sticky: one IP per identity

Add -session-<id> and every connection that uses that id exits from the same IP. Add -lifetime-<minutes> to set how long it is kept.

Stick when the site links state to the IP across requests:

  • logging in to your own accounts, or QA test accounts, then navigating behind the login;
  • cart and checkout flows on a store you test;
  • multi-page forms, or pagination tied to a server-side session;
  • long downloads or WebSocket connections you may need to reopen.

Sessions are private to your account. The id you choose is combined with your account before it reaches the network, so another customer using cart42 never gets your IP.

Rules for session ids and lifetimes

  • Ids are letters and digits only, 1 to 32 characters. cart42 is valid. cart_42 and cart-42 are rejected with 400 invalid_parameters.
  • Lifetime is in minutes, from 1 to 1440. Set it explicitly every time, so the behavior doesn’t depend on a default.
  • After the lifetime ends, the same id is given a new IP. Pick a lifetime a little longer than the longest flow you run, not “as long as possible”.
Use case Suggested lifetime
Checkout or form test, a few minutes -lifetime-10
Logged-in browsing session -lifetime-30 to -lifetime-60
Long-running monitor on one account -lifetime-240, and re-login on IP change

Idle tunnels are closed after a few minutes without traffic. Reconnecting with the same session id brings you back to the same IP while the lifetime lasts.

One session id per worker

The common mistake is a single hardcoded id shared by every thread, which puts all your traffic on one IP. Give each worker its own id, and prefix ids with a per-run token so a restarted job doesn’t reuse sessions from the last run:

import os
import secrets
from concurrent.futures import ThreadPoolExecutor

import requests

USER, PASS = os.environ["EXITWAY_USER"], os.environ["EXITWAY_PASS"]
RUN = secrets.token_hex(4)  # new ids on every run: no stale sessions after a restart


def sticky_session(worker_id, country="us", minutes=20):
    user = f"{USER}-country-{country}-session-{RUN}w{worker_id}-lifetime-{minutes}"
    proxy = f"http://{user}:{PASS}@gw.exitway.net:7777"
    s = requests.Session()
    s.proxies = {"http": proxy, "https": proxy}
    return s


def exit_ip(s):
    r = s.get("https://ipinfo.io/ip", timeout=(10, 30))
    r.raise_for_status()
    return r.text.strip()


def run_flow(worker_id, steps):
    s = sticky_session(worker_id)
    try:
        ip = exit_ip(s)
        for url in steps:
            s.get(url, timeout=(10, 30)).raise_for_status()
        if exit_ip(s) != ip:
            return worker_id, "IP changed mid-flow (failover): restart this flow"
        return worker_id, f"done from {ip}"
    except requests.exceptions.ProxyError as exc:
        if "402" in str(exc):
            return worker_id, "out of bandwidth: top up, then rerun"
        return worker_id, f"proxy error: {exc}"
    except requests.exceptions.RequestException as exc:
        # timeout, dropped exit, TLS error or an error status from the site:
        # this flow failed, the other workers carry on
        return worker_id, f"flow failed ({type(exc).__name__}): retry it"


STEPS = [  # your own test site
    "https://staging.example.com/login",
    "https://staging.example.com/cart",
    "https://staging.example.com/checkout",
]

with ThreadPoolExecutor(max_workers=4) as pool:
    for worker_id, result in pool.map(lambda w: run_flow(w, STEPS), range(4)):
        print(worker_id, result)

RUN is hex and the worker part is w plus a number, so every id stays within the allowed characters. The broad RequestException handler matters in practice: a residential exit that stalls raises a timeout in one worker, and without it that single timeout would crash the whole pool. In a browser, the equivalent is one sticky session per browser context; see the Playwright and Puppeteer guide.

When a sticky IP goes away

Residential exits are real devices on home connections, and some of them go offline in the middle of your session. When that happens, connections open through that exit drop. The session itself fails over: the next connection with the same id works, but from a new IP. The id is unchanged, but the site now sees a different address.

Design for it:

  • Detect it. Compare the exit IP at the start and end of a flow, as run_flow does above, or after any unexpected logout.
  • Restart the unit of work, not the job. Redo the flow from its first step on the new IP.
  • Keep flows short. A 3-minute checkout test rarely sees a failover. A 6-hour session on one IP sometimes will.

Rotating requests are immune to this by design: every connection is a fresh pick anyway, and a 502 from the gateway is a signal to retry.

Node.js: use request() to see proxy errors

With undici, fetch() reports a refused tunnel only as fetch failed. Its lower-level request() keeps the status. The snippet works with undici 8 on Node.js 22.19 or later; on Node.js 20, install undici@7, the code is the same:

import { ProxyAgent, request } from "undici";
import { randomBytes } from "node:crypto";

const { EXITWAY_USER, EXITWAY_PASS } = process.env;
const run = randomBytes(4).toString("hex");

function stickyAgent(workerId, country = "us", minutes = 20) {
  const user = `${EXITWAY_USER}-country-${country}-session-${run}w${workerId}-lifetime-${minutes}`;
  return new ProxyAgent(`http://${user}:${EXITWAY_PASS}@gw.exitway.net:7777`);
}

const agent = stickyAgent(1);
try {
  const { statusCode, body } = await request("https://ipinfo.io/ip", { dispatcher: agent });
  console.log(statusCode, (await body.text()).trim());
} catch (err) {
  // undici's fetch() hides this detail ("fetch failed"); request() keeps it:
  // "Proxy response (402) !== 200 when HTTP Tunneling"
  console.error(err.message);
} finally {
  await agent.close();
}

One ProxyAgent per worker gives each worker its own sticky IP.

The IP is only part of the identity

A sticky IP keeps the network side consistent. Cookies, headers and the browser fingerprint have to stay consistent too, or the site still sees a different visitor on each request. Browser fingerprinting for scrapers covers that side. Use sticky sessions on accounts you own or are authorized to test, and within our Acceptable Use Policy.

Rotating and sticky sessions cost the same: residential from $0.70/GB, and you only pay for bandwidth. Create an account or see the docs for every parameter.

More guides