A sticky session is a proxy setting that keeps routing your requests through the same exit IP address for a set period or until you change the session ID, instead of assigning a new IP on every request. That continuity lets multi-step tasks such as logins, carts, and checkouts run without the site seeing your IP change mid-session.
On some gateways, you can set the sticky session duration, in some cases up to 24 hours, and the session expires when that time runs out.
The term has a second meaning on the server side. AWS describes a sticky session, also called session affinity, as a load balancer feature that binds a user's session to one backend instance. Both meanings keep one client tied to one thing: a proxy keeps your exit IP fixed, and a load balancer keeps you on one server.
How Sticky Sessions Work
Some rotating-proxy gateways create a sticky session from a session ID you add to the proxy username:
- Pick a session ID: you add it to the username, along with any session length the gateway supports.
- Reuse it: requests that carry the same session ID leave through the same exit IP.
- Let it expire or replace it: the IP stays assigned until the session length runs out. On some networks, it also ends if the session is idle.
- Change the ID for a new IP: a new session ID forces a new IP, so you can run several sticky sessions in parallel, each on its own IP.
Proxy vs. Load Balancer Sticky Sessions
| Proxy sticky session | Load balancer sticky session | |
|---|---|---|
| What stays fixed | Your exit IP | The backend server handling you |
| Who sets it up | You, through the proxy username | The website's operator |
| How it's tracked | A session ID | A cookie, such as AWS's AWSALB, or a hash of your IP |
| Why it's used | Keep logins and carts from seeing an IP change | Send all of a user's requests to the same server |
A sticky session falls between the two other options: a rotating proxy changes the IP freely, and a static proxy never changes it.
Websites Use Sticky Sessions Too
Many sites run their own stickiness behind a load balancer, and a scraper can break it without noticing:
- Cookie-based: AWS's troubleshooting guide says that if the client fails to include the
AWSALBcookie, stickiness doesn't work. A scraper that drops cookies between requests can land on a different server each time. - IP-based: with NGINX's IP hash method, a hash of the client IP picks the server, so the same client keeps reaching the same server. Rotating your IP mid-flow can move you to another server.
If the site keeps session data on one server, the next server may not have your cart or login state. Keeping both the exit IP and the session cookie steady for the whole task avoids this.
Limitations of Sticky Sessions
- A target that rate-limits by IP can answer with
429 Too Many Requestsonce one IP sends too many requests in a given time. - If the IP goes offline before the session ends, some gateways swap in a new IP automatically. That can break a task halfway, so build in retries.
- When the session window closes, the IP changes, which can interrupt work still in progress.
What It Means for Web Scraping
- Match the session to the task: choose a session length that covers the whole flow, such as login through checkout.
- One session ID per worker: give each parallel worker its own ID, so their requests and cookies don't mix on one IP.
- Keep a cookie jar per session: store the cookies each session receives and send them back on every request in that session.