Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:32:07+00:00 2026-06-09T21:32:07+00:00

I have a Django application which I decided to port to Google App Engine.

  • 0

I have a Django application which I decided to port to Google App Engine.
I decided to use NDB as my database and have ported all the models (including django user). After one week of reading through the documentation (the App Engine documentation is awful, the examples given are often outdated and don’t work anymore) and porting the application, when I ran it it was really slow: 1s-2s latency with an empty database.
The ndb queries don’t take much time (less then 50 ms) and the Appstats application doesn’t show me anything else.
I decided to use cProfile and have created an wsgi middleware but I can’t figure out how to print the output. The methods pstats gives me either prints the output or saves it to file and I can’t do any inside the wsgi handler.
My code is as follows:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
from django.core.handlers import wsgi

from webob import Request
class AppProfiler(object):  
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):  
        from django.core.files.base import ContentFile 

        self.req = Request(environ)
        import cProfile, pstats
        prof = cProfile.Profile()
        prof = prof.runctx("self.get_resp()", globals(), locals())

        print "<pre>"
        stats = pstats.Stats(prof)
        #stats.dump_stats(output)
        stats.print_stats(80)
        print "</pre>"

        body = self.resp.body # here i should append the stats data
        self.resp.body = body

        return self.resp(environ, start_response)

    def get_resp(self):
        self.resp = self.req.get_response(self.app)

app = wsgi.WSGIHandler() 
profiler = AppProfiler(app)

How can I append the profiler stats to the body?
Or is there a better way to find out what is slowing down my application?
I’m using a lot of module imports in my django views is there an App Engine way to import modules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:32:09+00:00Added an answer on June 9, 2026 at 9:32 pm

    There’s already an awesome WSGI application that you can easily integrate in your project called google-app-engine-mini-profiler.

    gae_mini_profiler is a quick drop-in WSGI app that provides ubiquitous
    profiling of your existing GAE projects. It exposes both RPC
    statistics and standard profiling output for users of your choosing on
    your production site. Only requests coming from users of your choosing
    will be profiled, and others will not suffer any performance
    degradation.

    Please, have a look to this blog post by the author Ben Kamens or go straight to the repo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a App Engine/Python/Django application which has grown and been modified over the
HI I have a django application running on app engine and I want to
I have a Django application which edits a database table, which another application polls
I have a django application which talks to a database to which several other
I have a django application that uses an SQLite database. I use git to
I have a second database in my Django application, which is filled with static
I have a django application which has two models like this: class MyModel(models.Model): name
I would like to deplay a django application/project, which i have created within Aptana.
I have two models in my Django application, for the purposes of storing search
I have following models setup in my Django application class School(models.Model): name = models.TextField()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.