title: node.js mysql socket error after stress test
body: <p>I use node.js, an asynchronous event base server with mysql module to select 122 rows of records from the database.</p>
  
  <p>I ran a simple stress test using the command below:</p>
  
  <pre><code>ab -n 10 -c 2 http://localhost:8000/
  </code></pre>
  
  <p>the node.js finish the process, but mysql is still running, until it hits an error:</p>
  
  <pre><code> throw new Error('Socket is not writable');
            ^
   Error: Socket is not writable
      at Socket._writeOut (net.js:391:11)
      at Socket.write (net.js:377:17)
      at Client.write (/home/kelvin/node_modules/mysql/lib/client.js:142:16)
      at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:240:10)
      at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18)
      at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10)
      at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18)
      at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10)
      at Client._dequeue (/home/kelvin/node_modules/mysql/lib/client.js:274:18)
      at Object.end [as fn] (/home/kelvin/node_modules/mysql/lib/client.js:247:10)
  </code></pre>
  
  <p>Now whenever I run the test again, I get the same error.</p>
  
  <p>Is MySQL a good solution to use with Node.js or is it how I code?</p>
  
  <p>Some node.js code:</p>
  
  <pre><code>var server = http.createServer(function (request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
  
    client.query('USE ' + db);
    client.query('SELECT * FROM ' + tbl,
        function selectDb(err, results, fields) {
          if (err) {
            throw err;
          }
  
          console.log(results);
          client.end();
        }
    );
  
    response.end("END RESULT");
  });
  </code></pre>