app engine on air: munich

48
Google App Engine Flying into Munich

Upload: dion

Post on 19-May-2015

5.774 views

Category:

Technology


0 download

DESCRIPTION

This is the presentation that I gave on the European On Air tour in Munich. Hence the footy pieces. A lot of the presentation was going through a live application, a port of the addressbook app to App Engine, that lives on Google Code.

TRANSCRIPT

Page 1: App Engine On Air: Munich

Google App EngineFlying into Munich

Page 2: App Engine On Air: Munich

Dion Almaer

twitter.com/dalmaeralmaer.com

Page 3: App Engine On Air: Munich
Page 4: App Engine On Air: Munich
Page 5: App Engine On Air: Munich
Page 6: App Engine On Air: Munich

Don't forget, RIA's have rich internet back-ends (RIBs?)

Jonathan SchwartzCEO, Sun Microsystems

Page 7: App Engine On Air: Munich

Google App EngineRunning Web Apps on Google’s Infrastructure

• Fully-integratedapplication environment

• Language agnostic runtimePython for now

• Free quota of 5Mpageviews per month

code.google.com/appengine

Page 8: App Engine On Air: Munich

Google App EngineTechnical Challenges

Page 9: App Engine On Air: Munich

Google App EngineFinancial and Admin Challenges

Page 10: App Engine On Air: Munich

Google App EngineEasy to use, Easy to scale, Free to start

Page 11: App Engine On Air: Munich

11

Google App EngineFree Quota and Expected Pricing

Resource Free Quota Additional

CPU

Equivalent to 5M pageviews / month

for a typical app

10-12¢ / core-hour

Storage 15-18¢ / GB-month

Bandwidth, Outgoing 11-13¢ / GB transferred

Bandwidth, Incoming 9-11¢ / GB transferred

Page 12: App Engine On Air: Munich
Page 13: App Engine On Air: Munich

13

Google App EngineFree Quota and Expected Pricing

Resource Free Quota Additional

CPU

Equivalent to 5M pageviews / month

for a typical app

1 euro / core-year

Storage 1 euro / GB-decade

Bandwidth, Outgoing 1 euro / PB transferred

Bandwidth, Incoming 1 euro / PB transferred

Thanks George

!

Page 14: App Engine On Air: Munich

Develop locally. Deploy to Google. Launch.

Page 15: App Engine On Air: Munich

Develop locally. Deploy to Google. Launch.

Deploy

Page 16: App Engine On Air: Munich
Page 17: App Engine On Air: Munich

Develop locally. Deploy to Google. Launch.

Page 18: App Engine On Air: Munich

Develop locally.

• Google App Engine SDK is open source

• Simulates production environment

•dev_appserver.py myapp•appcfg.py update myapp

Page 19: App Engine On Air: Munich

# helloworld.py print "Content-Type: text/html" print print "Hello, world!"

# app.yaml application: dalmaer-helloworld version: 1 runtime: python api_version: 1 handlers: - url: /.* script: helloworld.py

Hello WorldSimplest output, simplest config

Page 20: App Engine On Air: Munich
Page 21: App Engine On Air: Munich

Web Services

loadcontacts

var contacts = [ { id: 1, name: ‘Dion Almaer’, ... }, { id: 2, name: ‘Ben Galbraith’, ... },]savecontact

name=’Dion A Lamer’email=’[email protected]

Page 22: App Engine On Air: Munich

the snake is almost there

threadssockets

filesforeground

Page 23: App Engine On Air: Munich

from django import v0_96 as django

Page 24: App Engine On Air: Munich

Wow, that's abig table!

Store dataScalable, and not like a RDBMS

Page 25: App Engine On Air: Munich

• No joins

• Hierarchies

• Indexes

Page 26: App Engine On Air: Munich

from google.appengine.ext import db

class Story(db.Model): title = db.StringProperty() body = db.TextProperty(required=True) author = db.UserProperty(required=True) created = db.DateTimeProperty(auto_now_add=True) rating = db.RatingProperty()

# Many other types: BlobProperty, ReferenceProperty, EmailProperty, PhoneProperty, IMProperty, PostallAddressProperty, etc.

Data ModelJust an object

Page 27: App Engine On Air: Munich

SELECT *FROM StoryWHERE title = 'App Engine Launch'AND author = :current_userAND rating >= 10ORDER BY rating, created DESC

GQLOur query language

Page 28: App Engine On Air: Munich

Story.gql(GQL_FROM_BEFORE, current_user = users.get_current_user())

query = Story.all()

query.filter('title =', 'Foo') .order('-date') .ancestor(key)

Run the queriesBeyond GQL

Page 29: App Engine On Air: Munich

story = Story( title = 'Morning Glory', body = '....', author = users.get_current_user(),)

story.put() # save or update

story.delete() # delete if saved

InsertsManipulating the data

Page 30: App Engine On Air: Munich

Call Web Services

Page 31: App Engine On Air: Munich

from google.appengine.api import urlfetch

some_feed = urlfetch.fetch('http://somesite.com/rss')

if some_feed.status_code == 200: self.response.out.write(some_feed.content)

URL Fetch APIAint no urllib2

54321

Page 32: App Engine On Air: Munich

Authenticate to GoogleOpenID provider.... available

Page 33: App Engine On Air: Munich

from google.appengine.api import users

current_user = users.get_current_user()

if not current_user: self.redirect(users.create_login_url('/current_url'))

nickname = current_user.nickname()email = current_user.email()

if users.is_current_user_admin(): ...

Users APIBut you can do your own thing too of course...

Page 34: App Engine On Air: Munich

Send Email

Page 35: App Engine On Air: Munich

from google.appengine.api import mail

def post(self): email_body = self.request.get('email_body') sender = users.get_current_user().email mail.send_mail(sender=sender, to='[email protected]', subject='Wiki Page', body=email_body)

self.response.out.write('Email Sent')

Email APINo SMTP config required

Page 36: App Engine On Air: Munich

Manipulate Images

Page 37: App Engine On Air: Munich

# in modelavatar = db.BlobProperty()

# in handleravatar = images.resize(self.request.get("img"), 32, 32)

# availableresizecroprotatehorizontal_flipvertical_flipim_feeling_lucky :)

Image Manipulation APINo SMTP config required

Page 38: App Engine On Air: Munich

Memcache SupportIn-memory distributed cache

Page 39: App Engine On Air: Munich

from google.appengine.api import memcache

def get_data(): data = memcache.get("key") if data is not None: return data else: data = self.query_for_data() memcache.add("key", data, 60) return data

# Set several values, overwriting any existing values for these keys.memcache.set_multi({ "USA_98105": "raining", "USA_94105": "foggy", "USA_94043": "sunny" }, key_prefix="weather_", time=3600)

# Atomically increment an integer value.memcache.set(key="counter", 0)memcache.incr("counter")memcache.incr("counter")memcache.incr("counter")

Memcache APIIn-memory distributed cache

Page 40: App Engine On Air: Munich

40

Google App EngineAreas of Work, Including…

• Offline Processing

• Rich Media Support

– e.g., large file upload / download

• Add’l Infrastructure Services

• What would you like to see?

Page 41: App Engine On Air: Munich

Use it as you willNo need to go whole hog

Page 42: App Engine On Air: Munich

Web Services

Your Application

Page 43: App Engine On Air: Munich
Page 44: App Engine On Air: Munich

Google App EngineAnnouncing Open Signups

Page 45: App Engine On Air: Munich
Page 46: App Engine On Air: Munich

Memcache API

Email API

Static Files

PythonRuntime

Configuration

URL Fetch API

Users API

Image API

Web Applications

Google App Engine

Page 47: App Engine On Air: Munich

Now hosting open source JavaScript libraries at GoogleStarting with: Prototype, Script.aculo.us, jQuery, Dojo, MootoolsAccepting requests for other open source librariesCan access directly:

1

What if popular JavaScript libraries were available and shared in the browser?

ajax.googleapis.com/ajax/lib/prototype?v=1.6.0.2&packed=false

Other featuresAutomatic compressionMinification of libraries

2

Can access via AJAX API Loader: google.load(“prototype”, “1.6”);

Not tied to Google Code

Page 48: App Engine On Air: Munich

Memcache API

Email API

Static Files

PythonRuntime

Configuration

URL Fetch API

Users API

Image API

Web Applications

Google App Engine