I am exploring the possibility of using Node to work as a reverse proxy. One of the main goals of my project is VERY high productivity. Therefore, I configured the Node server to proxy requests to the target Node server, which will say hello world regardless of the request.
Using Apache Bench I made some comparison of the number of requests processed per second. The proxy server, target audience, and caller are on separate instances of M1 Large in AWS. My results are disappointing and confusing.
Straight from the caller to the target:
ab -c 100 -n 10000 http:
= ~ 2600 requests per second
From caller through proxy to target
ab -c 100 -n 10000 http:
= ~ 1100 requests / sec
Using lighttpd, I was able to get ~ 3500 requests / second for proxies and target
I am disappointed that the proxy server is less efficient than the target server. Comparing other products, such as lighttpd, I saw the proxy achieve comparable results with the goal, so I'm confused by the fact that Node (supposedly to quickly illuminate) does not achieve the same.
Here is my proxy code in Node v0.5.9: Am I missing something?
var server = http.createServer(function(req, res){ var opts = { host: 'target-instance', port: 80, path: '/', method: 'GET'}; var proxyRequest = http.get(opts, function(response){ response.on('data', function(chunk){ res.write(chunk); }); response.on('end', function(){ res.end() }); }); }); server.listen(80);
jonnysamps
source share