Backend developer interview question · 3–5 years
A CPU-bound function is too slow. You add threads and nothing improves. Why?
The strongest answer
The GIL lets only one thread execute Python bytecode at a time, so threads help blocking I/O, not computation — use processes, a native library that releases the GIL, or move the work out of Python
Why it works
Exactly. Threads for waiting, processes for computing.
What a good answer covers
- The GIL serialises bytecode execution.
- Threads still win on I/O waits.
- multiprocessing for CPU-bound work.
- NumPy and friends release the GIL in C.
Answers that fall short
- Close, but not the strongest: Because the thread pool was too small; more threads would fix it
More threads contending for one lock makes it slower, not faster. - Weak: Because threads in Python are simulated and never actually run
They are real OS threads — they just take turns on the interpreter. - Red flag: Because CPython threads are only for GUI code
They are general purpose; the constraint is the interpreter lock.
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 Backend developer questions
- Under load the app stops responding, CPU is low and requests queue. What do you suspect?
- The business asks for a disaster recovery plan. What two numbers do you ask for first, and why?
- Two requests read a balance of 100, each subtracts 30, and the balance ends at 70. What happened and what…
- Your queue delivers at least once. What does that force on every consumer?
- A Spring service bean keeps the current user in a field so its helper methods can read it. Under load, users…
- You are designing a Python service that fans out to many slow downstreams. What shapes the design?
- Your service calls three internal APIs and one is intermittently slow. What do you build in?
- You are asked to make a payments service active in two regions. What is the first design question?