Skip to content
Alienproxies.com

Language

LoginRegister
Alienproxies.com
All posts
sessionsrotatingstickyscraping

Rotating vs Sticky Sessions: When to Use Each

Alienproxies.com Team · · 3 min read

One of the most common questions from new proxy users: should I use rotating or sticky sessions? The short answer — it depends on what the target site tracks. Here's the breakdown.

Rotating Sessions (Default)

In rotating mode, every HTTP request gets a fresh IP from the pool. There's no session continuity at all.

# Each curl call gets a different IP
curl -x "http://user:[email protected]:7777" https://httpbin.org/ip
curl -x "http://user:[email protected]:7777" https://httpbin.org/ip

When to use it:

  • Fetching product listings, prices, or public data
  • Search engine scraping (Google, Bing, DuckDuckGo)
  • Ad verification across geos
  • Any single-page GET request where you don't need continuity

Why it works: Most targets rate-limit by IP. With a new IP per request, you spread load across the pool and never trigger IP-level rate limits.

Sticky Sessions

A sticky session pins your requests to the same IP for a set duration (1–60 minutes). You set a session ID and TTL in the username.

# All requests with session-abc123 hit the same IP for 10 minutes
curl -x "http://user-session-abc123-sesstime-10:[email protected]:7777" \
  https://example.com/login

curl -x "http://user-session-abc123-sesstime-10:[email protected]:7777" \
  https://example.com/dashboard

In Python:

import requests, uuid

session_id = uuid.uuid4().hex[:8]
proxy_username = f"user-country-us-session-{session_id}-sesstime-30"

proxies = {
    "http":  f"http://{proxy_username}:[email protected]:7777",
    "https": f"http://{proxy_username}:[email protected]:7777",
}

s = requests.Session()
s.proxies = proxies

# Login — sets a session cookie tied to this IP
s.post("https://target.com/login", data={"user": "...", "pass": "..."})

# Follow-up requests on the same IP — cookies remain valid
s.get("https://target.com/account/orders")

When to use it:

  • Multi-step flows: login → navigate → scrape
  • Shopping cart operations
  • Form submissions that set cookies
  • Any site that validates IP consistency across a session

TTL guidelines:

Use case Suggested TTL
Login + 1-2 page scrape 5 min
Multi-step checkout simulation 10–15 min
Long account scrape 30 min
Extended session (careful with blocks) 60 min

Choosing the Right Session ID

Your session ID can be any alphanumeric string under 32 characters. Use something that makes sense for your workload:

# One sticky session per target account
session_id = hashlib.md5(account_email.encode()).hexdigest()[:10]

# One per scraping worker
session_id = f"worker{worker_index}"

# Random per run
session_id = uuid.uuid4().hex[:8]

The gateway routes requests with the same session ID to the same exit node until the TTL expires or the IP becomes unavailable (in which case it assigns a new one transparently).

Common Mistakes

Using sticky sessions everywhere. If you're scraping thousands of product pages with no login flow, rotating is faster and spreads load better. Sticky sessions hold IPs that could be used by other requests.

TTL too short. A 1-minute TTL on a 3-minute checkout flow will cause a mid-session IP rotation. Add a 50% buffer to your expected flow duration.

Hardcoded session IDs. If you run workers in parallel with the same session ID, they'll collide on the same IP and saturate it. Generate unique IDs per worker or per request flow.

Summary

Rotating Sticky
IP per request New each time Same for TTL
Best for Public data, search scraping Login flows, cart, session-aware sites
Config No extra params -session-ID-sesstime-N
GB efficiency Highest Same cost per GB

Pick rotating by default. Switch to sticky only when the target site tracks IP consistency.