Google App Engine and Social Apps


Published on

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

Published in: Technology, News & Politics

Google App Engine and Social Apps

  1. 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
  2. 2. Google App Engine • Easy to build • Easy to maintain • Easy to scale Leveraging Google’s platform to better serve your customers 2
  3. 3. Some App Engine Partners 3
  4. 4. Gartner’s view on Cloud Computing •  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 4 * Source: Yefim Natis, Gartner, AADI 2009
  5. 5. App Engine Platform Details 5
  6. 6. Specialized services 6
  7. 7. Language runtimes Duke, the Java mascot Copyright © Sun Microsystems Inc., all rights reserved. 7
  8. 8. Ensuring Portability 8
  9. 9. Extended Language support through JVM •  Java •  Scala •  JRuby (Ruby) •  Groovy •  Quercus (PHP) •  Rhino (JavaScript) Duke, the Java mascot •  Jython (Python) Copyright © Sun Microsystems Inc., all rights reserved. 9
  10. 10. Application management in the cloud 10
  11. 11. App Engine Dashboard 11
  12. 12. Development Tools for App Engine 12
  13. 13. Google App Engine Launcher 13
  14. 14. SDK Console 14
  15. 15. Google Plugin for Eclipse 15
  16. 16. Feature Roadmap 16
  17. 17. 18+ months in review 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 17
  18. 18. Demos! •  Dashboard •  AppLauncher •  Eclipse Plugin 18
  19. 19. App Engine as a Social Platform 19
  20. 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” • title=Building_an_OpenSocial_App_with_Google_App_Engine –  Facebook •  BuddyPoke –  Dave Westwood here to speak on his FB implementation of BuddyPoke on GAE 20
  21. 21. A social example: BuddyPoke 21
  22. 22. A social example: BuddyPoke (on FaceBook) 22
  23. 23. BuddyPoke Architecture at a glance Main Functionality 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 23
  24. 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 24
  25. 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. 25
  26. 26. BuddyPoke User Data in GAE Data models for user data •  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 … 26
  27. 27. Storing Unique Icons per User On FB, a unique icon is generated for each poke/mood change. These icons appear in the feed/wall. •  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! 27
  28. 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. 28
  29. 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("", 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. 29
  30. 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. 30
  31. 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..” 31
  32. 32. Thank you! 32