Reputation: 2998
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:
webapp2.WSGIApplication
instances are created? Just 1? 100? (If I understood WSGI, I think that just 1)MyClass
instances are created? Upvotes: 2
Views: 72
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