We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Welcome to Web Servers

In a way, this course is where everything you've learned so far on the Boot.dev back-end path comes together. Building HTTP servers is the bread-and-butter of a back-end developer's day-to-day work.

This course assumes you already have a solid understanding of TypeScript.

Goals of This Course

  • Understand what web servers are and how they power real-world web applications
  • Build an actual web server in TypeScript, without the use of a framework
  • Learn what makes TypeScript a great language for building fast web servers
  • We'll use production-ready tools for everything in this course.

What Is a Server?

A web server is just a computer that serves data over a network, typically the Internet. Servers run software that listens for incoming requests from clients. When a request is received, the server responds with the requested data.

Any server worth its salt can handle many requests at the same time. In TypeScript, we use asynchronous functions and the event loop to handle many requests concurrently. Let's start by practicing with asynchronous functions.

Assignment

In this course, we'll be working on a product called "Chirpy". Chirpy is a social network similar to Twitter.

One of Chirpy's servers is processing requests unbelievably slowly. It's processing every request using async/await.

Notice that the server times out after 5 seconds and the requests can't finish. That's because they're being processed one-by-one sequentially - each request takes 2 seconds, so 4 requests would take 8 seconds total.

await Promise.all(reqs.map((req) => handleRequest(req)));

This uses Promise.all to run all the requests concurrently instead of sequentially. Now all 4 requests will run at the same time and complete in just 2 seconds.