This chapter covers
- Comparing asynchronous and synchronous processing
- Understanding the event loop
- Hiding latency with async I/O and deferring work
- Handling errors in async systems
- Observing async systems
Throughout the book, we’ve built a comprehensive understanding of latency optimization. In part 1, we established the foundations by exploring the fundamental nature of latency, why it’s so important, and essential techniques for modeling and measuring it. In part 2, we explored data-centric latency optimization strategies, such as partitioning and caching, and in part 3, we explored code-level techniques to reduce latency.
In this part of the book, we’ll turn our attention to hiding latency. This approach becomes critical when you’ve exhausted latency optimization methods or have run into constraints in your system architecture. For example, you may have hit the physical limits of your hardware, or maybe you’re working with third-party systems that you cannot change. In such scenarios, latency-hiding techniques—using asynchronous processing and predictive methods—become critical for improving the latency of your application.
This chapter focuses on asynchronous processing. Unlike synchronous processing, where operations block until completion, asynchronous processing allows your system to initiate tasks without waiting for their results. This can significantly reduce the perceived latency and improve overall system responsiveness.