The performance comparison between node http-proxy and nginx proxy?

  node.js, question

In recent days, I have studied the http-proxy module briefly, and have done some simple reverse proxy tests (mainly compared with nginx)
Found the same number of concurrent and requests, nginx’s processing power is twice that of http-proxy. Do you generally use nginx as the proxy for node?

Http-proxy proxy code

var http = require('http')
 var httpProxy = require('http-proxy')
 var proxy = httpProxy.createProxyServer({})
 Var config = require(__dirname plus' /config')
 var LOCALHOST = 'http://127.0.0.1'
 
 proxy.on('error', function(err, req, res) {
 res.writeHead(500, {'Content-Type': 'text/plain'})
 res.end('Something went wrong.')
 })
 
 var server = http.createServer(function(req, res) {
 var host = req.headers.host
 var ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
 Log ('clientip:' plus ip plus', host:' plus host)
 
 switch (host) {
 case config[0].sitename:
 Proxy.web (req, res, {target: localhost plus':' plus config[0].port})
 break
 case config[1].sitename:
 Proxy.web (req, res, {target: localhost plus':' plus config[1].port})
 break
 case config[2].sitename:
 Proxy.web (req, res, {target: localhost plus':' plus config[2].port})
 break
 case config[3].sitename:
 Proxy.web (req, res, {target: localhost plus':' plus config[3].port})
 break
 case config[4].sitename:
 Proxy.web (req, res, {target: localhost plus':' plus config[4].port})
 break
 default:
 res.writeHead(200, {'Content-Type': 'text/plain'})
 res.end('http-proxy test.')
 bracket
 })
 
 console.log('listening on proxy-port 80')
 server.listen(80)

Http-proxy proxy proxy test

root@lizi:/usr/local/src/webbench-1.5# ab -n 200000 -c 50  http://test01.lizi.com/
 This is ApacheBench, Version 2.3 <$Revision: 655654 $>
 Copyright 1996 Adam Twiss, Zeus Technology Ltd,  http://www.zeustech.net/
 Licensed to The Apache Software Foundation,  http://www.apache.org/
 
 Benchmarking  test01.lizi.com (be patient)
 Completed 20000 requests
 Completed 40000 requests
 Completed 60000 requests
 Completed 80000 requests
 Completed 100000 requests
 Completed 120000 requests
 Completed 140000 requests
 Completed 160000 requests
 Completed 180000 requests
 Completed 200000 requests
 Finished 200000 requests
 
 
 Server Software:
 Server Hostname:         test01.lizi.com
 Server Port:            80
 
 Document Path:          /
 Document Length:        140 bytes
 
 Concurrency Level:      50
 Time taken for tests:   229.573 seconds
 Complete requests:      200000
 Failed requests:        0
 Write errors:           0
 Total transferred:      48200000 bytes
 HTML transferred:       28000000 bytes
 Requests per second:    871.18 [#/sec] (mean)
 Time per request:       57.393 [ms] (mean)
 Time per request:       1.148 [ms] (mean, across all concurrent requests)
 Transfer rate:          205.03 [Kbytes/sec] received
 
 Connection Times (ms)
 Min mean[ plus /-sd] median max
 Connect:        0    0   0.1      0       7
 Processing:     2   57  29.9     58     162
 Waiting:        0   57  29.9     58     162
 Total:          7   57  29.9     58     162
 
 Percentage of the requests served within a certain time (ms)
 50% 58
 66% 65
 75% 72
 80% 90
 90% 104
 95% 114
 98% 123
 99% 128
 100% 162 (longest request)

Nginx proxy test

root@lizi:/var/log/nginx# ab -n 200000 -c 50  http://test01.lizi.com/
 This is ApacheBench, Version 2.3 <$Revision: 655654 $>
 Copyright 1996 Adam Twiss, Zeus Technology Ltd,  http://www.zeustech.net/
 Licensed to The Apache Software Foundation,  http://www.apache.org/
 
 Benchmarking  test01.lizi.com (be patient)
 Completed 20000 requests
 Completed 40000 requests
 Completed 60000 requests
 Completed 80000 requests
 Completed 100000 requests
 Completed 120000 requests
 Completed 140000 requests
 Completed 160000 requests
 Completed 180000 requests
 Completed 200000 requests
 Finished 200000 requests
 
 
 Server Software:        nginx/0.7.67
 Server Hostname:         test01.lizi.com
 Server Port:            80
 
 Document Path:          /
 Document Length:        209 bytes
 
 Concurrency Level:      50
 Time taken for tests:   126.081 seconds
 Complete requests:      200000
 Failed requests:        0
 Write errors:           0
 Total transferred:      66400000 bytes
 HTML transferred:       41800000 bytes
 Requests per second:    1586.28 [#/sec] (mean)
 Time per request:       31.520 [ms] (mean)
 Time per request:       0.630 [ms] (mean, across all concurrent requests)
 Transfer rate:          514.30 [Kbytes/sec] received
 
 Connection Times (ms)
 Min mean[ plus /-sd] median max
 Connect:        0    2  97.9      0    9000
 Processing:     2   29  17.2     33    3474
 Waiting:        2   29  17.2     33    3474
 Total:          5   32  99.7     33    9038
 
 Percentage of the requests served within a certain time (ms)
 50% 33
 66% 34
 75% 34
 80% 35
 90% 36
 95% 38
 98% 39
 99% 41
 100% 9038 (longest request)

Yes, and nginx is also used to represent node.