Skip to content

Architecture & Patterns: Python + Async Foundations

Production Patterns

Architecture View

graph LR
  A[Task queue] --> B[Semaphore gate]
  B --> C[Async calls]
  C --> D[Retry and timeout]
  D --> E[Merged response]

Common Failure Modes

Common Failure Modes

  • Blocking libraries used inside async code paths.
  • Unbounded gather causing burst failures.
  • Retrying non-idempotent operations without safeguards.

Interview Q&A

Q: Interview Q: When do you increase concurrency vs add caching?

Increase concurrency when calls are independent and I/O-bound. Add caching when repeated reads dominate traffic and latency is already acceptable.

Q: Interview Q: How do you detect event-loop stalls in production?

Instrument per-step timing and inspect long-tail latency (`P95`/`P99`) by step. Blocking calls usually show up as long synchronous gaps.