// Blocking(Synchronous) IO example in PHP // Can handle only one request at a time // (IO---CPU-)(IO--CPU--)(IO------CPU--) <?php echo 'Starting ...' . PHP_EOL; echo 'Contents of file: ' . file_get_contents('file.txt') . PHP_EOL; echo 'Executing the next job ...' . PHP_EOL; // $ php example.php // Starting ... // Contents of file: This is the content of this file. // Executing the next job ... // Non-blocking IO example in NodeJS (Asynchronous) // Handle multiple request at a time // IO--- CPU // IO--CPU // IO------ CPU var fs = require('fs'); console.log('Starting ...'); fs.readFile('file.txt', function(error, data) { console.log('Contents of file: ' + data); }); console.log('Executing the next job ...'); // $ node example.js // Starting ... // Executing the next job ... // Contents of file: This is the content of this file.