Sync Vs Async

Hands-on practice for this lecture. Work through the exercises and quizzes to reinforce what you've learned.

1

Exercise 1 of 2

Thread-per-Request vs Event Loop — Live Simulation

Set the concurrent request count and watch how a thread-per-request model stacks up blocking threads while an event loop handles the same load with a single thread.

Thread-per-Request vs Event Loop — Live Simulation
Concurrent Requests8
116
Thread-per-Request
Traditional Java / PHP
Threads: 8 · RAM: ~16MB
T-1IO wait
T-2
T-3
T-4
T-5
T-6
T-7
T-8
Event Loop
Node.js / Nginx
Threads: 1 · RAM: ~50MB
Event Loop — idle (IO in flight)
IO in flight: 1 · Done: 0
·
·
·
·
·
·
·

Both models finish in the same wall-clock time for IO-bound work. The event loop advantage is resource efficiency: 1,000 concurrent users needs 1,000 threads (~2GB) on TPR vs a single event loop thread. This is why Node.js was built.

2

Exercise 2 of 2

Async Queue — Accept Fast, Process Slow

Submit compression jobs and watch the server respond in under 1ms while a background worker handles the queue. Shows how queues break synchronous coupling at the system level.

Async Queue — Accept Fast, Process Slow

Click Submit Job. The server responds in under 1ms with a job ID — no waiting for compression to finish. Submit multiple jobs to watch them queue up.

The client received a response in under 1ms. Actual processing takes 3+ seconds — but the connection is already closed. The client saved the job ID and can poll or receive a webhook when done. This is exactly how Sidekiq, Bull, Celery, and AWS SQS work.

Practice: Sync Vs Async — Interactive Exercises | Durgesh Rai