首页 > 解决方案 > how to make django HttpResponse return faster than 1 second

问题描述

I am running Django on localhost using the Django development server. I have a view that just returns HttpResponse("hello world").

def simpleview(request):

    return HttpResponse("hello world")

I make a GET request with jquery to that view.

Looking in the browser, it shows that this takes 1.3 seconds to return which is very slow.

Is there any way to check what is going on? I am trying to use this for autocomplete, and a waiting time of 1.3 seconds for a virtually empty response is unusable.

标签: pythonajaxdjangodjango-rest-frameworkdjango-views

解决方案


When running on apache the latency issue went away, so it seems to be a problem with the python development server. In addition, i setup connection pooling to stop the reconnect on every request. This had no effect on the dev server though. The pooling was done by sqlalchemy pool for PostgreSQL.


推荐阅读