01How each one works
Rotating is what you get with no session in the username: each new connection to the gateway is given a different IP.
Sticky starts when you add -session- and a name. Every connection with that name, and the same targeting, gets the same IP until its lifetime runs out. -lifetime- sets that in minutes, up to 24 hours.
# Rotating: three requests, three IPs
USERNAME-country-us
# Sticky: three requests, one IP, held 30 minutes
USERNAME-country-us-session-basket7-lifetime-3002Which one to use
| Job | Use | Why |
|---|---|---|
| Crawling many separate pages | Rotating | Spreads the load; no IP stands out |
| Paging through one search | Sticky | A real visitor does not change IP between pages |
| Logging in, checkout, forms | Sticky | Sessions and cookies are often tied to the IP |
| Headless browser visits | Sticky | One page loads dozens of files; they should share an IP |
| Retrying a failed request | Rotating | A new IP may succeed where the last one did not |
03Common mistakes
- Expecting rotation inside a kept-alive connection. HTTP clients reuse connections, and a reused connection keeps its IP. If every request must rotate, turn keep-alive off or give each request its own session name.
- One session name for every worker. All workers then share one IP. Give each worker, or each task, its own name.
- Assuming sticky means forever. A residential IP is someone’s home line and can drop before 24 hours. Your next request then gets a new IP under the same name. Check, and restart a flow if the IP changed in the middle.
- Dashes in session names. A dash starts a new flag. Use letters, digits and underscores.