Harith Zahid

Key Takeaways

  1. Async/await helps with I/O, not CPU computation

    • I/O = waiting for external operations (files, network, database)
    • CPU = actively computing on the main thread
  2. The event loop has 6 phases + microtasks

    • Microtasks (nextTick, Promises) run between every phase
    • Understanding this helps debug timing issues
  3. For CPU-intensive tasks:

    • Use Worker Threads for true parallelism
    • Break up work with setImmediate for simpler cases
    • Never block the main thread
  4. setImmediate always runs in the next loop iteration

    • Use it to give the event loop breathing room
    • Multiple calls in same loop run together in next iteration
  5. Modern async patterns:

    • Use async/await for readability
    • Use Promise.all() for parallel operations
    • Always handle errors with try/catch