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
| Parameter | Default Value | Description |
|---|---|---|
| Protocol | HTTPS | Set use_socks5 = True for SOCKS5 proxies |
| Target | ip-api.com | Default endpoint for IP tests |
| Concurrency | 5–10 threads | Recommended thread range |
| Testing Volume | 2000+ requests | Recommended 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 Type | Protocol | Port Range | Description |
|---|---|---|---|
| Rotating | HTTP/HTTPS | 9000–9010 | Changes IP for every request |
| Rotating | SOCKS5 | 11000–11010 | Changes IP for every request |
| Sticky | HTTP/HTTPS | 10000–10900 | Keeps same IP for session duration |
| Sticky | SOCKS5 | 12000–12010 | Keeps 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 numpyLibraries used
requests— send HTTP requestsmatplotlib— visualize latency resultsnumpy— calculate average and median latencycollections— 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 threadsFor 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_timeEach 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.
| Color | Meaning |
|---|---|
| Blue | Successful requests (status 200) |
| Red | Non-200 responses (404, 500) |
| Green | Timeouts |
| Magenta | Other 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: 6These values help assess reliability, consistency, and stability of your proxy connections.
Step 7: Interpret Results
Use the output to evaluate proxy quality:
| Metric | Meaning |
|---|---|
| Success Rate | Percentage of status 200 responses |
| Latency | Average response time per request |
| Error Distribution | Frequency 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