0

So I've got this Django application (more specifically, Django Rest Framework) up there on Google's app engine. Mostly it works fine, except once in a while, I hit a strange delay (from 4-5s to 10-20 seconds...) This delay happens while authenticating the user and before I hit the view itself. I have already crossed out two theories :

So if it's not related to GAE's architecture and not limited by RPC... what's happening? I've plugged in cProfile and here's what it can tells us (I wrapped cProfile around the wsgi handler) :cProfile sample inside the console backend for GAE

Please note the line in the middle : around 10000 "len" calls. This same profiling report is devoid of such a line, usually. Only these requests with this absurd delay contains these 10000s of "len" calls.

This might indicate a very long query to Cloud SQL, but as I've said beforehand, the queries logged happens after. Or there is maybe a glitch in the SQL logging... Maybe.

Afrosimon
  • 285
  • 1
  • 4
  • 14
  • I suspect this is either 1) bad logging or 2) connection delays. Maybe it's trying to check/retry a connection 1000 times and that's done using `len`? That would explain both the delay (connection timing out) and the strange `len` calls in those cases. – Kevin Brown-Silva Jul 18 '15 at 00:35
  • I believe Django's auth hashes passwords 24000 times to be intentionally slow. Could this be related? – FlipperPA Jul 18 '15 at 03:19
  • I should have also mentioned: Django Debug Toolbar will help you easily find the bottleneck. https://github.com/django-debug-toolbar/django-debug-toolbar/blob/master/README.rst – FlipperPA Jul 18 '15 at 08:59
  • @FlipperPA - This app has a username / password auth as well as a token based auth. So no password hash-calculation in one mode of auth - and this issue happens with both types of auth. So I believe this is not related to any hashing-related latency. – Afrosimon Jul 20 '15 at 18:20
  • I can't help but feel this problem is very similar to this one : http://stackoverflow.com/questions/17970611/django-query-extremely-slow – Afrosimon Jul 20 '15 at 18:20

0 Answers0