app engine on air: munich

Post on 19-May-2015

5.774 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

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

Google App EngineFlying into Munich

Dion Almaer

twitter.com/dalmaeralmaer.com

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

Jonathan SchwartzCEO, Sun Microsystems

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

Google App EngineTechnical Challenges

Google App EngineFinancial and Admin Challenges

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

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

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

!

Develop locally. Deploy to Google. Launch.

Develop locally. Deploy to Google. Launch.

Deploy

Develop locally. Deploy to Google. Launch.

Develop locally.

• Google App Engine SDK is open source

• Simulates production environment

•dev_appserver.py myapp•appcfg.py update myapp

# 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

Web Services

loadcontacts

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

name=’Dion A Lamer’email=’dion@almaer.com’

the snake is almost there

threadssockets

filesforeground

from django import v0_96 as django

Wow, that's abig table!

Store dataScalable, and not like a RDBMS

• No joins

• Hierarchies

• Indexes

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

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

GQLOur query language

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

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

story.put() # save or update

story.delete() # delete if saved

InsertsManipulating the data

Call Web Services

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

Authenticate to GoogleOpenID provider.... available

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...

Send Email

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='marce@google.com', subject='Wiki Page', body=email_body)

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

Email APINo SMTP config required

Manipulate Images

# 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

Memcache SupportIn-memory distributed cache

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

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?

Use it as you willNo need to go whole hog

Web Services

Your Application

Google App EngineAnnouncing Open Signups

Memcache API

Email API

Static Files

PythonRuntime

Configuration

URL Fetch API

Users API

Image API

Web Applications

Google App Engine

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

Memcache API

Email API

Static Files

PythonRuntime

Configuration

URL Fetch API

Users API

Image API

Web Applications

Google App Engine

top related