Proxy speed and perfomance

Latency Testing

How to test the latency and success rate of your proxies.

This guide explains how to test the latency and success rate of your proxies using Python.
You’ll learn how to measure proxy performance, analyze results, and visualize latency data.


Overview

The provided script uses Python’s requests library to send concurrent requests and measure performance metrics like:

  • Latency (response time)
  • Success rate (status code analysis)
  • Error types (timeouts, connection issues)

It supports both SOCKS5 and HTTPS proxies and uses ip-api.com as the default target URL.
You can also test alternative endpoints like Cloudflare trace for comparison.


What You’ll Learn

  • How to run latency tests on multiple proxies.
  • How to configure proxy protocols (SOCKS5 or HTTP).
  • How to analyze average latency, median response time, and success rates.
  • How to interpret graphical results to detect issues.

Default Settings

ParameterDefault ValueDescription
ProtocolHTTPSSet use_socks5 = True for SOCKS5 proxies
Targetip-api.comDefault endpoint for IP tests
Concurrency5–10 threadsRecommended thread range
Testing Volume2000+ requestsRecommended for stable averages

Variable Settings

The script allows you to adjust several key variables:

  • Target Country – optional (leave blank to use random pool)
  • Protocol – choose between HTTP/HTTPS or SOCKS5
  • Session Type – rotating (default)
  • Target URL – endpoint to test (default: ip-api.com)
  • Number of Requests – define test size
  • Threads – set concurrent workers (recommended: 5–10)

Note

Results may vary depending on which gateway you use. Geonode currently provides three gateway locations.


Port Ranges

Session TypeProtocolPort RangeDescription
RotatingHTTP/HTTPS9000–9010Changes IP for every request
RotatingSOCKS511000–11010Changes IP for every request
StickyHTTP/HTTPS10000–10900Keeps same IP for session duration
StickySOCKS512000–12010Keeps same IP for session duration

Steps to Test Proxy Latency

Step 1: Install Required Libraries

Install dependencies before running the script:

pip install requests matplotlib numpy

Libraries used

  • requests — send HTTP requests
  • matplotlib — visualize latency results
  • numpy — calculate average and median latency
  • collections — count occurrences of errors

Step 2: Configure Proxy Settings

You can test SOCKS5 or HTTP(S) proxies by adjusting the use_socks5 flag.

SOCKS5 Proxy Example

use_socks5 = True

proxies = {
    'http': 'socks5://username:password@proxy.geonode.io:11009',
    'https': 'socks5://username:password@proxy.geonode.io:11009'
}

HTTP Proxy Example

use_socks5 = False

proxies = {
    'http': 'http://username:password@proxy.geonode.io:9008',
    'https': 'http://username:password@proxy.geonode.io:9008'
}

Replace username and password with your Geonode credentials

Step 3: Configure Test Parameters

Set your test parameters in the script:

url = 'http://ip-api.com'  # Default test target
num_requests = 5000        # Number of requests
num_workers = 5            # Concurrent threads

For accuracy:

  • Use 2000+ requests
  • Run with 5–10 threads

Step 4: Send Concurrent Requests

The script uses ThreadPoolExecutor to send multiple requests simultaneously:

from concurrent.futures import ThreadPoolExecutor
import requests, time

def fetch_url(i):
    try:
        start_time = time.time()
        response = requests.get(url, proxies=proxies, timeout=60)
        latency = time.time() - start_time
        return response.status_code, latency
    except requests.exceptions.Timeout:
        return 'Timeout', time.time() - start_time
    except requests.exceptions.RequestException:
        return 'Error', time.time() - start_time

Each request logs:

  • Status code
  • Latency (seconds)
  • Timeouts or errors

Step 5: Analyze and Visualize Results

After completing all requests, the script plots a latency graph.

ColorMeaning
BlueSuccessful requests (status 200)
RedNon-200 responses (404, 500)
GreenTimeouts
MagentaOther errors

Step 6: View Test Statistics

Once the test completes, the script outputs key metrics:


Average Latency: 1.20 seconds
Median Latency: 0.89 seconds
Standard Deviation of Latency: 1.30 seconds

Status Code Percentages:
200: 99.54%
Error: 0.12%
401: 0.04%
402: 0.06%
500: 0.20%
502: 0.04%

Total Requests: 5000
Successful (Status 200): 4977
Timeouts: 0
Other Errors: 6

Error Messages:
Error: 6

These values help assess reliability, consistency, and stability of your proxy connections.


Step 7: Interpret Results

Use the output to evaluate proxy quality:

MetricMeaning
Success RatePercentage of status 200 responses
LatencyAverage response time per request
Error DistributionFrequency of timeouts or other failures

Rotating ports provide more accurate, diversified benchmarks than testing a single static proxy.


Source Code

You can find the full source code for this script on GitHub: Geonode Proxy Testing Toolkit

On this page