Back to all posts
Schedule Proxy IP Rotation in Python

Schedule Proxy IP Rotation in Python

November 12, 2026

Why Time-Based Rotation Helps

Many scraping jobs run on predictable cycles. A nightly price check, a scheduled content export, or a batch of search queries does not need fully manual control. It needs a known cadence.

Timed rotation changes the proxy after an interval you choose. Sticky rotation keeps an IP until you rotate it or until the IP fails. For scheduled jobs, timed rotation can make the cadence explicit and reduce manual triggers.

If your workflow already runs on a timer, time-based rotation fits. You do not need to trigger each change yourself. You only need to choose a sensible interval and handle failures.

For data collection, this matters. A site may serve different content per IP. A timed rotation can spread requests across multiple IPs over a crawl. That can help you observe changes without running one IP forever.

How Timed Rotation Works

With timed rotation, the proxy changes on a schedule you control. The change can happen after a set interval. This is useful when the data source updates predictably and you want a steady refresh rhythm.

Sticky rotation is different. The IP stays with the proxy until you rotate it or until the IP fails. That can be useful for multi-step flows, but it can also leave a worker waiting for a manual rotation.

For simple scheduled jobs, timed rotation removes that waiting. The next run can use a new IP if the interval has elapsed.

When to Choose Timed Over Sticky

Choose timed rotation when:

  • The job runs on a fixed schedule.
  • Freshness matters more than IP continuity.
  • You want predictable IP changes.
  • You do not need a single IP for a login flow.

Choose sticky rotation when:

  • The workflow needs a stable IP for authentication.
  • You run multi-step browser actions.
  • You manage multiple accounts.

For a batch of independent requests, timed rotation may be simpler. For login-based scraping, sticky rotation may be better.

Timed rotation is not only for scraping. It can fit ad verification, SEO monitoring, and price intelligence.

Pick an Interval That Fits the Target

The right interval depends on the target site, your request rate, and how often the data must be fresh.

  • Too short: risk rate limits, CAPTCHAs, or blocks.
  • Too long: data may be stale.
  • Just right: the job refreshes often enough to be useful and slow enough to avoid pressure.

For a price check every five minutes, a timed rotation of five minutes may be reasonable. For an overnight SEO report, a longer interval may be better.

Document the interval. Review it after blocks or rate limits. Adjust based on observed behavior.

Build the Client Setup

When you configure RoProxy in your HTTP client, use the gateway format. The proxy handles both HTTP and HTTPS through the gateway host and HTTP port.

PROXY = 'http://USERNAME:PASSWORD@GATEWAY_HOST:HTTP_PORT'
CHECK_URL = 'https://api.ipify.org?format=json'

For SOCKS5, use the gateway host and the SOCKS5_PORT placeholder with the same credentials.

Keep the proxy value in one place. Use a secret manager in production. Set explicit timeouts so a hung connection does not block a worker.

For browser clients, set the same proxy before navigation. For command line tools, pass the proxy with the usual flags or environment variables.

Check the Exit IP

After a rotation, verify the new IP. Use the IP check endpoint.

import requests

def get_exit_ip():
    response = requests.get(
        CHECK_URL,
        proxies={'http': PROXY, 'https': PROXY},
        timeout=10,
    )
    return response.json()

current = get_exit_ip()
print(current)

If the IP changed as expected, continue. If it did not, rotate again or adjust the interval.

Compare the IP before and after the rotation. Log the result. This helps separate rotation failures from network failures.

Schedule, Retry, and Rotate

For timed rotation, set the interval in your plan. For immediate control, use the API on Pro and Business plans.

import requests

def rotate_now():
    response = requests.post(
        'https://backend-api.ro-proxy.com/api/session/SESSION_ID/rotate',
        headers={'Authorization': 'Bearer API_KEY'},
        timeout=10,
    )
    return response.status_code

The Free plan uses a fixed schedule and cannot be rotated by hand.

Build retry logic. On failure, log the status code and body. Do not blindly rotate on every error. Some errors are temporary. Some require a new IP.

Use exponential backoff. If you get a rate limit response, slow down before rotating. If you get a timeout, retry with a new proxy only when appropriate.

Align Rotation With Rate Limits

Proxy rotation and rate limiting are related. A rotation does not remove the need to respect limits.

  • Track request counts per IP.
  • Use a token bucket or similar pattern.
  • Rotate before the bucket empties if needed.

This keeps the system polite and predictable.

Practical Workflow for Scheduled Scrapes

  1. Define the refresh interval.
  2. Set the proxy rotation interval.
  3. Add timeouts and retries.
  4. Check the exit IP after rotation.
  5. Log failures and adjust.

This workflow helps you avoid stale data and runaway retries.

For a scheduled job, run the check in a small smoke test. Send one request, record the IP, then rotate. Confirm the next request uses a new IP.

Final Take

Time-based rotation can be a good fit for scheduled scraping. It gives you a predictable cadence without sticky proxy state. For on-demand changes, use the API.

For a scheduled job, RoProxy's timed rotation can align IP changes with your refresh cycle.

The goal is not rotation for its own sake. The goal is useful, fresh data. Pick a cadence you can operate. Monitor failures. Keep the pipeline simple.

Start Small

Start with a small interval. Test on a small set of URLs. Watch status codes and timing. If blocks appear, increase delay. If data is stale, decrease interval. Keep a fallback retry strategy.