Beginner LevelSystem Design & Architecture
What is Synchronous Blocking vs Asynchronous Non-Blocking execution?
β Interview Prompt: Compare Synchronous (blocking thread execution) vs Asynchronous (non-blocking, event loop, promises, callbacks) execution models.
Evaluating execution model concurrency paradigms:
β’
Synchronous Execution: Threads block and wait passively for operations (like disk I/O or network requests) to complete before executing subsequent lines of code.
β’
Asynchronous Execution: Threads delegate I/O tasks to the OS kernel or event loop and continue executing other work immediately. Callbacks or Promises trigger when the I/O completes, handling high concurrency with minimal threads (e.g. Node.js Event Loop).
Code Implementation Example
typescript
// Asynchronous Non-Blocking I/O in Node.js
async function fetchUserData(userId: string) {
// Event loop handles I/O non-blockingly while executing other tasks
const [user, orders] = await Promise.all([
fetchUser(userId),
fetchOrders(userId)
]);
return { user, orders };
}π‘Executing parallel non-blocking asynchronous requests in Node.js.
π― Interview Key Takeaway
Use asynchronous non-blocking execution models to achieve high concurrency throughput with minimal thread overhead.
#System Design#Asynchronous#Non-Blocking#Event Loop#Beginner
Back to all System Design & Architecture Questionsβ