title: nodejs web server and simultaneous file append
body: <p>I've read about nodejs event-loop, but what i don't understand well is:   </p>
  
  <blockquote>
    <ul>
    <li>i've created a simple http-server that logs the whole request post-data to a file .  </li>
    <li>i used apache-ab to flood it with a 700 kb file for-each request it does .</li>
    </ul>
  </blockquote>
  
  <p>i imagined that each request will write some chunks after each other each tick in the event-loop, but i found that the full post data is written completely after each request and i don't know why , and i cannot understand it .  </p>
  
  <hr>
  
  <p>i'm using something like this</p>
  
  <pre><code>stream = require('fs').createWriteStream('path/to/log.file', {flags: 'a'})
  log = function(data){
     return stream.write(data)
  }
  
  require('http').createServer(function(req, res)
  {
  
     // or req.pipe(stream)
     req.on('data', function(chunk){
       log(chunk.toString() + "\r\n")
     })
  
     req.on('end', function(){
        res.end("ok")
     })
  
  }).listen(8000)
  </code></pre>
  
  <hr>
  
  <p>sorry for my bad English :)</p>