Performance: Single-threaded non-blocking I/O concept
HIGH IMPACT
This concept affects how fast Node.js can handle multiple I/O tasks without blocking the main thread, improving responsiveness and throughput.
const fs = require('fs'); fs.readFile('file1.txt', (err, data1) => { if (err) throw err; fs.readFile('file2.txt', (err, data2) => { if (err) throw err; console.log(data1.toString(), data2.toString()); }); });
const fs = require('fs'); const data1 = fs.readFileSync('file1.txt'); const data2 = fs.readFileSync('file2.txt'); console.log(data1.toString(), data2.toString());
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous I/O | N/A | Blocks event loop | N/A | [X] Bad |
| Asynchronous non-blocking I/O | N/A | Event loop free | N/A | [OK] Good |