Python · Concurrency · Under the hood Understanding Asyncio Internals: How Python Manages State Without Threads Published 28 Apr 2026 · ~10 min read · PyVerse · ByteForge A common question from developers diving into async Python: “When an async function hits await , how does it pick up later with all its variables intact?” Let’s pop the hood – no fluff, just how it actually works under the hood. asyncio coroutines event loop Python concurrency TL;DR An async def function is a stateful coroutine object , not a regular function. When you await , the coroutine pauses , saves its locals + instruction pointer, and yields control to the event loop. The event loop runs other tasks while I/O happens, then resumes the coroutine from the exact same line. Key components: coroutine (state machine), task (scheduling wrapper), future (promise of a result), event loop (the traffic cop). As...
Long read · Systems · Python PostgreSQL Connection Pooling, FastAPI, and Why More Connections Made Everything Worse Published 9 Apr 2026 · ~12 min read · PyVerse (Anupam Dutta) · ByteForge This is a production-focused walkthrough: how connection pools actually multiply with workers, what each TCP + Postgres connection costs, when PgBouncer and NullPool make sense, and how to right-size pool_size / max_overflow so you stop outliving max_connections under real traffic. PostgreSQL FastAPI asyncpg SQLAlchemy SQLAlchemy 2.0 Performance TL;DR Each app worker (e.g. Uvicorn) typically owns its own pool → total open connections = workers × (pool_size + max_overflow) in the worst case. Opening a new DB connection is not free: TCP/TLS, auth, and backend process memory add latency and RAM; unbounded pools amplify that under load. “Turn everything up” without checking ...