Jorge Arévalo
Jorge Arévalo

Reputation: 2998

How many objects are created per request in this GAE app?

I'm developing a Google App Engine application with Python and Webapp2. For this question, the relevant parts are:

import webapp2

my_object = MyClass()

class MainPage(webapp2.RequestHandler):
  def get(self):
    # do stuff

app = webapp2.WSGIApplication([
    ('/', MainPage)
], debug=True)

So, every time my app is accesed, MainPage request handler takes care of the request. Let's assume there are 100 users using the app at a given moment. My questions are:

Upvotes: 2

Views: 72

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1121346

On the Google App Engine, count on 100 instances of both MainPage() and MyClass being created; each user visiting your site potentially is routed to a different machine in the vast Google cloud.

Run locally, MyClass will be instantiated once per process; some WSGI servers run multiple procsses (forking) to handle incoming requests. A MainPage itstance is created for each incoming request (so 100 times).

Upvotes: 3

Related Questions