Mike Mangino: Facebook development and performance with Rails
Posted by Annalisa Afeltra in
comments are closed
Mangino explains how to create a Facebook application with Ruby on Rails optimizing the performances.
He explains how a Rails application can integrate with Facebook, practically Facebook acts as a proxy between the user and the application (taking the requests from the user to the application) this can create some probelms; the most dangerous: each HTTP request originates from Facebook, not from the user that created it.
The session continues with a live demo concentated on the creation of a facebook application that shows on the page a RailsConf Badge.
The first thing to do is to create a Facebook application e registering it with using the form. Therefore you must do it in a way that Facebook speaks to the server where the application is on. To do this it is necessary to make a tunneling operation, that will open up a few ports on the firewall and utilizing tunnir.
Once the application is created with the usual genrator ‘rails’ it is necessary to install the plugin facebooker e configurare using the facebooker.yml file.
This is what Facebooker does for us:- manages the pass of parameters e certifies that each request comes from facebook
- re-integrates the possibility to use the architecture REST to develop facebook applications
- and much more!
The configuration file of facebook comprises the signature of the application and some information about tunneling.
To launch the application that has just been created the following commands are run:
ruby script/server
rake facebooker:tunnel:start
Another facebook feature is the FBML (Facebook Markup Language) that gives the possibility to show a video some information relative to the user that is navigating in our application with an HTML-like instance. L’FBML also contains some helper for the drafting of the interface so that they have the look and feel of facebook.
Lets proceed with the drafting of the test application:
Installing a facebook application in the profile makes it in a way that the application can access to the characterisctics of the user who is using the application as well as sending this user notification emails.
‘ensure_application_is_installed_by_facebook_user’ placed in the controller will make it accessible only if the application has been installed.
Facebook makes it possible to know the characteristics of the user that is using the application through the parameters ‘fb_dig_user’. Following the method profile_fbml = you can update the profile of the user that is connected.
Be aware that developing in this environment it important that the urls must contain the absolute path.
Using the facebook publisher we can in facebook have (or almost) the functionality that a normal application can have with ActionMailer.
The most potential component in facebook is SocialGraph, that allows you to represent the collected information from my application, using the social function that can give problems to performance, to remedy this you can use REF, that works like a persistent version of memcached. To use REF, you can use the following syntax:
<fb:ref handle="<%=dom_id sess%>" ecc...
Lastly he says that using the Facebooker API REST does not have such a good performance.
Annalisa

