Django. Business Logic Bottlenecks.

Is there any smart way to find bottlenecks in business logic. For example, we have application, that have one view that doing HttpResponse('1') in big project. We are sure, that no SQL queries in middlewares exists. But HttpResponse working really slow(50 rps vs 200 rps on clear django project).

  1. What reasons can be?
  2. How to find bottlenecks in this case?
  3. Also we know, that in clear project less than 1 Mb of memory used for objects on each request, and in our project - more than 2Mb. How to find these objects?

Answers


The debug toolbar works well, but I also like running django-devserver. It can give you more information than you can process sometimes.

DEVSERVER_MODULES = (
    'devserver.modules.sql.SQLRealTimeModule',
    'devserver.modules.sql.SQLSummaryModule',
    'devserver.modules.profile.ProfileSummaryModule',

    # Modules not enabled by default
    'devserver.modules.ajax.AjaxDumpModule',
    #'devserver.modules.profile.MemoryUseModule',
    'devserver.modules.cache.CacheSummaryModule',
    #'devserver.modules.profile.LineProfilerModule',
)

This is what modules I have turned on, and one hit to the admin page after start:

Django version 1.3.1, using settings 'myproject.settings' Running django-devserver 0.3.1 Threaded django server is running at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK.
    [sql] SELECT ...
      FROM "auth_message"
      WHERE "auth_message"."user_id" = 1
    [sql] SELECT ...
      FROM "django_admin_log"
      INNER JOIN "auth_user" ON ("django_admin_log"."user_id" = "auth_user"."id")
      LEFT OUTER JOIN "django_content_type" ON ("django_admin_log"."content_typ_id" = "django_content_type"."id")
      WHERE "django_admin_log"."user_id" = 1
      ORDER BY "django_admin_log"."action_time" DESC LIMIT 10
    [sql] 4 queries with 0 duplicates
    [profile] Total time to render was 0.54s
    [cache] 0 calls made with a 100% hit percentage (0 misses) [30/Nov/2011 08:36:34] "GET /admin/ HTTP/1.1" 200 21667 (time: 0.69s; sql: 0ms (4q))
    [sql] SELECT ...
      FROM "django_flatpage"
      INNER JOIN "django_flatpage_sites" ON ("django_flatpage"."id" = "django_fatpage_sites"."flatpage_id")
      WHERE ("django_flatpage"."url" = /favicon.ico/
             AND "django_flatpage_sites"."site_id" = 1)
    [sql] 1 queries with 0 duplicates
    [profile] Total time to render was 0.02s
    [cache] 0 calls made with a 100% hit percentage (0 misses) [30/Nov/2011 08:36:34] "GET /favicon.ico/ HTTP/1.1" 404 2587 (time:
0.89s; sql: 0ms (1q))

Need Your Help

Character validation for each newLine

java

I'm trying to find a way to validate if each line being read from "srcFile" starts with an alpha character. I tried using the Character.isLetter() method but it complains about line being declared ...

Get BBM Chat Logs

blackberry bb-messenger

A Simple question for every one , is there any possible way to get Blackberry BBM Logs in application , via Programming.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.