SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Facebook on Rails

                              CardinalBlue
                              info@cardinalblue.com

                              Ruby Tuesday 2009.10.20


Friday, October 23, 2009
40% of all
                                       Internet Users in
                                        North America
                                             are on
                                           Facebook!



              300 million Facebook users around the world
Friday, October 23, 2009
Facebook Trends (   )


                           73




Friday, October 23, 2009
Facebook Apps Boom




Friday, October 23, 2009
Friday, October 23, 2009
Demographic Trends
      • More female
               gamers
      • More younger
               (ages 8-15) gamers
      • More older (ages
               50+) gamers


Friday, October 23, 2009
FB Games are Social
                     •     Trend #1: Virtual Worlds
                           •   e.g.,YoVille, PetSociety


                     •     Trend #2: Customization & Personalization
                           •   e.g., Nintendo’s “Mii” avatars, Buddy Poke


                     •     Trend #3: Collections and Wish Lists
                           •   e.g., Mafia Wars


                     •     Trend #4: Interaction and Engagement
                           •   Farm Town, FarmVille, Barn Buddy


                     •     Trend #5: Narrative and Missions

Friday, October 23, 2009
FB Games are Social
                     •     Trend #6: Gift Invites
                           •   e.g., Lil Green Patch, Give a Heart

                     •     Trend #7: Donations as Revenue
                           •   e.g., SpareChange, PayPal

                     •     Trend #8: Virtual Goods
                           •   e.g., Mafia Wars, PetSociety

                     •     Trend #9: Recruiting Users
                           •   e.g., FarmVille, Restaurant City, Tycoons

                     •     Trend #10: Capitalizing on Player Resources
                           •   e.g., All that Glitters, Photo-of-the-Day

Friday, October 23, 2009
FBML Application
                             Architecture




Friday, October 23, 2009
Facebook apps on Rails

                     • Rails 2.3.3
                     • Facebook API via Facebooker
                     • Hosted on Heroku
                     • Monitor via NewRelic


Friday, October 23, 2009
User model
                           Facebook UIDs are 64-bit, so need bigint for User#id
                           create_table :users, :id => false do |t|
                                t.column      :id, "bigint PRIMARY KEY", :null => false
                                ...
                                t.timestamps
                           end


                           Associations can be done based on user_id
                           create_table :balloons
                                t.column      :user_id, :bigint
                                ...
                                t.timestamps
                           end




Friday, October 23, 2009
Facebooker

                       • Wrapper for Facebook API
                       • Facebooker::User to query user data
                       • Facebooker::Publisher for feeds/notifications


Friday, October 23, 2009
Facebooker

                       • Wrapper for Facebook API
                       • Facebooker::User to query user data
                       • Facebooker::Publisher for feeds/notifications


Friday, October 23, 2009
Preload FQL
                     • Facebooker::User to query user data
                     • Since query can take 500ms or more, use
                            Preload FQL to pre-query the data
                           preload_fql = Hash.new
                           preload_fql[:preload_user_data] = {
                             :pattern => ".*",
                             :query => "SELECT name,birthday_date
                                        FROM user WHERE uid={*user*};"
                           }

                           Facebooker::Admin.new(Facebooker::Session.create).set_app_pro
                           perties({:preload_fql => preload_fql.to_json})


                     • Obtain the preloaded data on every page:
                            params[:fb_sig_user_data]



Friday, October 23, 2009
Open Stream API
               • Facebooker::Publisher for feeds/notifications
               • Facebook has deprecated template bundles
               • Instead use the Open Stream API:
                           <script>
                           var attachment = {'media':[{'type':'image', 'src':'http://
                           cardinalblue.com/images/cblue_logo_white100.png', 'href':'http://
                           cardinalblue.com'}]};
                           Facebook.streamPublish('Hello Cardinal Blue', attachment);
                           </script>




Friday, October 23, 2009
Functional tests
                            with facebook_get
        test "requires-login page, logged in" do
             facebook_get :install
             assert_response :success
             assert_nil facebook_redirect_url
        end


        test "requires-login page, not logged in" do
             # access a page that requires login
             facebook_get :install, :fb_sig_user => nil
             assert_response :success
             assert_not_nil facebook_redirect_url
             assert facebook_redirect_url.match("http://www.facebook.com/install.php")
        end


Friday, October 23, 2009
Heroku




Friday, October 23, 2009
Scaled to over 10000 requests per minute




Friday, October 23, 2009
Heroku features
           • Uses nginx, thin, postgres, Amazon EC2
           • Easy Deployment:         git push heroku master


           • Flexible Scaling:      heroku dynos +1


           • Free Memcache:          Rails.cache


           • Delayed Job:
                   facebook_session.send_notification(...)
                   facebook_session.send_later(:send_notification,...)

           • New Relic
Friday, October 23, 2009
New Relic

                              Facebooker




Friday, October 23, 2009
Can set up
                custom tracers:
                Facebook/query
                Facebook/notify
                Facebook/feed

           class NewrelicTracer
             def self.query
               yield
             end
             class << self
               add_method_tracer :query, 'Custom/Facebook/query'
             end
           end

           NewrelicTracer.query do
             location = facebook_session.user.current_location
           end

Friday, October 23, 2009
Observations

                      • Facebook is growing
                      • Facebook games are social
                      • Rails + Facebooker = Facebook app
                      • Heroku is fun (and scalable)

Friday, October 23, 2009
Thank you.

                           http://cardinalblue.com/about

                             jobs@cardinalblue.com




Friday, October 23, 2009

Contenu connexe

Similaire à Facebook on Rails

BuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress PluginsBuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress PluginsMark Jaquith
 
It's a beautiful day in your (online) neighborhood
It's a beautiful day in your (online) neighborhoodIt's a beautiful day in your (online) neighborhood
It's a beautiful day in your (online) neighborhoodKatie Laird
 
Social Media and Your (online) Neighborhood
Social Media and Your (online) NeighborhoodSocial Media and Your (online) Neighborhood
Social Media and Your (online) NeighborhoodKatie Laird
 
URIplay for Media Futures Conference (2009)
URIplay for Media Futures Conference (2009)URIplay for Media Futures Conference (2009)
URIplay for Media Futures Conference (2009)Chris Jackson
 
Hacking And Hosting Hot Potatoes
Hacking And Hosting Hot PotatoesHacking And Hosting Hot Potatoes
Hacking And Hosting Hot PotatoesDerek Moore
 
Health Care Social Media Summit Keynote
Health Care Social Media Summit KeynoteHealth Care Social Media Summit Keynote
Health Care Social Media Summit KeynoteLee Aase
 
Kevin Coughlin Brand Presentation TCNJ 9/23/13
Kevin Coughlin Brand Presentation TCNJ 9/23/13Kevin Coughlin Brand Presentation TCNJ 9/23/13
Kevin Coughlin Brand Presentation TCNJ 9/23/13kevintcoughlin
 
Strategies Tech It Up
Strategies Tech It UpStrategies Tech It Up
Strategies Tech It UpLisa Read
 
Social Media and philanthropy - tracking the buzz, making connections
Social Media and philanthropy - tracking the buzz, making connectionsSocial Media and philanthropy - tracking the buzz, making connections
Social Media and philanthropy - tracking the buzz, making connectionsEd Schipul
 
NoTube User Model slides
NoTube User Model slidesNoTube User Model slides
NoTube User Model slidesDan Brickley
 
Education Wants To Be Free
Education Wants To Be FreeEducation Wants To Be Free
Education Wants To Be FreeDave Cooksey
 
URIplay for Open Video Conference (2009)
URIplay for Open Video Conference (2009)URIplay for Open Video Conference (2009)
URIplay for Open Video Conference (2009)Chris Jackson
 
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...Cheryl Foong
 
Cloud Computing Presentation - Kenosee Retreat 2013
Cloud Computing Presentation - Kenosee Retreat 2013Cloud Computing Presentation - Kenosee Retreat 2013
Cloud Computing Presentation - Kenosee Retreat 2013Trent Haus
 
Highprofile New Media Congres
Highprofile New Media CongresHighprofile New Media Congres
Highprofile New Media CongresVincent Everts
 
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01CommGres Conference Agency
 

Similaire à Facebook on Rails (18)

BuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress PluginsBuddyPress and the Future of WordPress Plugins
BuddyPress and the Future of WordPress Plugins
 
It's a beautiful day in your (online) neighborhood
It's a beautiful day in your (online) neighborhoodIt's a beautiful day in your (online) neighborhood
It's a beautiful day in your (online) neighborhood
 
Social Media and Your (online) Neighborhood
Social Media and Your (online) NeighborhoodSocial Media and Your (online) Neighborhood
Social Media and Your (online) Neighborhood
 
URIplay for Media Futures Conference (2009)
URIplay for Media Futures Conference (2009)URIplay for Media Futures Conference (2009)
URIplay for Media Futures Conference (2009)
 
Hacking And Hosting Hot Potatoes
Hacking And Hosting Hot PotatoesHacking And Hosting Hot Potatoes
Hacking And Hosting Hot Potatoes
 
Health Care Social Media Summit Keynote
Health Care Social Media Summit KeynoteHealth Care Social Media Summit Keynote
Health Care Social Media Summit Keynote
 
Kevin Coughlin Brand Presentation TCNJ 9/23/13
Kevin Coughlin Brand Presentation TCNJ 9/23/13Kevin Coughlin Brand Presentation TCNJ 9/23/13
Kevin Coughlin Brand Presentation TCNJ 9/23/13
 
Strategies Tech It Up
Strategies Tech It UpStrategies Tech It Up
Strategies Tech It Up
 
All The Little Pieces
All The Little PiecesAll The Little Pieces
All The Little Pieces
 
Using Drupal
Using DrupalUsing Drupal
Using Drupal
 
Social Media and philanthropy - tracking the buzz, making connections
Social Media and philanthropy - tracking the buzz, making connectionsSocial Media and philanthropy - tracking the buzz, making connections
Social Media and philanthropy - tracking the buzz, making connections
 
NoTube User Model slides
NoTube User Model slidesNoTube User Model slides
NoTube User Model slides
 
Education Wants To Be Free
Education Wants To Be FreeEducation Wants To Be Free
Education Wants To Be Free
 
URIplay for Open Video Conference (2009)
URIplay for Open Video Conference (2009)URIplay for Open Video Conference (2009)
URIplay for Open Video Conference (2009)
 
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...
Creative Commons in Practice: Application, Search and Attribution - Cheryl Fo...
 
Cloud Computing Presentation - Kenosee Retreat 2013
Cloud Computing Presentation - Kenosee Retreat 2013Cloud Computing Presentation - Kenosee Retreat 2013
Cloud Computing Presentation - Kenosee Retreat 2013
 
Highprofile New Media Congres
Highprofile New Media CongresHighprofile New Media Congres
Highprofile New Media Congres
 
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01
Vincent Evers Trendwatcher High Profile New Media Congres 091123114846 Phpapp01
 

Dernier

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Facebook on Rails

  • 1. Facebook on Rails CardinalBlue info@cardinalblue.com Ruby Tuesday 2009.10.20 Friday, October 23, 2009
  • 2. 40% of all Internet Users in North America are on Facebook! 300 million Facebook users around the world Friday, October 23, 2009
  • 3. Facebook Trends ( ) 73 Friday, October 23, 2009
  • 4. Facebook Apps Boom Friday, October 23, 2009
  • 6. Demographic Trends • More female gamers • More younger (ages 8-15) gamers • More older (ages 50+) gamers Friday, October 23, 2009
  • 7. FB Games are Social • Trend #1: Virtual Worlds • e.g.,YoVille, PetSociety • Trend #2: Customization & Personalization • e.g., Nintendo’s “Mii” avatars, Buddy Poke • Trend #3: Collections and Wish Lists • e.g., Mafia Wars • Trend #4: Interaction and Engagement • Farm Town, FarmVille, Barn Buddy • Trend #5: Narrative and Missions Friday, October 23, 2009
  • 8. FB Games are Social • Trend #6: Gift Invites • e.g., Lil Green Patch, Give a Heart • Trend #7: Donations as Revenue • e.g., SpareChange, PayPal • Trend #8: Virtual Goods • e.g., Mafia Wars, PetSociety • Trend #9: Recruiting Users • e.g., FarmVille, Restaurant City, Tycoons • Trend #10: Capitalizing on Player Resources • e.g., All that Glitters, Photo-of-the-Day Friday, October 23, 2009
  • 9. FBML Application Architecture Friday, October 23, 2009
  • 10. Facebook apps on Rails • Rails 2.3.3 • Facebook API via Facebooker • Hosted on Heroku • Monitor via NewRelic Friday, October 23, 2009
  • 11. User model Facebook UIDs are 64-bit, so need bigint for User#id create_table :users, :id => false do |t| t.column :id, "bigint PRIMARY KEY", :null => false ... t.timestamps end Associations can be done based on user_id create_table :balloons t.column :user_id, :bigint ... t.timestamps end Friday, October 23, 2009
  • 12. Facebooker • Wrapper for Facebook API • Facebooker::User to query user data • Facebooker::Publisher for feeds/notifications Friday, October 23, 2009
  • 13. Facebooker • Wrapper for Facebook API • Facebooker::User to query user data • Facebooker::Publisher for feeds/notifications Friday, October 23, 2009
  • 14. Preload FQL • Facebooker::User to query user data • Since query can take 500ms or more, use Preload FQL to pre-query the data preload_fql = Hash.new preload_fql[:preload_user_data] = { :pattern => ".*", :query => "SELECT name,birthday_date FROM user WHERE uid={*user*};" } Facebooker::Admin.new(Facebooker::Session.create).set_app_pro perties({:preload_fql => preload_fql.to_json}) • Obtain the preloaded data on every page: params[:fb_sig_user_data] Friday, October 23, 2009
  • 15. Open Stream API • Facebooker::Publisher for feeds/notifications • Facebook has deprecated template bundles • Instead use the Open Stream API: <script> var attachment = {'media':[{'type':'image', 'src':'http:// cardinalblue.com/images/cblue_logo_white100.png', 'href':'http:// cardinalblue.com'}]}; Facebook.streamPublish('Hello Cardinal Blue', attachment); </script> Friday, October 23, 2009
  • 16. Functional tests with facebook_get test "requires-login page, logged in" do facebook_get :install assert_response :success assert_nil facebook_redirect_url end test "requires-login page, not logged in" do # access a page that requires login facebook_get :install, :fb_sig_user => nil assert_response :success assert_not_nil facebook_redirect_url assert facebook_redirect_url.match("http://www.facebook.com/install.php") end Friday, October 23, 2009
  • 18. Scaled to over 10000 requests per minute Friday, October 23, 2009
  • 19. Heroku features • Uses nginx, thin, postgres, Amazon EC2 • Easy Deployment: git push heroku master • Flexible Scaling: heroku dynos +1 • Free Memcache: Rails.cache • Delayed Job: facebook_session.send_notification(...) facebook_session.send_later(:send_notification,...) • New Relic Friday, October 23, 2009
  • 20. New Relic Facebooker Friday, October 23, 2009
  • 21. Can set up custom tracers: Facebook/query Facebook/notify Facebook/feed class NewrelicTracer def self.query yield end class << self add_method_tracer :query, 'Custom/Facebook/query' end end NewrelicTracer.query do location = facebook_session.user.current_location end Friday, October 23, 2009
  • 22. Observations • Facebook is growing • Facebook games are social • Rails + Facebooker = Facebook app • Heroku is fun (and scalable) Friday, October 23, 2009
  • 23. Thank you. http://cardinalblue.com/about jobs@cardinalblue.com Friday, October 23, 2009