Your SlideShare is downloading. ×
0
App Engine 101

Ikai Lan
May 17th, 2010
Agenda
Topics we'll cover
 Why App Engine?
    Traditional web stack scalability
    App Engine to the rescue!
 Services a...
What is Google App Engine?
Google App Engine is...


                ... a way for you to run
                your web applications
                 ...
Start with... the basic LAMP stack


LAMP:
   Linux
   Apache
   MySql
   Programming Language
        (PHP, Python, Perl,...
Database on a separate server



Still not Scalable!


TWO Single Points of Failure




                                Go...
Multiple Web Servers




              Now you need Load Balancing

          Database is still Single Point of Failure

 ...
Round Robin Load Balancing




              Register list of IPs with DNS

     DNS record is cached with a Time to Live ...
Round Robin Load Balancing




But the TTL takes time to propagate and might not be respected

So if a machine goes down.....
Master Slave Database




:-) Better read throughput   :-( Master is SPOF for writes

                             :-( Mas...
Partitioned Database




:-) Better R/W throughput   :-( More machines, more management

                            :-( R...
Why build it all yourself?




                             Google Confidential and Proprietary
Why not use Google App Engine?




            Simple application configuration

              No systems administration

...
App Engine Developers/Apps




                             Google Confidential and Proprietary
Google Confidential and Proprietary
By the numbers

 Over 100,000 applications
 250,000 developers
 Over 250 million daily pageviews
Underneath the hood
App Engine Components



                                  Load balancing

                                  Routing




H...
App Engine Components

                        Hosts application code

                        Handles concurrent requests...
App Engine Services/APIs
Bigtable - The App Engine datastore



                           Distributed, partitioned datastore




Arbitrary horizon...
Memcache




                              Distributed, very fast,
                                in-memory cache




Opt...
URL Fetch




                          Simple, HTTP communication




HTTP GET/POST to external service

Allows integrati...
Mail




                        Inbound and outbound mail




Outbound mail

Inbound mail handling

Attachment processing...
XMPP




                       Instant messaging for your application




Incoming and outgoing XMPP

No need to worry ab...
Task Queue




                           Background and scheduled
                                 computation




Backgr...
Images




                     Image manipulation




Resize

Crop

Image compositions

                                 ...
Blobstore




                             Heavy lifting for large files




Upload and distribute large files

Programmat...
User Accounts




                      Federated login for your application




Google Accounts or OpenID

Administrator ...
Getting started
Getting started with App Engine

 Download the SDK
    http://code.google.com/appengine
 Register for an Appspot account
 ...
Starting a project
  Linux, MacOS, etc. command-line:
    $ dev_appserver.py helloworld # run dev svr
    $ appcfg.py upda...
Project contents




       app.yaml – main configuration file

       index.yaml – automatically
       generated to inde...
main.py
Local development server
  $ dev_appserver.py helloworld
  INFO 2009-03-04 17:51:22,354 __init__.py]




        (Can also...
Deploying the application
 Set application identifier
 Run deploy script
 You're live!
Modifying app.yaml

application: helloworld
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
script: main.py
Running the deploy script


$ appcfg.py update helloworld
Scanning files on local disk.
Initiating update.
Email: ...
You're live!
Demo time!
main.py: Skeleton application

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util


clas...
main.py: Adding a handler
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_ap...
main.py: Persisting to the datastore

class GuestBook(webapp.RequestHandler):
  def post(self):
    greeting = Greeting()
...
main.py: Collecting values from the datastore

class MainHandler(webapp.RequestHandler):
  def get(self):
    self.respons...
Live code!
Next steps

 Download the SDK
    http://code.google.com/appengine
 Register for an Appspot account
     https://appengine...
Upcoming SlideShare
Loading in...5
×

Boot camp 2010_app_engine_101

4,723

Published on

Slides for the talk I gave for the Google I/O 2010 App Engine Bootcamp session. Thanks to everyone who came out

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,723
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
89
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Transcript of "Boot camp 2010_app_engine_101"

  1. 1. App Engine 101 Ikai Lan May 17th, 2010
  2. 2. Agenda Topics we'll cover Why App Engine? Traditional web stack scalability App Engine to the rescue! Services and APIs Code preview Guestbook sample Codelab preview
  3. 3. What is Google App Engine?
  4. 4. Google App Engine is... ... a way for you to run your web applications on Google’s scalable infrastructure. Google’s Data Centers
  5. 5. Start with... the basic LAMP stack LAMP: Linux Apache MySql Programming Language (PHP, Python, Perl, etc.) NOT Scalable Single Point of Failure (SPOF) Google Confidential and Proprietary
  6. 6. Database on a separate server Still not Scalable! TWO Single Points of Failure Google Confidential and Proprietary
  7. 7. Multiple Web Servers Now you need Load Balancing Database is still Single Point of Failure Google Confidential and Proprietary
  8. 8. Round Robin Load Balancing Register list of IPs with DNS DNS record is cached with a Time to Live (TTL) Google Confidential and Proprietary
  9. 9. Round Robin Load Balancing But the TTL takes time to propagate and might not be respected So if a machine goes down... :-( And the database is still SPOF Google Confidential and Proprietary
  10. 10. Master Slave Database :-) Better read throughput :-( Master is SPOF for writes :-( Master may die before replication Google Confidential and Proprietary
  11. 11. Partitioned Database :-) Better R/W throughput :-( More machines, more management :-( Re-architect data model :-( Rewrite queries Google Confidential and Proprietary
  12. 12. Why build it all yourself? Google Confidential and Proprietary
  13. 13. Why not use Google App Engine? Simple application configuration No systems administration No performance tuning AUTOMATIC SCALING! Google Confidential and Proprietary
  14. 14. App Engine Developers/Apps Google Confidential and Proprietary
  15. 15. Google Confidential and Proprietary
  16. 16. By the numbers Over 100,000 applications 250,000 developers Over 250 million daily pageviews
  17. 17. Underneath the hood
  18. 18. App Engine Components Load balancing Routing Hosts static content Separate from programming files Google Confidential and Proprietary
  19. 19. App Engine Components Hosts application code Handles concurrent requests Enforces isolation for app safety Maintains statelessness Multiple Runtimes Copyright © Sun Microsystems Inc. All rights reserved. Google Confidential and Proprietary
  20. 20. App Engine Services/APIs
  21. 21. Bigtable - The App Engine datastore Distributed, partitioned datastore Arbitrary horizontal scaling - scales to “Internet scale” Replicated and fault tolerant Parallel processing Predictable query performance No deadlocks Google Confidential and Proprietary
  22. 22. Memcache Distributed, very fast, in-memory cache Optimistic caching Very stable, robust and specialized Google Confidential and Proprietary
  23. 23. URL Fetch Simple, HTTP communication HTTP GET/POST to external service Allows integration with third-party REST APIs Google Confidential and Proprietary
  24. 24. Mail Inbound and outbound mail Outbound mail Inbound mail handling Attachment processing Google Confidential and Proprietary
  25. 25. XMPP Instant messaging for your application Incoming and outgoing XMPP No need to worry about setting up servers Google Confidential and Proprietary
  26. 26. Task Queue Background and scheduled computation Background processing infrastructure Scheduled jobs Automatic handling of queuing and job polling Google Confidential and Proprietary
  27. 27. Images Image manipulation Resize Crop Image compositions Google Confidential and Proprietary
  28. 28. Blobstore Heavy lifting for large files Upload and distribute large files Programmatic access to file contents Google Confidential and Proprietary
  29. 29. User Accounts Federated login for your application Google Accounts or OpenID Administrator management No need to create user management system Google Confidential and Proprietary
  30. 30. Getting started
  31. 31. Getting started with App Engine Download the SDK http://code.google.com/appengine Register for an Appspot account https://appengine.google.com Write code - deploy!
  32. 32. Starting a project Linux, MacOS, etc. command-line: $ dev_appserver.py helloworld # run dev svr $ appcfg.py update helloworld # deploy live Windows GUI (also avail for Mac):
  33. 33. Project contents app.yaml – main configuration file index.yaml – automatically generated to index your data main.py – your main application "controller" code goes here
  34. 34. main.py
  35. 35. Local development server $ dev_appserver.py helloworld INFO 2009-03-04 17:51:22,354 __init__.py] (Can also use the launcher for Windows and OS X)
  36. 36. Deploying the application Set application identifier Run deploy script You're live!
  37. 37. Modifying app.yaml application: helloworld version: 1 runtime: python api_version: 1 handlers: - url: .* script: main.py
  38. 38. Running the deploy script $ appcfg.py update helloworld Scanning files on local disk. Initiating update. Email: ...
  39. 39. You're live!
  40. 40. Demo time!
  41. 41. main.py: Skeleton application from google.appengine.ext import webapp from google.appengine.ext.webapp import util class MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('Hello world!') def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) util.run_wsgi_app(application) if __name__ == '__main__': main()
  42. 42. main.py: Adding a handler from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('<h1>Hello world!</h1>') self.response.out.write(''' <form action="/sign" method=post> <input type=text name=content> <br><input type=submit value="Sign Guestbook"> </form> ''') class GuestBook(webapp.RequestHandler): def post(self): self.response.out.write( '<h2>You wrote:</h2> %s' % self.request.get('content') ) application = webapp.WSGIApplication([ ('/', MainHandler), ('/sign', GuestBook), ], debug=True) # start_wsgi_app etc ...
  43. 43. main.py: Persisting to the datastore class GuestBook(webapp.RequestHandler): def post(self): greeting = Greeting() greeting.content = self.request.get('content') greeting.put() self.redirect('/')
  44. 44. main.py: Collecting values from the datastore class MainHandler(webapp.RequestHandler): def get(self): self.response.out.write('Hello world!') self.response.out.write('<h1>My GuestBook</h1><ol>') greetings = Greeting.all() for greeting in greetings: self.response.out.write('<li> %s' % greeting.content) self.response.out.write(''' </ol><hr> <form action="/sign" method=post> <textarea name=content rows=3 cols=60></textarea> <br><input type=submit value="Sign Guestbook"> </form> ''')
  45. 45. Live code!
  46. 46. Next steps Download the SDK http://code.google.com/appengine Register for an Appspot account https://appengine.google.com Attend the codelab!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×