SlideShare a Scribd company logo
App Engine
Development
Ron Reiter, 2012
Agenda
●   What is Google App Engine
●   Advantages
●   Disadvantages
●   Creating your first webapp
●   Deployment
●   Features
●   Reducing Cost
What is GAE
● Google App Engine is a Platform-as-a-
  service server for web applications
● Similar to Heroku, but writing atop it
  requires using specific Google APIs
● Supports Python, Java and Go
Advantages
● Scales automatically
● Bills by services used
● Easy to deploy
● Extremely high uptime of all services (web
  server, database, cronjobs, mail delivery,
  etc)
● Free development tier
Disadvantages
● Cannot use native libraries with Python
● Cannot use different runtime
  environments, such as PyPy (yet).
● Constrained to Google because code is
  Google specific
● 30 second limit per request
● No websockets for now
● High price because of PaaS
Your first Web Application
● Download the Google App Engine Python
  SDK
● Add a new application
● Click "Run"
● Go to
  http://localhost:8080
● And you're done!
Your first Web Application
● The code example contains two important
  files:
  ○ main.py - the web server code example
  ○ app.yaml - the web application configuration
● It also contains a favicon example and a
  file called index.yaml, which you don't
  need to touch right now.
app.yaml
● The default app.yaml configuration is to
  forward all requests to main.py
● We will need to add a static files path, if we
  want App Engine to serve some static files.

- url: /static
  static_dir: static
Deployment
● Go to http://appengine.google.com
● If you haven't yet verified your account
  using your mobile phone, please do so
● Add a new application and find an
  available identifier for it
● Once you've created it, change your app.
  yaml file to use the same identifier
● Using your Google credentials, Use the
  App Engine launcher to deploy
Deployment (cont.)
● After deploying, use the GAE dashboard
  for datastore access, logs, quota details,
  load, and more.
main.py
import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write("Hello world!")

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)
Templates
from google.appengine.ext.webapp import template
import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write(template.render("index.html", {
            "message" : "Hello, World!"
        })

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)
GET/POST Parameters
from google.appengine.ext.webapp import template
import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write(template.render("index.html", {
            "message" : self.request.get("message")
        })

app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)
URL Parameters
from google.appengine.ext.webapp import template
import webapp2

class MainHandler(webapp2.RequestHandler):
    def get(self, message):
        self.response.write(template.render("index.html", {
            "message" : message
        })

app = webapp2.WSGIApplication([
    ('/(w+)', MainHandler)
], debug=True)
Datastore API
● NoSQL Database (BigTable)
● Supports an SQL-like syntax called GQL
    ○   GqlQuery("SELECT * FROM Song WHERE composer = :
        composer", composer="Lennon, John")

●   Scales Automatically
●   Django-like ORM (db.Model)
●   Map Reduce API
●   Expando - schema-less objects
The Model Class
from google.appengine.ext import db

class Post(db.Model):
    name = db.StringProperty()
    body = db.TextProperty()
    created = db.DateTimeProperty(auto_now_add=True)

# create a new entry
post = Post(
  name = "Ron Reiter",
  body = "This is a guestbook entry!"
)

# save it to the database
post.put()
The Model Class (cont.)
# get the post key
post_id = post.key().id()

# using the class method to fetch the object using the ID
post = Post.get_by_id(post_id)

# update the entry
post.body = "This is the updated body"
post.put()
NDB API
● An alternative to the Datastore API
● Document oriented instead of column
  oriented
● Schema-less
● Can run map reduce queries on structured
  properties, like MongoDB
NDB API (cont.)
class Address(ndb.Model):
  type = ndb.StringProperty() # E.g., 'home', 'work'
  street = ndb.StringProperty()
  city = ndb.StringProperty()

class Contact(ndb.Model):
  name = ndb.StringProperty()
  addresses = ndb.StructuredProperty(Address, repeated=True)

guido = Contact(name='Guido',
                addresses=[Address(type='home',
                                   city='Amsterdam'),
                           Address(type='work',
                                   street='Spear St',
                                   city='SF')])
guido.put()
Cloud Storage API
● Cloud Storage is similar to Amazon S3
● Integrates very well with App Engine

with files.open('/gs/mybucket/myobject/', 'r') as f:
  data = f.read(1)
  while data != "":
    print data
    data = f.read(1)
  print 'Done reading file!'
Python Service APIs
● BlobStore API - Allows saving and
  retrieving binary data from the datastore
● Channel API - Gives server push
  capabilities using long polling
● Memcache API - fast key/value store
● LogService API - Convenient logging
● Mail API - Simple email delivery
● Inbound mail handler - Use request
  handlers to handle emails sent to the app
Python Service APIs
● Search API - Powerful datastore search
● Task Queues API - Allows queueing
  request handlers to process data in the
  background
● Cron jobs - Allows scheduling request
  handlers to be executed
● Image API - Simple image processing
  module, based on PIL
Python Service APIs
● URLFetch API - Alternative to urllib, use it
  instead, also with asynchronous bindings
● Users API - Easy integration for user
  authentication using Google accounts
● And more...
Reducing Cost of GAE App
● Use Go (compiled) instead of Python for
  CPU intensive applications
● Use Asynchronous APIs to prevent
  spawning new handlers for no reason
● Use memcache whenever possible
● Reduce DataStore calls
● Use cache headers
Questions?
Thank You!

More Related Content

PDF
jQuery Mobile Workshop
PDF
Multi screen HTML5
PDF
AppEngine Performance Tuning
PDF
Gae Meets Django
PDF
Laravel 8 export data as excel file with example
PDF
React vs-angular-mobile
PPTX
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
PPT
Grails Connecting to MySQL
jQuery Mobile Workshop
Multi screen HTML5
AppEngine Performance Tuning
Gae Meets Django
Laravel 8 export data as excel file with example
React vs-angular-mobile
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Grails Connecting to MySQL

What's hot (20)

PDF
Integrating React.js Into a PHP Application
PDF
AngularJS Deep Dives (NYC GDG Apr 2013)
KEY
I18n
PDF
jQuery - Chapter 1 - Introduction
PDF
Python for AngularJS
PDF
Developing iOS REST Applications
PDF
React && React Native workshop
PDF
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
PDF
Introduction to react
PDF
The Complementarity of React and Web Components
PDF
Mezzanine簡介 (at) Taichung.py
PDF
Unobtrusive JavaScript
PPTX
Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...
PPTX
React / Redux Architectures
PPTX
IndexedDB and Push Notifications in Progressive Web Apps
PPTX
Tips for Angular Applications
PDF
Django Overview
PPTX
A Brief Introduction to React.js
PPTX
Lets go vanilla
PDF
JS Chicago Meetup 2/23/16 - Redux & Routes
Integrating React.js Into a PHP Application
AngularJS Deep Dives (NYC GDG Apr 2013)
I18n
jQuery - Chapter 1 - Introduction
Python for AngularJS
Developing iOS REST Applications
React && React Native workshop
Ajax on drupal the right way - DrupalCamp Campinas, São Paulo, Brazil 2016
Introduction to react
The Complementarity of React and Web Components
Mezzanine簡介 (at) Taichung.py
Unobtrusive JavaScript
Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...
React / Redux Architectures
IndexedDB and Push Notifications in Progressive Web Apps
Tips for Angular Applications
Django Overview
A Brief Introduction to React.js
Lets go vanilla
JS Chicago Meetup 2/23/16 - Redux & Routes
Ad

Similar to Introduction to App Engine Development (20)

PDF
Google app-engine-with-python
PDF
Web App Prototypes with Google App Engine
PDF
Accessing Google Cloud APIs
PDF
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
PDF
Parse cloud code
PDF
Modern Web Applications Utilizing HTML5 APIs
PPTX
Google App Engine for Python - Unit01: Basic
PDF
Utilizing HTML5 APIs
PDF
Exploring Google (Cloud) APIs with Python & JavaScript
PDF
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
PDF
Introduction to Google App Engine
PDF
Introduction to Google Cloud Endpoints: Speed Up Your API Development
PDF
Powerful Google developer tools for immediate impact! (2023-24 A)
PDF
Introduction to serverless computing on Google Cloud
PDF
Google App Engine Overview - BarCamp Phnom Penh 2011
PDF
Using Google (Cloud) APIs
PDF
Build Android App using GCE & GAE
PDF
App Engine On Air: Munich
PPT
Google App Engine for Java
PDF
Introduction to Cloud Computing with Google Cloud
Google app-engine-with-python
Web App Prototypes with Google App Engine
Accessing Google Cloud APIs
Modern Web Applications Utilizing HTML5 (Dev Con TLV 06-2013)
Parse cloud code
Modern Web Applications Utilizing HTML5 APIs
Google App Engine for Python - Unit01: Basic
Utilizing HTML5 APIs
Exploring Google (Cloud) APIs with Python & JavaScript
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Introduction to Google App Engine
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Powerful Google developer tools for immediate impact! (2023-24 A)
Introduction to serverless computing on Google Cloud
Google App Engine Overview - BarCamp Phnom Penh 2011
Using Google (Cloud) APIs
Build Android App using GCE & GAE
App Engine On Air: Munich
Google App Engine for Java
Introduction to Cloud Computing with Google Cloud
Ad

More from Ron Reiter (9)

PDF
Securing your Bitcoin wallet
PDF
Brogramming - Python, Bash for Data Processing, and Git
PDF
BDX 2015 - Scaling out big-data computation & machine learning using Pig, Pyt...
PDF
Introduction to Bootstrap
PDF
Mobile Spaces
PDF
Building Chrome Extensions
PDF
HTML5 New Features and Resources
PPTX
Digital Audio & Signal Processing (Elad Gariany)
PPTX
Writing HTML5 Web Apps using Backbone.js and GAE
Securing your Bitcoin wallet
Brogramming - Python, Bash for Data Processing, and Git
BDX 2015 - Scaling out big-data computation & machine learning using Pig, Pyt...
Introduction to Bootstrap
Mobile Spaces
Building Chrome Extensions
HTML5 New Features and Resources
Digital Audio & Signal Processing (Elad Gariany)
Writing HTML5 Web Apps using Backbone.js and GAE

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
Teaching material agriculture food technology
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PPTX
Big Data Technologies - Introduction.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Network Security Unit 5.pdf for BCA BBA.
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
Building Integrated photovoltaic BIPV_UPV.pdf
Empathic Computing: Creating Shared Understanding
Chapter 3 Spatial Domain Image Processing.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
Teaching material agriculture food technology
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
Big Data Technologies - Introduction.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Introduction to App Engine Development

  • 2. Agenda ● What is Google App Engine ● Advantages ● Disadvantages ● Creating your first webapp ● Deployment ● Features ● Reducing Cost
  • 3. What is GAE ● Google App Engine is a Platform-as-a- service server for web applications ● Similar to Heroku, but writing atop it requires using specific Google APIs ● Supports Python, Java and Go
  • 4. Advantages ● Scales automatically ● Bills by services used ● Easy to deploy ● Extremely high uptime of all services (web server, database, cronjobs, mail delivery, etc) ● Free development tier
  • 5. Disadvantages ● Cannot use native libraries with Python ● Cannot use different runtime environments, such as PyPy (yet). ● Constrained to Google because code is Google specific ● 30 second limit per request ● No websockets for now ● High price because of PaaS
  • 6. Your first Web Application ● Download the Google App Engine Python SDK ● Add a new application ● Click "Run" ● Go to http://localhost:8080 ● And you're done!
  • 7. Your first Web Application ● The code example contains two important files: ○ main.py - the web server code example ○ app.yaml - the web application configuration ● It also contains a favicon example and a file called index.yaml, which you don't need to touch right now.
  • 8. app.yaml ● The default app.yaml configuration is to forward all requests to main.py ● We will need to add a static files path, if we want App Engine to serve some static files. - url: /static static_dir: static
  • 9. Deployment ● Go to http://appengine.google.com ● If you haven't yet verified your account using your mobile phone, please do so ● Add a new application and find an available identifier for it ● Once you've created it, change your app. yaml file to use the same identifier ● Using your Google credentials, Use the App Engine launcher to deploy
  • 10. Deployment (cont.) ● After deploying, use the GAE dashboard for datastore access, logs, quota details, load, and more.
  • 11. main.py import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write("Hello world!") app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
  • 12. Templates from google.appengine.ext.webapp import template import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write(template.render("index.html", { "message" : "Hello, World!" }) app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
  • 13. GET/POST Parameters from google.appengine.ext.webapp import template import webapp2 class MainHandler(webapp2.RequestHandler): def get(self): self.response.write(template.render("index.html", { "message" : self.request.get("message") }) app = webapp2.WSGIApplication([ ('/', MainHandler) ], debug=True)
  • 14. URL Parameters from google.appengine.ext.webapp import template import webapp2 class MainHandler(webapp2.RequestHandler): def get(self, message): self.response.write(template.render("index.html", { "message" : message }) app = webapp2.WSGIApplication([ ('/(w+)', MainHandler) ], debug=True)
  • 15. Datastore API ● NoSQL Database (BigTable) ● Supports an SQL-like syntax called GQL ○ GqlQuery("SELECT * FROM Song WHERE composer = : composer", composer="Lennon, John") ● Scales Automatically ● Django-like ORM (db.Model) ● Map Reduce API ● Expando - schema-less objects
  • 16. The Model Class from google.appengine.ext import db class Post(db.Model): name = db.StringProperty() body = db.TextProperty() created = db.DateTimeProperty(auto_now_add=True) # create a new entry post = Post( name = "Ron Reiter", body = "This is a guestbook entry!" ) # save it to the database post.put()
  • 17. The Model Class (cont.) # get the post key post_id = post.key().id() # using the class method to fetch the object using the ID post = Post.get_by_id(post_id) # update the entry post.body = "This is the updated body" post.put()
  • 18. NDB API ● An alternative to the Datastore API ● Document oriented instead of column oriented ● Schema-less ● Can run map reduce queries on structured properties, like MongoDB
  • 19. NDB API (cont.) class Address(ndb.Model): type = ndb.StringProperty() # E.g., 'home', 'work' street = ndb.StringProperty() city = ndb.StringProperty() class Contact(ndb.Model): name = ndb.StringProperty() addresses = ndb.StructuredProperty(Address, repeated=True) guido = Contact(name='Guido', addresses=[Address(type='home', city='Amsterdam'), Address(type='work', street='Spear St', city='SF')]) guido.put()
  • 20. Cloud Storage API ● Cloud Storage is similar to Amazon S3 ● Integrates very well with App Engine with files.open('/gs/mybucket/myobject/', 'r') as f: data = f.read(1) while data != "": print data data = f.read(1) print 'Done reading file!'
  • 21. Python Service APIs ● BlobStore API - Allows saving and retrieving binary data from the datastore ● Channel API - Gives server push capabilities using long polling ● Memcache API - fast key/value store ● LogService API - Convenient logging ● Mail API - Simple email delivery ● Inbound mail handler - Use request handlers to handle emails sent to the app
  • 22. Python Service APIs ● Search API - Powerful datastore search ● Task Queues API - Allows queueing request handlers to process data in the background ● Cron jobs - Allows scheduling request handlers to be executed ● Image API - Simple image processing module, based on PIL
  • 23. Python Service APIs ● URLFetch API - Alternative to urllib, use it instead, also with asynchronous bindings ● Users API - Easy integration for user authentication using Google accounts ● And more...
  • 24. Reducing Cost of GAE App ● Use Go (compiled) instead of Python for CPU intensive applications ● Use Asynchronous APIs to prevent spawning new handlers for no reason ● Use memcache whenever possible ● Reduce DataStore calls ● Use cache headers