Skip to content

Commit

Permalink
perf(plook): use custom HTTP agent
Browse files Browse the repository at this point in the history
By using a custom HTTP agent, we are able to increase the maxSockets.
This allows for much greater performance when doing ApacheBench
tests, for example.
  • Loading branch information
Gustavo Henke committed Sep 9, 2014
1 parent 7e3be04 commit baa9cd5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/plook.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ function Plook( root ) {
return new Plook();
}

// Create a custom socket for when getting files
this._agent = new https.Agent();
this._agent.maxSockets = 10;

Object.defineProperty( this, "_cache", {
value: root instanceof Plook ? root._cache : LRU({
max: 500
Expand Down Expand Up @@ -193,6 +197,7 @@ Plook.prototype.get = function( name, version, file, etag ) {

promise = this.findURLs( name, version, file ).call( "map", function( reqUrl ) {
var options = url.parse( reqUrl );
options.agent = plook._agent;
options.headers = {
"if-none-match": etag
};
Expand Down

0 comments on commit baa9cd5

Please sign in to comment.