All jobs / Automation developer
Automation developer interview question · 3–5 years
One synchronous database call inside an async handler makes the whole service slow. Why?
The strongest answer
A blocking call stops the event loop, so no other coroutine can run until it returns — use an async driver, or push it to a thread with asyncio.to_thread
Why it works
Right. One blocking call in an async service is an outage waiting for load.
What a good answer covers
- Blocking code freezes the whole event loop.
- Use async drivers end to end.
- asyncio.to_thread for unavoidable blocking calls.
- One offender starves every other coroutine.
Answers that fall short
- Close, but not the strongest: Because async functions are slower than sync ones by nature
Async is not inherently slower; blocking the loop is the problem. - Weak: Because the loop retries the coroutine on every tick
There is no retry loop. - Red flag: Because the database connection is not thread-safe
Thread safety is a different issue entirely.
Who gets asked this
- Backend developer
- Full-stack developer
- Automation developer
- DevOps / SRE / cloud
- Data analyst / BI
- Data engineer
- Data science / ML / AI
- AI engineer
More Automation developer questions
- Three independent API calls run one after another in an async function. How do you overlap them?
- How do you compose several transformation stages over a huge stream without buffering?
- A Python service does heavy numeric work per request and latency is unacceptable. What options do you weigh?
- Under load your async service exhausts database connections. What went wrong?
- What is a decorator, really?
- You need setup and guaranteed teardown around a block. What do you write?
- Can you rely on a dict keeping insertion order?