title: I/O bound and CPU bound
body: <p>Hei.</p>
  
  <p>I'm using <code>Node.JS</code> with <code>child_process</code> to spawn bash processes. I'm trying to understand if i'm doing I/O bound, CPU bound or both.</p>
  
  <p>I'm using <a href="http://www.tutorialspoint.com/unix_commands/pdftotext.htm" rel="nofollow noreferrer">pdftotext</a> to extract the text of <strong>10k+</strong> files. To control concurrences, I'm using <a href="https://github.com/caolan/async" rel="nofollow noreferrer">async</a>.</p>
  
  <p>Code:</p>
  
  <pre><code>let spawn = require('child_process').spawn;
  let async = require('async');
  let files = [
    {
      path: 'path_for_file'
      ...
    },
    ...
  ];
  let maxNumber = 5;
  
  async.mapLimit(files, maxNumber, (file, callback) =&gt; {
    let process = child_process.spawn('pdftotext', [
      "-layout",
      "-enc",
      "UTF-8",
      file.path,
      "-"
    ]);
    let result = '';
    let error = '';
  
    process.stdout.on('data', function(chunk) {
      result += chunk.toString();
    });
  
    process.stderr.on('error', function(chunk) {
      error += chunk.toString();
    });
  
    process.on('close', function(data) {
      if (error) {
        return callback(error, null);
      }
      callback(null, result);
    });
  
  
  }, function(error, files) {
    if (error) {
      throw new Error(error);
    }
  
    console.log(files);
  });
  </code></pre>
  
  <p>I'm monitoring my Ubuntu usage and my CPU and Memory are very high when i run the program, and also sometimes I see only one file being processed at a time, is this normal?? What could be the problem??</p>
  
  <p>I'm trying to understand the concept of child_process. Is <code>pdftotext</code> a child process of <code>Node.JS</code>? All child processes are running only in one core? And, how can i make more soft for my computer process the files?</p>
  
  <p>Cool image of glancer:</p>
  
  <p><a href="https://i.stack.imgur.com/K2ibo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K2ibo.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>Is this usage of Node.JS because of the child_process's??</p>
  
  <p><a href="https://i.stack.imgur.com/rM6fl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rM6fl.png" alt="enter image description here"></a></p>
  
  <p>Thanks.</p>