Apigee Edge supports Node.js version 0.10. In this version of Node, the default connection pool for outgoing http requests to a host is 5. This can be a significant bottleneck if you have many concurrent requests to the same host. This is a very well-known issue. Fortunately, there are some very simple solutions that will make your application more performant in these scenarios:
var http = require('http'); http.globalAgent.maxSockets = 100; // You could also set it to unlimited (Node v0.12 does by default): http.globalAgent.maxSockets = Infinity;
var http = require('http'); var req = http.request({ agent: false, url: "", ... }, function (res) { ... });
Are there any side-effects of increasing the size of the connection pool or disabling connection pooling (such as increased memory foot-print) that one needs to be aware of when making these changes and would any changes be required in those areas where side-effects could be caused?
If requests sent from Node.js aren't throttled, increasing the pool size can be too high, so that too many requests hit the backend and bring it down. I have used NPM modules such as Throat to manage concurrency of parallel promises https://www.npmjs.com/package/throat.
Also Bluebird module comes with some handy affordances to limit concurrency with Promises. http://bluebirdjs.com/docs/api/promise.map.html#map-option-concurrency
where should i add this off code in node.js
I read somewhere that static files should be served from Nginx which sits in front of Node.js. Why is it not recommended to serve from Node.js directly? Is express.static() not good for production usage?