slow performance using basic-proxy.js vs. no proxy
Problem
Hey all, I have been running some ab tests against the basicproxy.js service and have noticed it's about 3 times slower using the proxy than not. I'm on node 0.8.8 and ubuntu 11.10. Using proxy > ab -c 10 -n 1000 http://127.0.0.1:8000/ > Total response time was approx. 4 seconds No proxy > ab -c 10 -n 1000 http://127.0.0.1:9000/ > Total response time was approx. 1.7 seconds I ran the proxy with node http debugging enabled for a single request and this was the output. NODE_DEBUG=http node basic-proxy.js 1 request through proxy HTTP: SERVER new http connection HTTP: server response shouldKeepAlive: false I'm proxyrequest get base result HTTP: outgoing message end. HTTP: SERVER new http connection HTTP: server response shouldKeepAlive: true HTTP: write ret = true HTTP: outgoing message end. HTTP: AGENT incoming response! HTTP: AGENT isHeadResponse false HTTP: write ret = true HTTP: AGENT socket keep-alive HTTP: outgoing message end. HTTP: server socket close HTTP: server socket close 1 request without proxy HTTP: SERVER new http connection HTTP: server response shouldKeepAlive: false HTTP: write ret = true HTTP: outgoing message end. HTTP: server socket close Is the performance difference simply because we're asking the proxy to do that much more, that 3x increase seems like something is askew here. I tested this with different ab parameters, played around with the maxSockets settting and tried a different http agent, but nothing seemed to speed up going through th
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: slow performance using basic-proxy.js vs. no proxy
So I identified the majority of the bottleneck is in the dns lookup call done from in the node.js source from http.js > net.js > dns.js. I added some debug statements to the node.js source and found this: DEBUG - http.js socket write ms:796ms DEBUG - 2012-09-24T18:52:28.797Z <trace> simpleproxy-withlisteners.js:35 (ClientRequest.<anonymous>) socket assigned to backend request! DEBUG - net.js loo
Trust Score
1 verification
- 1
So I identified the majority of the bottleneck is in the dns lookup call done fr
So I identified the majority of the bottleneck is in the dns lookup call done from in the node.js source from http.js > net.js > dns.js. I added some debug statements to the node.js source and found this:
- 2
DEBUG - http.js socket write ms:796ms
DEBUG - 2012-09-24T18:52:28.797Z <trace> simpleproxy-withlisteners.js:35 (ClientRequest.<anonymous>) socket assigned to backend request! DEBUG - net.js lookup dns callback ms:880ms
- 3
That's 84ms of what was a 100ms request just in processing the dns lookup. Node
That's 84ms of what was a 100ms request just in processing the dns lookup. Node is doing no caching of this either, so you take that hit every time.
- 4
I created this test script to help narrow down where the
https://gist.github.com/3834431
Validation
Resolved in http-party/node-http-proxy GitHub issue #305. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep