Course contentsShow
← React
Lesson 1568 of 2,39638. Server Components FundamentalsFree lesson

Sequential vs Parallel Fetching Patterns

Understanding when Server Components fetch sequentially (await chains) versus in parallel (Promise.all).

Sequential vs Parallel Fetching Patterns

What you'll learn: How to control whether Server Components fetch data one-after-another or all-at-once, dramatically affecting performance.

The Default: Sequential Fetching

When you await multiple promises one after another in a Server Component, they execute sequentially—each waits for the previous to finish:

async function ProductPage({ id }) {
  const product = await fetchProduct(id);      // Waits 200ms
  const reviews = await fetchReviews(id);      // Then waits 300ms
  const recommendations = await fetchRecommendations(id); // Then waits 250ms
  
  return <div>{/* Total: 750ms */}</div>;
}

This creates a waterfall: each fetch blocks the next. Total time is the sum of all requests.

The Solution: Parallel Fetching

When fetches don't depend on each other, start them simultaneously and await them together using Promise.all:

async function ProductPage({ id }) {
  const [product, reviews, recommendations] = await Promise.all([
    fetchProduct(id),          // All three start immediately
    fetchReviews(id),
    fetchRecommendations(id)
  ]);
  
  return <div>{/* Total: 300ms (longest request) */}</div>;
}

Total time becomes the longest single request, not the sum.

When to Use Each Pattern

Sequential (await chains):

  • When data depends on previous results: await fetchUser(id) then await fetchPosts(user.id)

Parallel (Promise.all):

  • When fetches are independent: product details, reviews, and recommendations don't need each other's data to start

The Analogy

Sequential is like waiting in three separate checkout lines one after another. Parallel is like having three friends each stand in a different line simultaneously—you're done when the slowest finishes, not when all three finish in sequence.

Key Takeaway: Use Promise.all for independent Server Component data fetches to eliminate waterfalls and minimize total loading time—your 750ms page can become 300ms with one line change.