Is there a performance gain from defining routes in app.yaml versus one large mapping in a WSGIAppli
Posted
by jgeewax
on Stack Overflow
See other posts from Stack Overflow
or by jgeewax
Published on 2010-06-11T20:15:42Z
Indexed on
2010/06/11
20:32 UTC
Read the original article
Hit count: 229
Scenario 1
This involves using one "gateway" route in app.yaml
and then choosing the RequestHandler
in the WSGIApplication
.
app.yaml
- url: /.*
script: main.py
main.py
from google.appengine.ext import webapp
class Page1(webapp.RequestHandler):
def get(self):
self.response.out.write("Page 1")
class Page2(webapp.RequestHandler):
def get(self):
self.response.out.write("Page 2")
application = webapp.WSGIApplication([
('/page1/', Page1),
('/page2/', Page2),
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
Scenario 2:
This involves defining two routes in app.yaml
and then two separate scripts for each (page1.py
and page2.py
).
app.yaml
- url: /page1/
script: page1.py
- url: /page2/
script: page2.py
page1.py
from google.appengine.ext import webapp
class Page1(webapp.RequestHandler):
def get(self):
self.response.out.write("Page 1")
application = webapp.WSGIApplication([
('/page1/', Page1),
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
page2.py
from google.appengine.ext import webapp
class Page2(webapp.RequestHandler):
def get(self):
self.response.out.write("Page 2")
application = webapp.WSGIApplication([
('/page2/', Page2),
], debug=True)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
Question
What are the benefits and drawbacks of each pattern? Is one much faster than the other?
© Stack Overflow or respective owner