Load balancing with node.js using http-proxy
问题 I'm trying to code a loadbalancing with node.js and http-proxy. I want a loadBalancer which share incoming request treatment between 2 servers. var http = require('http'), httpProxy = require('http-proxy'); var servers = [{host :'127.0.0.1', port :3000}, {host : 'remote_adr',port :3000}]; httpProxy.createServer(function (req, res, proxy) { var target = servers.shift(); proxy.proxyRequest(req, res, target); servers.push(target); }).listen(8000); I thought that doing this, it would have made a