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:
- How many
webapp2.WSGIApplicationinstances are created? Just 1? 100? (If I understood WSGI, I think that just 1) - How many
MyClassinstances are created?
On the Google App Engine, count on 100 instances of both
MainPage()andMyClassbeing created; each user visiting your site potentially is routed to a different machine in the vast Google cloud.Run locally,
MyClasswill be instantiated once per process; some WSGI servers run multiple procsses (forking) to handle incoming requests. AMainPageitstance is created for each incoming request (so 100 times).