chapter ten

10 Understanding Async Rust

 

This chapter covers

  • Introduction to Async programming concepts
  • Writing concurrent programs
  • Diving deeper into async Rust
  • Understanding futures
  • Implementing a custom future

In the previous chapters, we covered building a web service and a web application using Rust. To build these, we’ve used the Actix web framework for handling the network communications. We’ve mostly submitted HTTP requests to the Actix web server from a single browser window or from a command-line terminal. But have you thought about what happens when tens or hundreds of users send requests concurrently for registering tutors or courses? Or more broadly, how do modern web servers handle tens of thousands of concurrent requests? Read on, to find out.

In this chapter, we will take a detour from building the web application, and look under the hood to understand what is asynchronous Rust, what is the need to use it, and how it works in practice. By the end of this chapter you’ll have a better understanding of the magic that Actix (and other similar modern web frameworks) perform to handle heavy concurrent loads, while delivering swift responses to user requests.

10.1 Introduction to Async programming concepts

10.2 Writing concurrent programs

10.3 Diving deeper into async Rust

10.4 Understanding futures

10.5 Implementing a custom future

10.6 Summary