Skip to content

Production Python · Async & Concurrency

Concurrent Python that survives real traffic

Diagnostics-first references on event loops, worker pools, network I/O, throttling, cancellation and resilience — written for engineers operating systems under real load, not tutorials.

Start with the fundamentals Diagnose a slow loop

This knowledge base focuses on the decisions and failure modes that surface after systems reach real traffic: event loop saturation, queue backpressure, upstream rate limits, cancellation bugs, shutdown races, and cross-runtime coordination between async tasks, threads and processes. Over two hundred pages across four sections, each one built from a specific production symptom rather than an API tour, and each number in them measured on real hardware rather than quoted.

Explore the library

Start here for a specific symptom

What you will get

  • Practical patterns for timeout, retry, cancellation, throttling and graceful shutdown behaviour.
  • Trade-off guidance for selecting asyncio, threads, processes, or hybrid models, with the arithmetic behind each choice.
  • Diagnostics-first examples for tracing starvation, deadlocks, contention, pool exhaustion and leaked resources.
  • Production-oriented references for I/O scaling, protocol design, connection reuse and throughput tuning.

Audience

  • Python engineers running web services, gateways, streaming systems and data pipelines.
  • Teams modernizing legacy concurrency stacks with minimal operational risk.
  • Developers who want architecture-level context and implementation-level examples in one place.

How to navigate the content

  • Use the four overview pages for mental models, boundaries, and system trade-offs.
  • Use the section overviews beneath them for the patterns and failure modes of one specific area.
  • Use the deep-dive articles for step-by-step implementation, verification steps and diagnostic hooks.
  • Follow the inline links across topics to connect a design choice to its operational behaviour.

New in this edition

  • Message Brokers & Event Streams — Kafka, RabbitMQ and Redis Streams consumers verified against live brokers, plus the transactional outbox that makes publishing atomic with the database write.
  • ASGI Servers & Frameworks — lifespan-owned resources, streaming that cut peak memory from 14.6 MiB to 0.9 MiB, and a uvicorn worker count derived from measurement.
  • gRPC & RPCgrpc.aio services, streaming calls, interceptors, and a deadline that propagated across a two-hop chain and cancelled the leaf.
  • Background Jobs & Task Queues — Celery, arq and taskiq compared on the same workload, and a Postgres job queue measured at 2,001 jobs per second.
  • Async Caching & Deduplication — stampede protection that took 50 origin calls to one, and a two-tier cache that served 22,000 reads with 50.
  • Observability & Tracing — loop lag, queue wait against service time, OpenTelemetry through contextvars, and logging that never blocks the loop.
  • Memory & Resource Leaks — four counters, four tools, and a watchdog that names the leaking line by itself.
  • AnyIO & Trio Interop — one pipeline running unchanged on asyncio and trio, with cancel scopes and memory object streams.

Suggested reading paths