Skip to content

Commit 3377836

Browse files
committed
[dist doc] Added baseline scripts and documentation for consistent benchmarking.
1 parent 611a1b1 commit 3377836

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

benchmark/README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Benchmarking `node-http-proxy`
2+
3+
The long-term goal of these scripts and documentation is to provide a consistent and well understood benchmarking process for `node-http-proxy` so that performance does not degrade over time. They were initially created to compare the performance of `v0.10.3` and `v1.0.0` (which was a significant rewrite).
4+
5+
## Pre-requisites
6+
7+
All benchmarking shall be done with [wrk](https://github.com/wg/wrk) which _is the same tool used for performance testing by the node.js core team._ **Make sure you have `wrk` installed before continuing**.
8+
9+
```
10+
$ wrk
11+
Usage: wrk <options> <url>
12+
Options:
13+
-c, --connections <n> Connections to keep open
14+
-r, --requests <n> Total requests to make
15+
-t, --threads <n> Number of threads to use
16+
17+
-H, --header <h> Add header to request
18+
-v, --version Print version details
19+
20+
Numeric arguments may include a SI unit (2k, 2M, 2G)
21+
```
22+
23+
## Benchmarks
24+
25+
1. [Simple HTTP benchmark](#simple-http)
26+
27+
### Simple HTTP
28+
29+
_This benchmark requires three terminals running:_
30+
31+
1. **A proxy server:** `node benchmark/scripts/proxy.js`
32+
2. **A target server:** `node benchmark/scripts/hello.js`
33+
3. **A wrk process:** `wrk -c 20 -r 10000 -t 2 http://127.0.0.1:8000`

benchmark/scripts/hello.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('http').createServer(function(req, res) {
2+
res.end('Hello world!');
3+
}).listen(9000);

benchmark/scripts/proxy.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var http = require('http'),
2+
httpProxy = require('../../../lib/node-http-proxy');
3+
//
4+
// Create your proxy server
5+
//
6+
httpProxy.createServer(9000, 'localhost').listen(8000);

benchmark/websockets-throughput.js benchmark/scripts/websockets-throughput.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var crypto = require('crypto'),
22
WebSocket = require('ws'),
33
async = require('async'),
4-
httpProxy = require('../');
4+
httpProxy = require('../../');
55

66
var SERVER_PORT = 8415,
77
PROXY_PORT = 8514;

0 commit comments

Comments
 (0)