1 Getting to know asyncio

 

This chapter covers

  • What asyncio is and the benefits it provides
  • Concurrency, parallelism, threads and processes
  • The global interpreter lock and the challenges it poses to concurrency
  • How non-blocking sockets can achieve concurrency with only one thread
  • The basics around how event-loop based concurrency works

Many applications especially in today’s world of web applications rely heavily on I/O operations. These types of operations include downloading the contents of a webpage from the internet, communicating over a network with a group of microservices, or running several queries together against a database such as MySQL or Postgres. A web request or communication with a microservice may take hundreds of milliseconds, or even seconds if the network is slow. A database query could be expensive especially if that database is under high load or the query is complex. A web server may need to handle hundreds if not thousands of requests at the same time. These operations can be expensive in terms of time.

1.1      What is asyncio?

1.2      What is I/O bound and what is CPU bound?

1.3      Understanding Concurrency, Parallelism and Multitasking

1.3.1   What are concurrency and parallelism?

1.3.2   The difference between concurrency and parallelism

1.3.3   What is multitasking?

1.3.4   The benefits of cooperative multitasking

1.4      Understanding processes, threads, multithreading and multiprocessing

1.5      Understanding the Global Interpreter Lock

1.5.1   Is the GIL ever released?

1.5.2   Asyncio and the GIL

1.6      How single threaded concurrency works

1.6.1   What is a socket?

1.7      Understanding the asyncio event loop

1.8      Summary

sitemap