title: delay of 5 seconds between each request in Node Js
body: <p>Here is my code:</p>
  
  <p>I have more than 500,000 records in my database and I want to loop and request some information from another server. I've successfully wrote all functions except delays between each request. If I send all request with node.js remote server goes downs or can not answer each request. So I need to create a queue for looping But my code is not working still sending all request very fast.</p>
  
  <pre><code>var http = require('http')
  , mysql = require('mysql');
  var querystring = require('querystring');
  var fs = require('fs');
  var url  = require('url');
  
  
  var client = mysql.createClient({
      user: 'root',
      password: ''
  });
  
  client.useDatabase('database');
  client.query("SELECT * from datatable",
      function(err, results, fields) {
          if (err) throw err;
          for (var index in results) {
              username = results[index].username;
              setInterval(function() {
  
                  requestinfo(username);
              }, 5000 );
  
          }
      }
      );
  client.end();
  }
  </code></pre>