Grokking Concurrency in Python

Learn to choose, write, test and debug concurrent Python on current CPython: threads, processes, asyncio, structured concurrency, cancellation, the free-threaded build and subinterpreters, each measured on one running program.

Level:
Intermediate
Study Time:
20h
Lessons:
85
Assessments:
155
Updated
Today
4.5
(39 ratings)
331 learners
Arslan Ahmad
Created byArslan Ahmad
Ex FAANG Manager, Expert Behind Grokking Concurrency in Python

Course Overview

Python offers several ways to do more than one thing at a time. You can use threads, processes, asyncio, the free-threaded build or subinterpreters. The right choice depends on two things: whether your program mostly waits or mostly computes, and what the GIL allows on the build you run. This course teaches every model on one program, a web crawler and search indexer called Harvest. Harvest starts as a sequential script and grows into a concurrent service. Fetching pages is waiting work and indexing them is computing work, so one program shows where each model helps and where it does not. Along the way you learn thread pools, locks and queues, process start methods, the asyncio event loop, TaskGroup, cancellation, deadlines and backpressure. Each lesson measures what its mechanism does to Harvest. It then shows how that mechanism fails in a running service, the symptom you would see, and the check that confirms the cause. Later chapters cover testing concurrent code, diagnosing problems in production, graceful shutdown and sizing a service for its machine. Each lesson names the machine that produced its output, and every result comes from a real run on Python 3.15.2. The course is for engineers who already know Python and need a program to handle more work at once. It also prepares you to defend those design choices with numbers in a code review or an interview.

Grokking Concurrency in Python Image
This course
Lifetime access to this course
One-time payment. Yours forever.
All 70 courses
Annual plan
Discussions
Certificate
Free updates
Own everything, once
Grokking Concurrency in Python Image
This course
Lifetime access to this course
One-time payment. Yours forever.
All 70 courses
Annual plan
Discussions
Certificate
Free updates
Own everything, once

What you'll learn in Grokking Concurrency in Python

  • Tell IO bound work from CPU bound work, size a worker pool for each, and confirm the choice by measuring
  • Find race conditions in threaded code and fix them with locks, a fixed lock order, events and queues
  • Choose a process start method, keep pickling costs low, and avoid hangs after fork in worker processes
  • Group tasks with TaskGroup so one failure cancels the rest, and handle every error with except*
  • Bound concurrency, rate limit requests per site, retry with jitter, and stream data with constant memory use
  • Measure the free-threaded build, find its new data races, audit dependencies, and plan a migration
  • Force races to happen on demand in tests, test timeouts without waiting, and stress code until rare races appear
  • Explain what the GIL protects, when CPython releases it, and why a race can still happen while it is on
  • Use thread and process pools, collect results and errors, and shut a pool down without losing work
  • Build a small event loop from generators, then use asyncio tasks without losing any of them
  • Cancel work, set one deadline across a chain of calls, and write cleanup code that still runs
  • Call blocking code from async code, and async code from sync code, without stalling the event loop
  • Run code in subinterpreters and choose between asyncio, threads, processes and interpreters by measurement
  • Diagnose a blocked event loop, a stuck task, a deadlock, a leak and GIL contention in a running service

Course Content

• 17 Chapters • 85 Lessons
1.

Introduction

1 lesson

Course Introduction

Concurrency and Parallelism in Python

IO Bound and CPU Bound Work

What the GIL Protects

When the GIL Is Released

The Four Models and How to Size Them

Quiz: How CPython Runs Concurrent Code

What people say about our courses

Ashley Pean avatar
Ashley Pean
Software Engineer
Check out Grokking the Coding Interview. Instead of trying out random Algos, they break down the patterns you need to solve them. Helps immensely with retention!
Eric avatar
Eric
Software Engineer
I've completed my first pass of "grokking the System Design Interview" and I can say this was an excellent use of money and time. I've grown as a developer and now know the secrets of how to build these really giant internet systems.
Simon Barker avatar
Simon Barker
Software Engineer
This is what I love about http://designgurus.io’s Grokking the coding interview course. They teach patterns rather than solutions.
Steven Zhang avatar
Steven Zhang
Software Engineer
Just wanted to say thanks for your Grokking the system design interview resource (https://lnkd.in/g4Wii9r7) - it helped me immensely when I was interviewing from Tableau (very little system design exp) and helped me land 18 FAANG+ jobs!
Roger Cruz avatar
Roger Cruz
Software Engineer
The world gets better inch by inch when you help someone else. If you haven't tried Grokking The Coding Interview, check it out, it's a great resource!
Arijeet avatar
Arijeet
Software Engineer
Just completed the “Grokking the system design interview”. It's amazing and super informative. Have come across very few courses that are as good as this!

About the Author

Arslan Ahmad

Arslan Ahmad

Design Gurus Founder
Ex-FAANG Manager
Meta
Microsoft
Google
Amazon
Uber

Industry Expertise & Leadership

Arslan Ahmad is the lead author of Grokking Concurrency in Python. As the founder of Design Gurus and a former FAANG hiring manager, he has worked at industry giants like Facebook (now Meta) and Microsoft.

He has conducted hundreds of system design interviews, giving him unique insight into what top tech companies look for in candidates.

The course also incorporates expertise from senior engineers at Google, Meta, Amazon, Microsoft, and Uber, ensuring you learn system design best practices from professionals who have built and scaled real-world systems.

500+

Interviews Conducted

10k+

Students Taught

Related Courses

Grokking Multithreading and Concurrency for Coding Interviews
Master multithreading and concurrency with practical examples to tackle race conditions, deadlocks, and coding interview challenges effectively.
3.8
2.1K learners
Discounted price for Your Region

$98

Grokking Advanced Python
Learn the Python that larger programs depend on: error handling, classes, generators, files, threads, and networking.
4.7
386 learners
Discounted price for Your Region

$48

New
Grokking Concurrency in Go
Learn to write concurrent Go programs that are correct, fast, and easy to debug. The course covers goroutines, channels, select, the sync and context packages, atomics and the memory model, the standard concurrency patterns, flow control, testing, and the Go scheduler, with runnable Go 1.27 programs throughout.
4.4
559 learners
Discounted price for Your Region

$48

FAQs

Engineers who write Python at work and have used threads or async at least once, even if the result surprised them: a request that blocked a whole service, a process pool that hung on exit, or a test that failed one time in fifty. By the end you can choose a concurrency model for a workload and support the choice with a measurement.

You should be comfortable writing Python functions, classes and modules, and you should have run some code with threads or asyncio. You do not need to have used them well. The course builds the model of CPython that every later choice depends on before it uses any concurrency tool.

Every output in the course comes from Python 3.15.2, on both the standard build with the GIL and the free-threaded build without it. Python 3.14 is the baseline, and where a feature needs a newer version or a particular build, the lesson says so where the feature appears.

Harvest is a small web crawler and search indexer that the course builds one piece at a time. Fetching a page is mostly waiting, and indexing a page keeps a CPU busy, so the one program shows where threads and asyncio help and where only parallel execution does. It crawls a test site on the same machine that answers after a fixed delay, so every timing can be repeated and explained.

Yes. Every program in the course ran, and each lesson shows the code next to the exact output it printed, with every timing in the text taken from that output. Each lesson names its machine: a Windows desktop with an 8 core AMD Ryzen 7 5800X for parallel work, or a Linux virtual machine for start methods, signals and production diagnostic tools.

That is the main goal of the course. The first chapter explains the four models and how to size each one, and a later chapter gives a decision framework and then measures asyncio against threads for IO bound work and compares four options for CPU bound work on both builds of CPython.

Yes, in depth. You measure how the free-threaded build scales and what a single thread pays for it, find the data races that the GIL used to hide, audit compiled dependencies, run asyncio on it, and plan a migration with a way back. You also run code in subinterpreters with InterpreterPoolExecutor and see what crosses between them.

Where they matter in practice. It compares TaskGroup with the nurseries and cancel scopes of Trio and AnyIO, tests async code with pytest-asyncio, profiles with py-spy, measures the thread pool behind def endpoints in FastAPI and Starlette, and explains what ThreadSanitizer finds in compiled extensions.

Yes. You make races happen on demand with a barrier, test deadlines and rate limits with virtual time instead of real waiting, and stress code until rare races appear. You then find a blocked event loop, a stuck task, a deadlock, a leak and GIL contention in a running process with the tools that production servers use.

Every lesson closes with Key Takeaways and practice questions with folded answers. Each chapter before the capstone ends with a quiz that draws a fresh set of questions from a larger bank on every attempt, and the course ends with a capstone that runs failure drills on the finished Harvest, practice problems, and a final exam that covers every chapter.

The Practice Problems chapter builds a blocking queue, a read-write lock, a rate limiter shared by threads and a concurrent web crawler, which are common interview problems. The rest of the course is written for production work. For interview preparation, Grokking Multithreading and Concurrency for Coding Interviews is the better fit.

The two courses share an approach but not a runtime. Go schedules goroutines across all cores from the start, while CPython adds the GIL, separate processes, an event loop, a free-threaded build and subinterpreters, and most of this course is about choosing among them and measuring the result.

Design Gurus logo
One-Stop Portal For Tech Interviews.
About Us
Our Team
Careers
Partners
Contact Us
Become Affiliate
Copyright © 2026 Design Gurus, LLC. All rights reserved.