Top Banner
What is App Engine? Ikai Lan OSCON July 21st, 2010 Twitter: @ikai
51
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: What is App Engine? O

What is App Engine?

Ikai LanOSCONJuly 21st, 2010Twitter: @ikai

Page 2: What is App Engine? O

AgendaTopics we'll cover

Why App Engine?Traditional web stack scalability

App Engine to the rescue!

Services and APIs

Deployment stepsApp Engine and Open SourceQuestions and Next Steps

Page 3: What is App Engine? O

What is Google App Engine?

Page 4: What is App Engine? O

Google Confidential and Proprietary

Google App Engine is...

... a way for you to run your web applications on Google’s scalable

infrastructure.

Google’s Data Centers

Page 5: What is App Engine? O

Google Confidential and Proprietary

Start with... the basic LAMP stack

LAMP:Linux

Apache

MySql

Programming Language(PHP, Python, Perl, etc.)

NOT Scalable

Single Point of Failure (SPOF)

Page 6: What is App Engine? O

Google Confidential and Proprietary

Database on a separate server

Still not Scalable!

TWO Single Points of Failure

Page 7: What is App Engine? O

Google Confidential and Proprietary

Multiple Web Servers

Now you need Load Balancing

Database is still Single Point of Failure

Page 8: What is App Engine? O

Google Confidential and Proprietary

Round Robin Load Balancing

Register list of IPs with DNS

DNS record is cached with a Time to Live (TTL)

Page 9: What is App Engine? O

Google Confidential and Proprietary

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

Page 10: What is App Engine? O

Google Confidential and Proprietary

Master Slave Database

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

:-( Master may die before replication

Page 11: What is App Engine? O

Google Confidential and Proprietary

Partitioned Database

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

:-( Re-architect data model

:-( Rewrite queries

Page 12: What is App Engine? O

Google Confidential and Proprietary

Why build it all yourself?

Page 13: What is App Engine? O

Google Confidential and Proprietary

Why not use Google App Engine?

Simple application configuration

No systems administration

No performance tuning

AUTOMATIC SCALING!

Page 14: What is App Engine? O

The Cloud Computing Landscape

IaaS

PaaS

SaaS

Source: Gartner AADI Summit Dec 2009

Page 15: What is App Engine? O

Google Confidential and Proprietary

App Engine Developers/Apps

Page 16: What is App Engine? O

Google Confidential and Proprietary

Page 17: What is App Engine? O

By the numbers

Over 100,000 applications250,000 developersOver 250 million daily pageviews

Page 18: What is App Engine? O

Underneath the hood

Page 19: What is App Engine? O

Google Confidential and Proprietary

App Engine Components

Load balancing

Routing

Hosts static content

Separate from programming files

Page 20: What is App Engine? O

Google Confidential and Proprietary

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.

Page 21: What is App Engine? O

App Engine Services/APIs

Page 22: What is App Engine? O

Google Confidential and Proprietary

Bigtable - The App Engine datastore

Arbitrary horizontal scaling - scales to “Internet scale”

Replicated and fault tolerant

Parallel processing

Predictable query performance

No deadlocks

Distributed, partitioned datastore

Page 23: What is App Engine? O

Google Confidential and Proprietary

Memcache

Optimistic caching

Very stable, robust and specialized

Distributed, very fast, in-memory cache

Page 24: What is App Engine? O

Google Confidential and Proprietary

URL Fetch

HTTP GET/POST to external service

Allows integration with third-party REST APIs

Simple, HTTP communication

Page 25: What is App Engine? O

Google Confidential and Proprietary

Mail

Outbound mail

Inbound mail handling

Attachment processing

Inbound and outbound mail

Page 26: What is App Engine? O

Google Confidential and Proprietary

XMPP

Incoming and outgoing XMPP

No need to worry about setting up servers

Instant messaging for your application

Page 27: What is App Engine? O

Google Confidential and Proprietary

Task Queue

Background processing infrastructure

Scheduled jobs

Automatic handling of queuing and job polling

Background and scheduled computation

Page 28: What is App Engine? O

Google Confidential and Proprietary

Images

Resize

Crop

Image compositions

Image manipulation

Page 29: What is App Engine? O

Google Confidential and Proprietary

Blobstore

Upload and distribute large files

Programmatic access to file contents

Heavy lifting for large files

Page 30: What is App Engine? O

Google Confidential and Proprietary

User Accounts

Google Accounts or OpenID

Administrator management

No need to create user management system

Federated login for your application

Page 31: What is App Engine? O

Getting started

Page 32: What is App Engine? O

Getting started with App Engine

Download the SDKhttp://code.google.com/appengine

Register for an Appspot account

https://appengine.google.com

Write code - deploy!

Page 33: What is App Engine? O

$ dev_appserver.py helloworld # run dev svr$ appcfg.py update helloworld # deploy live

Linux, MacOS, etc. command-line:

Windows GUI (also avail for Mac):

Starting a project

Page 34: What is App Engine? O

app.yaml – main configuration file

index.yaml – automatically generated to index your data

main.py – your main application "controller" code goes here

Project contents

Page 35: What is App Engine? O

main.py

Page 36: What is App Engine? O

$ dev_appserver.py helloworld

(Can also use the launcher for Windows and OS X)

Local development server

Page 37: What is App Engine? O

Deploying the applicationSet application identifierRun deploy scriptYou're live!

Page 38: What is App Engine? O

main.py: Adding a handlerfrom google.appengine.ext import webappfrom 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 ...

Page 39: What is App Engine? O

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('/')

Page 40: What is App Engine? O

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> ''')

Page 41: What is App Engine? O

Running the deploy script

$ appcfg.py update helloworldScanning files on local disk.Initiating update.Email: ...

Page 42: What is App Engine? O

You're live!

Page 43: What is App Engine? O

Google App Engine and Open Source

Page 44: What is App Engine? O

Google Confidential and Proprietary

TyphoonAE: Open Source implementation

Page 45: What is App Engine? O

Google Confidential and Proprietary

Open Source JVM language runtimes

ClojurePractical Lisp on the JVMJRuby/MirahRuby on the JVM. Mirah = Ruby-like language that compiles to Java (speed!)GroovyDynamically typed Java-like languageScalaStrongly typed, functional imperativeJythonJava implementation of Python

Page 46: What is App Engine? O

Google Confidential and Proprietary

Open Source Persistence Frameworks

Objectifyhttp://code.google.com/p/objectify-appengine/Twighttp://code.google.com/p/twig-persist/Slim3 (popular in Japan)http://sites.google.com/site/slim3appengine/SimpleDShttp://code.google.com/p/simpleds/Django-nonrelhttp://www.allbuttonspressed.com/projects/django-nonrel

Page 47: What is App Engine? O

Google Confidential and Proprietary

Official features

Datanucleus JDO/JPAhttp://code.google.com/p/datanucleus-appengine/App Engine Map/Reducehttp://code.google.com/p/appengine-mapreduce/Python SDKJava SDK - soon!

Page 48: What is App Engine? O

Questions and Next Steps

Page 49: What is App Engine? O

Code time!

Page 50: What is App Engine? O

main.py: Skeleton application

from google.appengine.ext import webappfrom 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()

Page 51: What is App Engine? O

Next steps

Download the SDKhttp://code.google.com/appengine

Do the codelabhttp://code.google.com/appengine

Register for an Appspot account

https://appengine.google.com

Get this presentation

http://slideshare.net/ikailan