PyCon India 2010 Building Scalable apps using appengine
-
Upload
pranav-prakash -
Category
Technology
-
view
924 -
download
0
description
Transcript of PyCon India 2010 Building Scalable apps using appengine
![Page 1: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/1.jpg)
Building Scalable Apps using Google App Engine
Pranav Prakash
bit.ly/scalableapps
PyCon India 2010
![Page 2: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/2.jpg)
Agenda
• Scalabality• Introduction to Google App Engine• Hello World• App Engine DataStore• Cache• Scalability Revisited• Case Study• Q-n-A
![Page 3: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/3.jpg)
Scalability
• Scaling Up• Scaling Out
![Page 4: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/4.jpg)
Google App Engine
• Develop, Deploy web apps on Google's Infrastructure
• Application Environment• Sandbox Environment• Runtime Environment
o Pythono Java
• DataStore• Google Accounts• Services• Cron Jobs and Task Queues
![Page 5: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/5.jpg)
Hello World :)
from google.appengine.ext import webappfrom 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__ == "__main__": main()
![Page 6: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/6.jpg)
app.yaml
application: helloworldversion: 1runtime: pythonapi_version: 1
handlers:- url: /.* script: helloworld.py
![Page 7: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/7.jpg)
App Engine Datastore
• Scalable data storage for your applications• Write once, read many• Stores data entities with properties, organised by
application defined Kinds• Queries on entities of same kind• Filter and sort order on property values and keys• Pre-Indexing
![Page 8: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/8.jpg)
Entities and Models
• Datastore Entity = key + set(attributes)• Models describe the kind of data an app uses
from google.appengine.ext import dbimport 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)
![Page 9: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/9.jpg)
Entity Groups, Ancestors and Path
• Entities residing in same part of the distributed network
• Transactions• Parent Child relationship• Path and Key uniqueness
![Page 10: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/10.jpg)
Fetching Entities
• GQL• GqlQuery• Query• db.get()
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)
![Page 11: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/11.jpg)
Cache
• Memcache• App Caching
![Page 12: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/12.jpg)
Scalability Revisited
• Read and Write Infrequently• Keys, Key Names, ID• Batch Reads and Writes• Small Entity Groups• Sharding• Memcache
![Page 13: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/13.jpg)
Case Study
• Social apps and games from Oxylabs
![Page 14: PyCon India 2010 Building Scalable apps using appengine](https://reader036.fdocuments.net/reader036/viewer/2022082916/54be8f454a79594c308b45a6/html5/thumbnails/14.jpg)
bit.ly/scalableapps
pranny @ gmail.com