-1

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.

Kai Aeberli
  • 1,189
  • 8
  • 21
  • Django debug toolbar? – Rambarun Komaljeet May 12 '18 at 14:16
  • I managed to run a profile using Django-extensions runprofileserver and checked the .prof files. It seems most of the time is taken by connections to the backend db - postgres. This seems to be a known issue for Django: https://stackoverflow.com/questions/1125504/django-persistent-database-connection – Kai Aeberli May 12 '18 at 15:11
  • after some more investigation, there is an option in Django you can set: CONN_MAX_AGE that is supposed to make connections persist, but for some reason has no effect. – Kai Aeberli May 12 '18 at 17:56
  • maybe its because i am running the python development server: https://stackoverflow.com/questions/41816570/how-does-conn-max-age-work-in-django – Kai Aeberli May 12 '18 at 18:04

1 Answers1

1

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.

Kai Aeberli
  • 1,189
  • 8
  • 21