PyCon India 2010 Building Scalable apps using appengine

1,217 views

Published on

http://in.pycon.org/2010/talks/5
The talk will is primarily designed for users who have some web programming experience in one or more frameworks. It will show an insight of AppEngine, how to create a basic app and how to scale apps with AppEngine's Cloud environment and BigTable storage. Primary focus of the talk will remain on scalability with necessary inputs from other dimensions as well.

Published in: Technology
  • Be the first to like this

PyCon India 2010 Building Scalable apps using appengine

  1. 1. Building Scalable Apps using Google App Engine Pranav Prakash bit.ly/scalableapps PyCon India 2010
  2. 2. Agenda <ul><ul><li>Scalabality </li></ul></ul><ul><ul><li>Introduction to Google App Engine </li></ul></ul><ul><ul><li>Hello World </li></ul></ul><ul><ul><li>App Engine DataStore </li></ul></ul><ul><ul><li>Cache </li></ul></ul><ul><ul><li>Scalability Revisited </li></ul></ul><ul><ul><li>Case Study </li></ul></ul><ul><ul><li>Q-n-A </li></ul></ul>
  3. 3. Scalability <ul><ul><li>Scaling Up </li></ul></ul><ul><ul><li>Scaling Out </li></ul></ul>
  4. 4. Google App Engine <ul><ul><li>Develop, Deploy web apps on Google's Infrastructure </li></ul></ul><ul><ul><li>Application Environment </li></ul></ul><ul><ul><li>Sandbox Environment </li></ul></ul><ul><ul><li>Runtime Environment </li></ul></ul><ul><ul><ul><li>Python </li></ul></ul></ul><ul><ul><ul><li>Java </li></ul></ul></ul><ul><ul><li>DataStore </li></ul></ul><ul><ul><li>Google Accounts </li></ul></ul><ul><ul><li>Services </li></ul></ul><ul><ul><li>Cron Jobs and Task Queues </li></ul></ul>
  5. 5. Hello World :) from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainPage(webapp.RequestHandler): def get(self):    self.response.headers[' Content-Type '] = ' text/plain '    self.response.out.write(' Hello, webapp World! ') application = webapp.WSGIApplication(                                          [(' / ', MainPage)],                                          debug= True ) def main():    run_wsgi_app(application) if __name__ == &quot; __main__ &quot;:    main()
  6. 6. app.yaml application : helloworld version : 1 runtime : python api_version : 1 handlers : - url : /.*    script : helloworld.py
  7. 7. App Engine Datastore <ul><ul><li>Scalable data storage for your applications </li></ul></ul><ul><ul><li>Write once, read many </li></ul></ul><ul><ul><li>Stores data entities with properties, organised by application defined Kinds </li></ul></ul><ul><ul><li>Queries on entities of same kind </li></ul></ul><ul><ul><li>Filter and sort order on property values and keys </li></ul></ul><ul><ul><li>Pre-Indexing </li></ul></ul>
  8. 8. Entities and Models <ul><ul><li>Datastore Entity = key + set(attributes) </li></ul></ul><ul><ul><li>Models describe the kind of data an app uses </li></ul></ul>from google.appengine.ext import db import datetime class Person(db.Model):    name = db.StringProperty(required= True )     birthdate = db.DateProperty()    height = db.IntegerProperty()    is_admin = db.BooleanProperty(default= False ) ted = Person(key_name='person_ted',                      name=' Ted ',                      birthdate=datetime.datetime(1986,12,04),                      height = 185) db.put(ted)
  9. 9. Entity Groups, Ancestors and Path <ul><ul><li>Entities residing in same part of the distributed network </li></ul></ul><ul><ul><li>Transactions </li></ul></ul><ul><ul><li>Parent Child relationship </li></ul></ul><ul><ul><li>Path and Key uniqueness </li></ul></ul>
  10. 10. Fetching Entities <ul><ul><li>GQL </li></ul></ul><ul><ul><li>GqlQuery </li></ul></ul><ul><ul><li>Query </li></ul></ul><ul><ul><li>db.get() </li></ul></ul>all_teds = Person.gql( “ WHERE name = :1 ” , “ Ted ” ).fetch(100) all_teds_1 = GqlQuery( “ SELECT * FROM Person WHERE name = :1 ” , “ Ted ” ).fetch(100) all_teds = Person.all().filter( “ name = “ , “ Ted ” ).fetch(100) specific_ted = Person.get_by_key_name(' person_ted ') specific_teds_key = db.Key(' Person ', ' person_ted ') specfic_ted_1 = db.get(specific_ted_key)
  11. 11. Cache <ul><ul><li>Memcache </li></ul></ul><ul><ul><li>App Caching </li></ul></ul>
  12. 12. Scalability Revisited <ul><ul><li>Read and Write Infrequently </li></ul></ul><ul><ul><li>Keys, Key Names, ID </li></ul></ul><ul><ul><li>Batch Reads and Writes </li></ul></ul><ul><ul><li>Small Entity Groups </li></ul></ul><ul><ul><li>Sharding </li></ul></ul><ul><ul><li>Memcache </li></ul></ul>
  13. 13. Case Study <ul><ul><li>Social apps and games from Oxylabs </li></ul></ul>
  14. 14. bit.ly/scalableapps pranny @ gmail.com

×