google app engine and social apps

Post on 19-May-2015

8.557 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

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

2

Google App Engine

• Easy to build

• Easy to maintain

• Easy to scale

Leveraging Google’s platform to better serve your customers

3

Some App Engine Partners

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

5

App Engine Platform Details

6

Specialized services

7

Language runtimes

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

8

Ensuring Portability

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.

10

Application management in the cloud

11

App Engine Dashboard

12

Development Tools for App Engine

13

Google App Engine Launcher

14

SDK Console

15

Google Plugin for Eclipse

16

Feature Roadmap

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

18

•  Dashboard •  AppLauncher •  Eclipse Plugin

Demos!

19

App Engine as a Social Platform

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

21

A social example: BuddyPoke

22

A social example: BuddyPoke (on FaceBook)

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

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

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.

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

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.

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.

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.

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.

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

32

Thank you!

code.google.com/appengine

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

top related