SlideShare una empresa de Scribd logo
1 de 54
Descargar para leer sin conexión
Monday, 18 April 2011
What You Don't Know
                  About Clouds Could
                      Kill You!!!
Monday, 18 April 2011
What we learned
               about the cloud by
              building and scaling
                  a corporate
                    intranet.

Monday, 18 April 2011
the
                • External infrastructure
                • Easy commissioning " Easy scaling
                • Less maintenance
                • Focus on what makes your app
                        different




Monday, 18 April 2011
But sometimes...




Monday, 18 April 2011
TIMTOWTDI
              (pronounced Tim Toady)



Monday, 18 April 2011
TIMTOWTDIBSCINABTE

                        (pronounced Tim Toady Bicarbonate)




Monday, 18 April 2011
@tangleofwire

                gar@55degrees.co.uk


Monday, 18 April 2011
MINT
Monday, 18 April 2011
Intranet




Monday, 18 April 2011
Google APIs



                        Intranet




Monday, 18 April 2011
Google APIs



                        Intranet




                        HR Server

Monday, 18 April 2011
Google APIs



                         Intranet



                        HR Interface



                         HR Server

Monday, 18 April 2011
Google APIs                Google Sites



                         Intranet



                        HR Interface



                         HR Server

Monday, 18 April 2011
Scaling

                • Eliminate N+1 queries
                • Add database indexes
                • Page, Fragment, Action caching
                • Background jobs



Monday, 18 April 2011
Other best practices

                • Metrics & useful debugging data
                • Notifications & error numbers
                • Monitoring




Monday, 18 April 2011
Max load
                        (many simultaneous web requests)




Monday, 18 April 2011
Google Sites



                        Intranet




Monday, 18 April 2011
AJAX polling
                          (are we there yet?)




Monday, 18 April 2011
i.Reduce number of HTTP calls




Monday, 18 April 2011
Annual leave
                • Request
                • View summary




Monday, 18 April 2011
Intranet



                        HR Interface



                         HR Server

Monday, 18 April 2011
API wrappers
                        (separate the things that change)




Monday, 18 April 2011
Integration
                           tests
                         (how are you today?)




Monday, 18 April 2011
ii.Be prepared for APIs to change




Monday, 18 April 2011
People pages
                • Directory
                • HR API
                • Google APIs




Monday, 18 April 2011
Google APIs



                         Intranet



                        HR Interface



                         HR Server

Monday, 18 April 2011
Sync
                        (avoid unnecessary HTTP requests)




Monday, 18 April 2011
Timeouts
                        (discard requests or retry later)




Monday, 18 April 2011
require 'net/http'
           url = URI("http://example.com/feed")
           req = Net::HTTP.new(url.host, url.port)

           req.read_timeout = HTTP_READ_TIMEOUT
           req.open_timeout = HTTP_OPEN_TIMEOUT




Monday, 18 April 2011
Exponential
                          backoff
                (handle intermittent network problems)




Monday, 18 April 2011
times_tried = 0
           max_retries = 5

           begin
             times_tried += 1
             feed = HRApi.get_employee_feed
           rescue => e
             if times_tried < max_retries
               sleep 4 ** times_tried
               retry
             end
             raise e, "max retries reached"
           end

Monday, 18 April 2011
Isolate
                        components
                  (one error shouldn’t stop everything)




Monday, 18 April 2011
Fail
                        (and go to the   pub   cache)




Monday, 18 April 2011
iii.Expect services to fail




Monday, 18 April 2011
Other considerations
                • HTTP caching
                • Webhooks




Monday, 18 April 2011
HTTP caching
                           (anything new?)




Monday, 18 April 2011
Intranet




                        HR service

Monday, 18 April 2011
Intranet


                           GET /user/23




                        HR service

Monday, 18 April 2011
Intranet


                           { user 23 + ETag }




                        HR service

Monday, 18 April 2011
Intranet




                        HR service

Monday, 18 April 2011
Intranet


                           GET /user/23 + ETag




                        HR service

Monday, 18 April 2011
Intranet


                           304 Not Modified




                        HR service

Monday, 18 April 2011
#users_controller
           def show
             @user = User.find(params[:id])
             expires_in 24.hours
             if stale? (:etag => @user,
                 :last_modified => @user.updated_at)
               respond_to do |wants|
                  wants.html
                  wants.xml { render :xml => @user }
               end
             end
           end


Monday, 18 April 2011
#client code
           def get_user
             u = User.find(23)
             return u if u.max_age < Time.now.utc

             headers = {
               'If-None-Match' => u.etag,
               'If-Modifed-Since' => u.last_modifed
             }
             ...
             data = request.get(path, headers)
             ...
             return u if response.code == 304
             return u.update_attributes(data)
           end

Monday, 18 April 2011
Webhooks
                        (have your people call my people)




Monday, 18 April 2011
Intranet




                 HR service

Monday, 18 April 2011
Intranet

                            GET /generate_report?
                                callback=/foo




                 HR service

Monday, 18 April 2011
Intranet




                                   working...
                 HR service

Monday, 18 April 2011
Intranet

                               POST /foo
                          { fascinating data }




                 HR service

Monday, 18 April 2011
iv.Reduce time and cost of HTTP
                      calls




Monday, 18 April 2011
Rules of thumb
       i.Reduce number of HTTP calls

       ii.Be prepared for APIs to change

       iii.Expect services to fail

       iv.Reduce time and cost of HTTP calls




Monday, 18 April 2011
Thanks
           $ git log --format='%aN' | sort -u

           @rogerbooth
           @mrloop
           @cframe
           @grahamsavage
           @douglasfshearer
           @aw221
           @jaz303
           @lenary
           @subblue
Monday, 18 April 2011
Questions?




Monday, 18 April 2011

Más contenido relacionado

Similar a Building and Scaling a Corporate Intranet in the Cloud

Migrating To Rails 3, An In-house Developers Perspective
Migrating To Rails 3, An In-house Developers PerspectiveMigrating To Rails 3, An In-house Developers Perspective
Migrating To Rails 3, An In-house Developers PerspectiveMark Johnson
 
OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)Michael Bleigh
 
Writing for people
Writing for peopleWriting for people
Writing for peoplefreerobby
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsMuhammad Ikram Ul Haq
 
Machines Talking To Themselves - Internet Of Things 101
Machines Talking To Themselves - Internet Of Things 101Machines Talking To Themselves - Internet Of Things 101
Machines Talking To Themselves - Internet Of Things 101Martin Spindler
 
Practical project automation (PyGrunn conference)
Practical project automation (PyGrunn conference)Practical project automation (PyGrunn conference)
Practical project automation (PyGrunn conference)Reinout van Rees
 
OpenData, Web Semântica e afins.
OpenData, Web Semântica e afins.OpenData, Web Semântica e afins.
OpenData, Web Semântica e afins.Alexandre Gomes
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalkstoJason Diller
 
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...Atit Patumvan
 
The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11Kaitlin Thaney
 

Similar a Building and Scaling a Corporate Intranet in the Cloud (13)

RailsConf 2011 Keynote
RailsConf 2011 KeynoteRailsConf 2011 Keynote
RailsConf 2011 Keynote
 
Migrating To Rails 3, An In-house Developers Perspective
Migrating To Rails 3, An In-house Developers PerspectiveMigrating To Rails 3, An In-house Developers Perspective
Migrating To Rails 3, An In-house Developers Perspective
 
OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)OmniAuth: From the Ground Up (RailsConf 2011)
OmniAuth: From the Ground Up (RailsConf 2011)
 
Writing for people
Writing for peopleWriting for people
Writing for people
 
Using+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applicationsUsing+javascript+to+build+native+i os+applications
Using+javascript+to+build+native+i os+applications
 
Machines Talking To Themselves - Internet Of Things 101
Machines Talking To Themselves - Internet Of Things 101Machines Talking To Themselves - Internet Of Things 101
Machines Talking To Themselves - Internet Of Things 101
 
Practical project automation (PyGrunn conference)
Practical project automation (PyGrunn conference)Practical project automation (PyGrunn conference)
Practical project automation (PyGrunn conference)
 
OpenData, Web Semântica e afins.
OpenData, Web Semântica e afins.OpenData, Web Semântica e afins.
OpenData, Web Semântica e afins.
 
Beyond Page Objects
Beyond Page ObjectsBeyond Page Objects
Beyond Page Objects
 
Node js techtalksto
Node js techtalkstoNode js techtalksto
Node js techtalksto
 
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...
Create a Professional Blog with WordPress: Chapter 6 Customizing Your Sites w...
 
The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11The Digital Toolbox - a discussion -Science Online '11
The Digital Toolbox - a discussion -Science Online '11
 
Webops dashboards
Webops dashboardsWebops dashboards
Webops dashboards
 

Más de Paul Cameron

13 good ideas_4_webvideos
13 good ideas_4_webvideos13 good ideas_4_webvideos
13 good ideas_4_webvideosPaul Cameron
 
Draught buster workshop guide for leap
Draught buster workshop guide for leapDraught buster workshop guide for leap
Draught buster workshop guide for leapPaul Cameron
 
Children and young people service plan consultation update
Children and young people service plan consultation updateChildren and young people service plan consultation update
Children and young people service plan consultation updatePaul Cameron
 
Rc resp.loch lib.08.12.10
Rc resp.loch lib.08.12.10Rc resp.loch lib.08.12.10
Rc resp.loch lib.08.12.10Paul Cameron
 
Lochwinnoch library presentation 24 11 10
Lochwinnoch library presentation 24 11 10Lochwinnoch library presentation 24 11 10
Lochwinnoch library presentation 24 11 10Paul Cameron
 

Más de Paul Cameron (8)

13 good ideas_4_webvideos
13 good ideas_4_webvideos13 good ideas_4_webvideos
13 good ideas_4_webvideos
 
Draught buster workshop guide for leap
Draught buster workshop guide for leapDraught buster workshop guide for leap
Draught buster workshop guide for leap
 
Children and young people service plan consultation update
Children and young people service plan consultation updateChildren and young people service plan consultation update
Children and young people service plan consultation update
 
Councillor email
Councillor emailCouncillor email
Councillor email
 
Mare email
Mare emailMare email
Mare email
 
Lag poster
Lag posterLag poster
Lag poster
 
Rc resp.loch lib.08.12.10
Rc resp.loch lib.08.12.10Rc resp.loch lib.08.12.10
Rc resp.loch lib.08.12.10
 
Lochwinnoch library presentation 24 11 10
Lochwinnoch library presentation 24 11 10Lochwinnoch library presentation 24 11 10
Lochwinnoch library presentation 24 11 10
 

Building and Scaling a Corporate Intranet in the Cloud

  • 2. What You Don't Know About Clouds Could Kill You!!! Monday, 18 April 2011
  • 3. What we learned about the cloud by building and scaling a corporate intranet. Monday, 18 April 2011
  • 4. the • External infrastructure • Easy commissioning " Easy scaling • Less maintenance • Focus on what makes your app different Monday, 18 April 2011
  • 6. TIMTOWTDI (pronounced Tim Toady) Monday, 18 April 2011
  • 7. TIMTOWTDIBSCINABTE (pronounced Tim Toady Bicarbonate) Monday, 18 April 2011
  • 8. @tangleofwire gar@55degrees.co.uk Monday, 18 April 2011
  • 11. Google APIs Intranet Monday, 18 April 2011
  • 12. Google APIs Intranet HR Server Monday, 18 April 2011
  • 13. Google APIs Intranet HR Interface HR Server Monday, 18 April 2011
  • 14. Google APIs Google Sites Intranet HR Interface HR Server Monday, 18 April 2011
  • 15. Scaling • Eliminate N+1 queries • Add database indexes • Page, Fragment, Action caching • Background jobs Monday, 18 April 2011
  • 16. Other best practices • Metrics & useful debugging data • Notifications & error numbers • Monitoring Monday, 18 April 2011
  • 17. Max load (many simultaneous web requests) Monday, 18 April 2011
  • 18. Google Sites Intranet Monday, 18 April 2011
  • 19. AJAX polling (are we there yet?) Monday, 18 April 2011
  • 20. i.Reduce number of HTTP calls Monday, 18 April 2011
  • 21. Annual leave • Request • View summary Monday, 18 April 2011
  • 22. Intranet HR Interface HR Server Monday, 18 April 2011
  • 23. API wrappers (separate the things that change) Monday, 18 April 2011
  • 24. Integration tests (how are you today?) Monday, 18 April 2011
  • 25. ii.Be prepared for APIs to change Monday, 18 April 2011
  • 26. People pages • Directory • HR API • Google APIs Monday, 18 April 2011
  • 27. Google APIs Intranet HR Interface HR Server Monday, 18 April 2011
  • 28. Sync (avoid unnecessary HTTP requests) Monday, 18 April 2011
  • 29. Timeouts (discard requests or retry later) Monday, 18 April 2011
  • 30. require 'net/http' url = URI("http://example.com/feed") req = Net::HTTP.new(url.host, url.port) req.read_timeout = HTTP_READ_TIMEOUT req.open_timeout = HTTP_OPEN_TIMEOUT Monday, 18 April 2011
  • 31. Exponential backoff (handle intermittent network problems) Monday, 18 April 2011
  • 32. times_tried = 0 max_retries = 5 begin times_tried += 1 feed = HRApi.get_employee_feed rescue => e if times_tried < max_retries sleep 4 ** times_tried retry end raise e, "max retries reached" end Monday, 18 April 2011
  • 33. Isolate components (one error shouldn’t stop everything) Monday, 18 April 2011
  • 34. Fail (and go to the pub cache) Monday, 18 April 2011
  • 35. iii.Expect services to fail Monday, 18 April 2011
  • 36. Other considerations • HTTP caching • Webhooks Monday, 18 April 2011
  • 37. HTTP caching (anything new?) Monday, 18 April 2011
  • 38. Intranet HR service Monday, 18 April 2011
  • 39. Intranet GET /user/23 HR service Monday, 18 April 2011
  • 40. Intranet { user 23 + ETag } HR service Monday, 18 April 2011
  • 41. Intranet HR service Monday, 18 April 2011
  • 42. Intranet GET /user/23 + ETag HR service Monday, 18 April 2011
  • 43. Intranet 304 Not Modified HR service Monday, 18 April 2011
  • 44. #users_controller def show @user = User.find(params[:id]) expires_in 24.hours if stale? (:etag => @user, :last_modified => @user.updated_at) respond_to do |wants| wants.html wants.xml { render :xml => @user } end end end Monday, 18 April 2011
  • 45. #client code def get_user u = User.find(23) return u if u.max_age < Time.now.utc headers = { 'If-None-Match' => u.etag, 'If-Modifed-Since' => u.last_modifed } ... data = request.get(path, headers) ... return u if response.code == 304 return u.update_attributes(data) end Monday, 18 April 2011
  • 46. Webhooks (have your people call my people) Monday, 18 April 2011
  • 47. Intranet HR service Monday, 18 April 2011
  • 48. Intranet GET /generate_report? callback=/foo HR service Monday, 18 April 2011
  • 49. Intranet working... HR service Monday, 18 April 2011
  • 50. Intranet POST /foo { fascinating data } HR service Monday, 18 April 2011
  • 51. iv.Reduce time and cost of HTTP calls Monday, 18 April 2011
  • 52. Rules of thumb i.Reduce number of HTTP calls ii.Be prepared for APIs to change iii.Expect services to fail iv.Reduce time and cost of HTTP calls Monday, 18 April 2011
  • 53. Thanks $ git log --format='%aN' | sort -u @rogerbooth @mrloop @cframe @grahamsavage @douglasfshearer @aw221 @jaz303 @lenary @subblue Monday, 18 April 2011