Async Programming & Performance in JavaScript – What Actually Happens Behind the Scenes

Who Am I?

Nirmal Vyas

18+ years experience in IT field

Worked almost 10+ years in various IT companies as a Developer, Senior developer, Team lead, Project Manager etc.

Fulltime Freelancer/Consultant since last 8 + years
I do Web development projects for various clients in India and abroad, and also Technical Consultancy Services for various IT companies and startups.

 

Website: http://codenirmal.com/

 

Organizer of Technical meetups in Kochi like Kerala JS, Active Member of other groups like Kochi Ruby, Kochi Python etc.

Introduction

Content:

  • JS is single-threaded — what does that really mean?
  • Why async programming exists
  • Common confusion:
    • async/await ≠ parallel
    • setTimeout ≠ immediate
    • “Node.js is fast” — why?

Trigger Questions:

  • “Why doesn’t Node crash with 1000 users?”
  • “Why is my API slow even though code is correct?”

JavaScript Execution Model

Content:

  • Call Stack (what runs now)
  • Single-threaded nature
  • Blocking vs Non-blocking

Key Takeaway:

  • Only one thing runs at a time

Event Loop Deep Dive

Content:

  • What is Event Loop?
  • Web APIs / Node APIs
  • Callback Queue (macrotask queue)
  • Microtask Queue (Promises)

Flow:

Code → Call Stack
Async → API
Done → Queue
Event Loop → Execute

4. Promises & async/await
 

Content:

  • Promise basics (resolve/reject)
  • async/await = syntactic sugar
  • Execution flow behind await
     

Key Misconceptions:

  • await does NOT make code parallel
  • await blocks function execution

Sequential vs Parallel Execution 

Content:

  • Sequential execution (slow)
  • Parallel execution with Promise.all
     

Key Misconceptions:

  • await does NOT make code parallel
  • await blocks function execution

Common Performance Mistakes

Content:

  • ❌ Blocking Code

  • Infinite loops
  • Heavy sync operations
  • ❌ Misuse of await

  • Inside loops
  • ❌ Large JSON parsing

  • CPU blocking
  • ❌ Too many sequential API calls

Fix Patterns​:

  • Promise.all Batching
  • Offloading work

Backend Performance Thinking

Content:

  • API response lifecycle
  • DB + API + File system → async flow
  • Identifying bottlenecks

Key Idea:

  •  Performance = execution order + resource usage

 Debugging Async Issues

 

Content:

  • How to identify slow parts

  • Logs + timing

  • Where things usually fail

Summary & Key Takeaways

  • JS is single-threaded but non-blocking

  • Event loop controls everything

  • async/await is not magic

  • Performance depends on how you structure async code

Questions?

nirmalkamath@gmail.com
Whatsapp: 9895625954

Thanks!

nirmalkamath@gmail.com

http://codenirmal.com

deck

By phpnirmal