Skip to content

Promise.all()로 독립적인 작업 병렬 처리

Overview

When async operations have no interdependencies, execute them concurrently using Promise.all().

Impact

  • Priority: CRITICAL
  • Performance: 2-10× improvement

Incorrect (sequential execution, 3 round trips)

typescript
const user = await fetchUser()
const posts = await fetchPosts()
const comments = await fetchComments()

This code executes each task sequentially, resulting in 3 network round trips.

Correct (parallel execution, 1 round trip)

typescript
const [user, posts, comments] = await Promise.all([fetchUser(), fetchPosts(), fetchComments()])

All operations start simultaneously, taking only as long as the slowest operation.

Key Points

  • Execute independent async operations in parallel
  • Use Promise.all() to handle multiple Promises concurrently
  • Reduce network round trips to minimize total response time

Tags: async, parallelization, promises, waterfalls