Huge performance issue
Problem
Hi all, I have a huge performance issue with node-http-proxy, maybe I'm missing something, hopefully someone can point out what's wrong. Here's the code I'm using for the proxy (listening on 9000): [code block] and here's the code of the server listening on 8000: [code block] I used wrk to benchmark the performance of the proxy. First, I test the http server to see how many requests it can handle: wrk -c 64 -d 15s http://127.0.0.1:8000 Requests/sec: 26255.78 Now when I test the proxy: wrk -c 64 -d 15s http://127.0.0.1:9000 Requests/sec: 543.84 Something is clearly wrong, so I inspected the cpu usage during the benchmark and I noticed that when I directly test the http server (port 8000), the cpu usage of the server's process stays very close to 100% for the duration of the test (which is expected), but when I test the proxy, the proxy's process gets to 100% but quickly (1-2 seconds after the beginning of the test) drops to 0% Note that wrk, the proxy and the hello world server run on different threads, this issue is not related to insufficient resources (I have 8 thread on my machine). I have also tested nginx and HAProxy, and both did fine. The main reason I want to use http-proxy is for load balancing, but so far it looks like it's gonna be a bottleneck more than anything else.
Error Output
var httpProxy = require('http-proxy');
var proxy = httpProxy.createServer({
target:'http://127.0.0.1:8000'
});
proxy.on('error', function(e) {
console.error(e);
});
proxy.listen(9000);Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Huge performance issue
Try ending the proxied response: [code block]
Trust Score
1 verification
- 1
Try ending the proxied response:
Try ending the proxied response:
textproxy.on('error', function(e, req, res) { console.error(e); res.status( 500 ).end( "Error occurred" ); });
Validation
Resolved in http-party/node-http-proxy GitHub issue #929. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep