title: Slow http request in node server
body: <p>In my application, I have to create an API for searching <em>n</em> items.
  The server logic is to find for items in it's own database and if the result count is less than <em>n</em>,  then use search results from a third party service to fill in the remaining results.</p>
  
  <p>The problem I'm facing over here is, the time taken to execute the third party request.<br>
  On an average it takes around <strong>900-1500 ms</strong> to execute the third party request from the server, however if I execute the same request from browser or any other rest clients, the same takes around <strong>300-400 ms</strong>.</p>
  
  <p>This is what I'm doing</p>
  
  <pre><code>router.get('/search/:searchParam', function (req, res, next) {
      async.parallel({
          local : function(callback){
              //Search for object in DB
              callback(null,localResults);
          },
          fallback : function(callback) {
              var url = &lt;searchURL&gt;+&lt;queryParam&gt;;
              //This takes 900-1500 ms
              request(url, function (error, response, body) {
                  if(error){
                      return callback(err);
                  }
                  callback(null,JSON.parse(body));
              });
          }
      }, function(err, results){
          if(err){
              return reject(err);
          }
          if(results.local.length &lt; searchLimit) {
              results.local.push.apply(results.local,_.first(results.fallback,searchLimit-results.local.length));
              results.local = results.local.reduce(function(a,b){if(a.indexOf(b)&lt;0)a.push(b);return a;},[]);
          }
          res.json(results.local);
      })
  })
  </code></pre>
  
  <p>The avg time taken is :<br>
  A. <strong>40-100 ms</strong> for local search<br>
  B. <strong>900-1500 ms</strong> for fallback search<br>
  A+B. <strong>1000-1500ms</strong> Total time </p>
  
  <p>I'm not getting how to improve the overall response time.<br>
  Any suggestions?</p>