From 3377836177ccc1d980e9a7d5d348dbae6757ff24 Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 26 Sep 2013 03:11:31 -0400 Subject: [PATCH 1/3] [dist doc] Added baseline scripts and documentation for consistent benchmarking. --- benchmark/README.md | 33 +++++++++++++++++++ benchmark/scripts/hello.js | 3 ++ benchmark/scripts/proxy.js | 6 ++++ .../{ => scripts}/websockets-throughput.js | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 benchmark/README.md create mode 100644 benchmark/scripts/hello.js create mode 100644 benchmark/scripts/proxy.js rename benchmark/{ => scripts}/websockets-throughput.js (98%) diff --git a/benchmark/README.md b/benchmark/README.md new file mode 100644 index 000000000..2a852d14e --- /dev/null +++ b/benchmark/README.md @@ -0,0 +1,33 @@ +# Benchmarking `node-http-proxy` + +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). + +## Pre-requisites + +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**. + +``` +$ wrk +Usage: wrk + Options: + -c, --connections Connections to keep open + -r, --requests Total requests to make + -t, --threads Number of threads to use + + -H, --header Add header to request + -v, --version Print version details + + Numeric arguments may include a SI unit (2k, 2M, 2G) +``` + +## Benchmarks + +1. [Simple HTTP benchmark](#simple-http) + +### Simple HTTP + +_This benchmark requires three terminals running:_ + +1. **A proxy server:** `node benchmark/scripts/proxy.js` +2. **A target server:** `node benchmark/scripts/hello.js` +3. **A wrk process:** `wrk -c 20 -r 10000 -t 2 http://127.0.0.1:8000` \ No newline at end of file diff --git a/benchmark/scripts/hello.js b/benchmark/scripts/hello.js new file mode 100644 index 000000000..be09b6388 --- /dev/null +++ b/benchmark/scripts/hello.js @@ -0,0 +1,3 @@ +require('http').createServer(function(req, res) { + res.end('Hello world!'); +}).listen(9000); \ No newline at end of file diff --git a/benchmark/scripts/proxy.js b/benchmark/scripts/proxy.js new file mode 100644 index 000000000..8ade4d533 --- /dev/null +++ b/benchmark/scripts/proxy.js @@ -0,0 +1,6 @@ +var http = require('http'), + httpProxy = require('../../../lib/node-http-proxy'); +// +// Create your proxy server +// +httpProxy.createServer(9000, 'localhost').listen(8000); \ No newline at end of file diff --git a/benchmark/websockets-throughput.js b/benchmark/scripts/websockets-throughput.js similarity index 98% rename from benchmark/websockets-throughput.js rename to benchmark/scripts/websockets-throughput.js index 6787385ad..866e42461 100644 --- a/benchmark/websockets-throughput.js +++ b/benchmark/scripts/websockets-throughput.js @@ -1,7 +1,7 @@ var crypto = require('crypto'), WebSocket = require('ws'), async = require('async'), - httpProxy = require('../'); + httpProxy = require('../../'); var SERVER_PORT = 8415, PROXY_PORT = 8514; From 71ab6e51e40efe701ed7609ac0234de969371bc5 Mon Sep 17 00:00:00 2001 From: yawnt Date: Tue, 15 Oct 2013 00:21:46 +0200 Subject: [PATCH 2/3] [fix] typo --- benchmark/scripts/proxy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/scripts/proxy.js b/benchmark/scripts/proxy.js index 8ade4d533..4b06f242f 100644 --- a/benchmark/scripts/proxy.js +++ b/benchmark/scripts/proxy.js @@ -1,6 +1,6 @@ var http = require('http'), - httpProxy = require('../../../lib/node-http-proxy'); + httpProxy = require('../../lib/node-http-proxy'); // // Create your proxy server // -httpProxy.createServer(9000, 'localhost').listen(8000); \ No newline at end of file +httpProxy.createServer(9000, 'localhost').listen(8000); From 67a858a1f62dfc0c163cbe41b78665ce8ee849cf Mon Sep 17 00:00:00 2001 From: cronopio Date: Thu, 17 Oct 2013 17:51:37 -0500 Subject: [PATCH 3/3] [misc] wrk drop the -r flag, now the benchmark use a test duration instead total requests to make --- benchmark/README.md | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index 2a852d14e..fd32f772a 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -7,17 +7,20 @@ The long-term goal of these scripts and documentation is to provide a consistent 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**. ``` -$ wrk -Usage: wrk - Options: - -c, --connections Connections to keep open - -r, --requests Total requests to make - -t, --threads Number of threads to use +Usage: wrk + Options: + -c, --connections Connections to keep open + -d, --duration Duration of test + -t, --threads Number of threads to use + + -s, --script Load Lua script file + -H, --header Add header to request + --latency Print latency statistics + --timeout Socket/request timeout + -v, --version Print version details - -H, --header Add header to request - -v, --version Print version details - - Numeric arguments may include a SI unit (2k, 2M, 2G) + Numeric arguments may include a SI unit (1k, 1M, 1G) + Time arguments may include a time unit (2s, 2m, 2h) ``` ## Benchmarks @@ -30,4 +33,4 @@ _This benchmark requires three terminals running:_ 1. **A proxy server:** `node benchmark/scripts/proxy.js` 2. **A target server:** `node benchmark/scripts/hello.js` -3. **A wrk process:** `wrk -c 20 -r 10000 -t 2 http://127.0.0.1:8000` \ No newline at end of file +3. **A wrk process:** `wrk -c 20 -d 60 -t 2 http://127.0.0.1:8000` \ No newline at end of file