google app engine and social apps

32
Chris Schalk, Developer Advocate, Google Ikai Lan, Developer Programs Engineer, Google Dave Westwood, Creator of BuddyPoke January 20, 2010 Google App Engine and Social Apps

Upload: chris-schalk

Post on 19-May-2015

8.557 views

Category:

Technology


0 download

DESCRIPTION

This is a presentation given by Chris Schalk and Dave Westwood at the FBMeetup in Palo Alto on Jan 20 2010.

TRANSCRIPT

Page 1: Google App Engine and Social Apps

Chris Schalk, Developer Advocate, Google Ikai Lan, Developer Programs Engineer, Google Dave Westwood, Creator of BuddyPoke

January 20, 2010

Google App Engine and Social Apps

Page 2: Google App Engine and Social Apps

2

Google App Engine

• Easy to build

• Easy to maintain

• Easy to scale

Leveraging Google’s platform to better serve your customers

Page 3: Google App Engine and Social Apps

3

Some App Engine Partners

Page 4: Google App Engine and Social Apps

Gartner’s view on Cloud Computing

4 * Source: Yefim Natis, Gartner, AADI 2009

•  Correctly sees App Engine as a “Platform as a Service”

•  Just focus on the code, don’t worry about infrastructure •  Application infrastructure •  System infrastructure

•  Rapid application deployment and change

•  Fully delegated data center responsibility

Page 5: Google App Engine and Social Apps

5

App Engine Platform Details

Page 6: Google App Engine and Social Apps

6

Specialized services

Page 7: Google App Engine and Social Apps

7

Language runtimes

Duke, the Java mascot Copyright © Sun Microsystems Inc., all rights reserved.

Page 8: Google App Engine and Social Apps

8

Ensuring Portability

Page 9: Google App Engine and Social Apps

9

Extended Language support through JVM

•  Java •  Scala •  JRuby (Ruby) • Groovy • Quercus (PHP) • Rhino (JavaScript) •  Jython (Python)

Duke, the Java mascot Copyright © Sun Microsystems Inc., all rights reserved.

Page 10: Google App Engine and Social Apps

10

Application management in the cloud

Page 11: Google App Engine and Social Apps

11

App Engine Dashboard

Page 12: Google App Engine and Social Apps

12

Development Tools for App Engine

Page 13: Google App Engine and Social Apps

13

Google App Engine Launcher

Page 14: Google App Engine and Social Apps

14

SDK Console

Page 15: Google App Engine and Social Apps

15

Google Plugin for Eclipse

Page 16: Google App Engine and Social Apps

16

Feature Roadmap

Page 17: Google App Engine and Social Apps

17

Apr 2008 Python launch

May 2008 Memcache, Images API

Jul 2008 Logs export

Aug 2008 Batch write/delete

Oct 2008 HTTPS support

Dec 2008 Status dashboard, quota details

Feb 2009 Billing, larger files

Apr 2009 Java launch, DB import, cron support, SDC

May 2009 Key-only queries

Jun 2009 Task queues

Aug 2009 Kindless queries

Sep 2009 XMPP

Oct 2009 Incoming Email

Dec 2009 Blobstore

18+ months in review

Page 18: Google App Engine and Social Apps

18

•  Dashboard •  AppLauncher •  Eclipse Plugin

Demos!

Page 19: Google App Engine and Social Apps

19

App Engine as a Social Platform

Page 20: Google App Engine and Social Apps

20

App Engine + Social Apps (mobile too!)

•  App Engine works well as a backend server for Social Apps of all types –  OpenSocial

•  Tutorials, example code - “Building an OpenSocial App with Google App Engine”

•  http://wiki.opensocial.org/index.php?title=Building_an_OpenSocial_App_with_Google_App_Engine

–  Facebook •  BuddyPoke

–  Dave Westwood here to speak on his FB implementation of BuddyPoke on GAE

Page 21: Google App Engine and Social Apps

21

A social example: BuddyPoke

Page 22: Google App Engine and Social Apps

22

A social example: BuddyPoke (on FaceBook)

Page 23: Google App Engine and Social Apps

23

BuddyPoke Architecture at a glance

Is an fbml application, with an embedded fb:swf to load the Flash swf file.

Services include:

•  Save avatar appearance •  Hug, Kiss, Poke a friend •  Change mood •  Create & Upload image to FB

Main Functionality

Page 24: Google App Engine and Social Apps

24

BuddyPoke User Validation

•  FB automatically passes fb_sig params to the fb:swf file

•  Makes direct calls from the swf file to GAE for Avatar saving functionality (appearance, mood, etc).

•  Pass the fb_sig params along with any http call to GAE

•  GAE then uses fb_sig params to validate any calls from a user

Page 25: Google App Engine and Social Apps

25

Making calls to FaceBook

•  fb:swf will have a session key that can be used to make direct calls to Facebook, so a lot of the time you can just do requests straight from Flash -> facebook.

• This is great for things like loading user data, friend data, fql queries etc.

Page 26: Google App Engine and Social Apps

26

BuddyPoke User Data in GAE

•  Main ‘User’ data model •  Used 99% of time •  not indexed, no queries, use keys •  key name based on FB id •  fast performance

•  Additional User info model •  Stores additional user info •  ex: install date •  Is indexed, can be queried •  Used less

•  Additional models for: • Virtual currency, blobs for user icons …

Data models for user data

Page 27: Google App Engine and Social Apps

27

Storing Unique Icons per User

•  Each user has maximum of N icons to avoid using up too much datastore space.

•  When a user does a hug, poke, changes mood etc, an icon is sent to GAE using multi-part message. The icon will overwrite the previous oldest icon in the datastore and return a unique icon url to use in the feed.

•  Icons are mem-cached, so better performance & saves money!

On FB, a unique icon is generated for each poke/mood change. These icons appear in the feed/wall.

Page 28: Google App Engine and Social Apps

28

Updating profile page FBML

•  BuddyPoke has a box on the profile page. It contains fbml that shows icons for the last 4 activities.

• When you hug a friend it will update your profile page, and your friend's profile page. Facebook's servers can be very slow.. So rather than tie up App Engine I create a facebook batch request, sign it on App Engine, and then pass it back to the Flash swf client.

• The client then makes the call to FaceBook's servers with the signed request to update the profile data.

• For OpenSocial, I'd just make the calls directly from App Engine to an OpenSocial server. But if you have 4+ operations to do on facebook those calls can take a long time, so I just get the Flash client to send the request and do all the waiting.

Page 29: Google App Engine and Social Apps

29

Updating profile page FBML, cont.

So let's say I wanted to update 20 images on facebook's image caching servers I'd sign a request on App Engine using something like:

def sig_batch_refreshImgSrc(self, urls, call_id): methods = [] for url in urls: sig_param = {} sig_param['url'] = url sig_param['call_id'] = str(call_id) call_id = call_id+1 self._build_post_args("facebook.fbml.refreshImgSrc", sig_param) methods.append(urllib.urlencode(sig_param)) batch_param = {} batch_param['method_feed'] = json.write(methods, True) batch_param['call_id'] = str(call_id) self._build_post_args("facebook.batch.run", batch_param) return '"run":%s' % json.write(batch_param, True)

Then I'd pass that back to the Flash client, and the Flash client can send the request and sit their waiting for 10 seconds while FaceBook forces the image refresh.

Page 30: Google App Engine and Social Apps

30

Payments using Paypal

I have Paypal hit App Engine any time there is a new transaction. Paypal will pass a bunch of params, you then ping Paypals server with a _notify-validate using a urlfetch to verify the params came from paypal.

if self.request.get('payment_status') == 'Completed': parameters = self.request.POST.copy() if parameters: parameters['cmd']='_notify-validate’ status = urlfetch.fetch(url = PP_URL, method = urlfetch.POST, payload = urllib.urlencode(parameters) ).content if status == "VERIFIED": ...

Then I'd pass that back to the Flash client, and the Flash client can send the request and sit their waiting for 10 seconds while FaceBook forces the image refresh.

Page 31: Google App Engine and Social Apps

31

Communicating with via Email

“Use the email API to send yourself messages about anything important.

Very soon, with the FaceBook changes, I expect I'll be using the email API a lot more.

And the beauty of App Engine is I can just pay for as much email quota as I need. No hassles setting up email servers..”

Page 32: Google App Engine and Social Apps

32

Thank you!

code.google.com/appengine

twitter.com/cschalk twitter.com/ikai twitter.com/app_engine