Latency Kills
Optimize your apps for latency




Shishir Birmiwal
Software Engineer



                                 Go...
Is latency that bad?
Why all the fuss?
Lets take a pop quiz!




                        Google Confidential and Proprieta...
Question# 1




Have you closed a page
because it didn't load up in time?




                                     Google ...
Question# 2




Have you re-clicked links?




                             Google Confidential and Proprietary
Question# 3




How would you feel if you have to wait 15
seconds between views?




                                     ...
Latency Kills


• Amazon reported that 100ms of latency costs sales by 1%
• An additional 500ms latency saw Google search ...
Sources of latency
Why do we have latency?




                          Google Confidential and Proprietary   7
Sources of latency



             fetch page
                                               gadget xml

             fetc...
Kill latency
Optimize your app




                    Google Confidential and Proprietary   9
Optimize your app


• Batch requests
• Caches are your friends
• Minify static content
• Be lean and mean
• Think ahead
• ...
Optimize your app


Batch Requests
Put multiple independent requests together
var idspec = opensocial.newIdSpec({ quot;use...
Caches are your friends


Proxy Content
     Use gadgets.io.getProxyUrl(url) to get a proxy URL
     var imgUrl = gadgets....
Caches are your friends


Use cache effectively
• makeRequests are cached; specify refresh interval
• set HTTP cache-heade...
Optimize your apps


Minify static content
• re-compress images to smaller sizes
• serve smaller and gzipped JS/CSS files
...
Optimize your apps


Be lean and mean
lighter faster profile pages


• use images, not swfs
• use app data as cache
• use ...
Think ahead


• Expect user requests and prefetch content
• Preload content from your servers
    <ModulePrefs ...>
      ...
Best practices


• Show a “loading gif” image when expecting the user to wait
• Put Stylesheets at top
• Put Scripts at bo...
Demo time


Firefox extensions are your friends!
• Firebug
• Live HTTP Headers
• YSlow




                               ...
Thank You!
Optimize your app and save the day!




                                      Google Confidential and Proprieta...
Upcoming SlideShare
Loading in …5
×

Latency Kills by Shishir Birmiwal

2,622 views

Published on

Published in: Technology, News & Politics
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,622
On SlideShare
0
From Embeds
0
Number of Embeds
16
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Latency Kills by Shishir Birmiwal

  1. 1. Latency Kills Optimize your apps for latency Shishir Birmiwal Software Engineer Google Confidential and Proprietary 1
  2. 2. Is latency that bad? Why all the fuss? Lets take a pop quiz! Google Confidential and Proprietary 2
  3. 3. Question# 1 Have you closed a page because it didn't load up in time? Google Confidential and Proprietary
  4. 4. Question# 2 Have you re-clicked links? Google Confidential and Proprietary
  5. 5. Question# 3 How would you feel if you have to wait 15 seconds between views? Google Confidential and Proprietary
  6. 6. Latency Kills • Amazon reported that 100ms of latency costs sales by 1% • An additional 500ms latency saw Google search usage drop by 20% • Users perceive Quality and Ease of Use with lower latency Google Confidential and Proprietary
  7. 7. Sources of latency Why do we have latency? Google Confidential and Proprietary 7
  8. 8. Sources of latency fetch page gadget xml fetch gadget iframe fetch social data Client fetch backend data Container Application Browser (orkut) backend data Backend content render Google Confidential and Proprietary
  9. 9. Kill latency Optimize your app Google Confidential and Proprietary 9
  10. 10. Optimize your app • Batch requests • Caches are your friends • Minify static content • Be lean and mean • Think ahead • Best practices Google Confidential and Proprietary
  11. 11. Optimize your app Batch Requests Put multiple independent requests together var idspec = opensocial.newIdSpec({ quot;userIdquot; : quot;OWNERquot;, quot;groupIdquot; : quot;FRIENDSquot; }); var fields = [ quot;AppField1quot;, quot;AppField2quot;, quot;AppField3quot; ]; var req = opensocial.newDataRequest(); req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER), quot;get_ownerquot;); req.add(req.newFetchPeopleRequest(idspec), quot;get_friendsquot;); req.add(req.newFetchPersonAppDataRequest(idSpec, fields), quot;owner_dataquot;); req.send(response); Google Confidential and Proprietary
  12. 12. Caches are your friends Proxy Content Use gadgets.io.getProxyUrl(url) to get a proxy URL var imgUrl = gadgets.io.getProxyUrl('http://example.org/image.png'); var html = '<img src=”' + imgUrl + '”>'; Content-rewrite Automatically rewrite URLs to fetch from cache <Optional feature=”content-rewrite”> <Param name=”include-urls”>.*</Param> <Param name=”exclude-urls”></Param> <Param name=”include-tags”>img,script,embed,link,style</Param> </Optional> http://www.example.org/image.png becomes something like: http://www1.orkut.gmodules.com/gadgets/proxy?url=http://example.org/image.png Google Confidential and Proprietary
  13. 13. Caches are your friends Use cache effectively • makeRequests are cached; specify refresh interval • set HTTP cache-headers effectively BYO cache • store user specific data in app data – faster to access • cache global info in app data  e.g. high scores  update content in app data from backend as required Google Confidential and Proprietary
  14. 14. Optimize your apps Minify static content • re-compress images to smaller sizes • serve smaller and gzipped JS/CSS files • concat. JS/CSS files to reduce number of fetches • include JS/CSS in gadget XML if possible Google Confidential and Proprietary
  15. 15. Optimize your apps Be lean and mean lighter faster profile pages • use images, not swfs • use app data as cache • use owner/viewer only signed makeRequest • may choose to show owner-only data on profile pages • don't load unnecessary files Google Confidential and Proprietary
  16. 16. Think ahead • Expect user requests and prefetch content • Preload content from your servers <ModulePrefs ...> ... <Preload href=”http://example.com/topScores”> </ModulePrefs> or <Preload href=”http://example.com/myScores” authz=signed views=”profile,canvas” signViewer=false> Google Confidential and Proprietary
  17. 17. Best practices • Show a “loading gif” image when expecting the user to wait • Put Stylesheets at top • Put Scripts at bottom • Post-load components • Use Google's cached version of JS libraries Google Confidential and Proprietary
  18. 18. Demo time Firefox extensions are your friends! • Firebug • Live HTTP Headers • YSlow Google Confidential and Proprietary
  19. 19. Thank You! Optimize your app and save the day! Google Confidential and Proprietary 19

×