Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4493f2
commit d3d03d5
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Requests-Racer seems to perform much better when your requests have a POST body. | ||
|
||
Here are some benchmarks, collected using `benchmark.py` in this directory running on a laptop on a wireless connection in Seattle, against a server in Boston. | ||
|
||
Values in the table are the spread (i.e., max value - min value) of the times when the requests were processed by the server. Values are given in milliseconds and are the median of 5 runs. | ||
|
||
| Number of simultaneous requests | GET | POST 128 bytes | POST 1024 bytes | POST 2048 bytes | POST 4096 bytes | | ||
| ------------------------------- | ---: | -------------: | --------------: | --------------: | --------------: | | ||
| 1 | 0 | 0 | 0 | 0 | 0 | | ||
| 2 | 0 | 0 | 0 | 0 | 0 | | ||
| 4 | 1 | 2 | 2 | 2 | 2 | | ||
| 8 | 21 | 4 | 5 | 4 | 4 | | ||
| 16 | 45 | 8 | 8 | 8 | 9 | | ||
| 32 | 85 | 16 | 19 | 15 | 13 | | ||
| 64 | 172 | 30 | 33 | 29 | 30 | | ||
| 128 | 387 | 62 | 63 | 66 | 53 | | ||
| 256 | 974 | 120 | 123 | 119 | 128 | | ||
| 512 | 2098 | 264 | 249 | 238 | 253 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import sys | ||
import time | ||
|
||
from requests_racer import SynchronizedSession | ||
|
||
# the script is just "<?= microtime(true) ?>" | ||
URL = 'http://example.com/time_raw.php' | ||
TRIES = 5 | ||
|
||
def median(l): | ||
n = len(l) | ||
ls = sorted(l) | ||
if n % 2 == 1: | ||
return ls[n // 2] | ||
return (ls[n // 2 - 1] + ls[n // 2]) / 2 | ||
|
||
def main(): | ||
session = SynchronizedSession() | ||
|
||
for i in range(10): | ||
n = 2**i | ||
|
||
spreads = [] | ||
|
||
for payload_size in [0, 128, 1024, 2048, 4096]: | ||
spreads_here = [] | ||
|
||
for j in range(TRIES): | ||
if payload_size == 0: | ||
requests = [session.get(URL) for _ in range(n)] | ||
else: | ||
requests = [session.post(URL, data='a'*payload_size) for _ in range(n)] | ||
|
||
session.finish_all() | ||
|
||
request_times = [float(r.text) for r in requests] | ||
spread = max(request_times) - min(request_times) | ||
|
||
spreads_here.append(spread) | ||
|
||
spreads.append(median(spreads_here)) | ||
|
||
spreads_ms = [round(t * 1000) for t in spreads] | ||
print(n, *spreads_ms, sep=' | ') | ||
|
||
if __name__ == '__main__': | ||
main() |