Is Django (especially Django Rest Framework) really synchronous?

I know some concepts that Django (DRF) is synchronous and it has some workers, but I know little about this.

I tried to verify this and created this view at the address http://localhost:8000/my-view/:

def my_view(request):
    # Simulate some time-consuming task
    time.sleep(10)
    return HttpResponse("Response after 10 seconds")

I proceeded to open 7 terminals and execute the same command on each of them within a range of 1-2 seconds (almost simultaneously):

curl http://localhost:8000/my-view/ -H 'Content-Type: application/json'

--> and the result was that in each terminal I received response in 10-12 seconds.

Here is the question, if Django is synchronous so why it did not take 70 seconds to execute these requests one by one?

The only explanation I can think of is that it uses multithreading.

Django is synchronous (except when it's not), but it doesn't have a concept of "some workers". The application server running the Django application might have a concept of workers of some sort.

The default runserver development server is indeed multi-threading.

Run with python manage.py runserver --nothreading --noreload for a single-process, single-thread development server.

Back to Top