Python web frameworks like Django and Flask handle multiple simultaneous requests through concurrency instead of parallelism.
This means they use a single thread and asynchronous I/O to juggle multiple requests, rather than multiple threads/processes. Here's how it works under the hood:
async def handle_request(request):
response = # do something with request
async def main():
The advantage over multi-threading is avoiding lock contention and simplified code. The tradeoff is CPU-bound tasks still execute sequentially. But most web workloads tend to be I/O heavy anyway.