Course contentsShow
← React
Lesson 1579 of 2,39639. Server Components in PracticeFree lesson

Sequential vs Parallel Data Fetching

Understand when to await sequentially versus when to let components fetch in parallel for performance.

Sequential vs Parallel Data Fetching

What you'll learn: How to control whether your async Server Components wait for each other or fetch simultaneously for better performance.


The Performance Fork in the Road

When you have multiple async Server Components fetching data, you face a critical decision: should they wait for each other (sequential) or run at the same time (parallel)?

Sequential fetching happens when you await one fetch before starting the next:

// Sequential: Second fetch waits for first to complete
async function SlowPage() {
  const user = await fetchUser(); // Waits 200ms
  const posts = await fetchPosts(); // Then waits another 300ms
  // Total: 500ms
}

Parallel fetching happens when you start all fetches simultaneously:

// Parallel: Both fetches start immediately
async function FastPage() {
  const userPromise = fetchUser(); // Starts immediately (200ms)
  const postsPromise = fetchPosts(); // Also starts immediately (300ms)
  
  const user = await userPromise;
  const posts = await postsPromise;
  // Total: 300ms (the slowest one)
}

When to Choose Each

Use sequential when:

  • The second fetch depends on data from the first (e.g., fetching user ID, then their posts using that ID)
  • You want to prioritize one piece of data appearing first

Use parallel when:

  • Fetches are independent
  • You want the fastest possible load time
  • All data is needed before rendering

Think of it like ordering at a restaurant: sequential is ordering your appetizer, waiting for it to arrive, then ordering your main course. Parallel is ordering everything at once—they all start cooking simultaneously.

Key Takeaway: Default to parallel fetching for independent data sources to minimize wait time; only use sequential await when one fetch truly depends on another's result.