how to avoid the latency trap and lessons about software design

46
How to avoid the latency trap and lessons about software design

Upload: tom-hughes-croucher

Post on 20-Jan-2015

1.647 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: How to avoid the latency trap and lessons  about software design

How to avoid the latency trap and lessons about

software design

Page 2: How to avoid the latency trap and lessons  about software design

Tom Hughes-Croucher

@sh1mmer

Page 3: How to avoid the latency trap and lessons  about software design

What is the latency trap?

Page 4: How to avoid the latency trap and lessons  about software design

Mobile

Page 5: How to avoid the latency trap and lessons  about software design

Web Service My Server

Page 6: How to avoid the latency trap and lessons  about software design

My Server Web Service

Page 7: How to avoid the latency trap and lessons  about software design

Optical Fibre

Page 8: How to avoid the latency trap and lessons  about software design

Web Service AT&T

Page 9: How to avoid the latency trap and lessons  about software design

Radio Waves

Page 10: How to avoid the latency trap and lessons  about software design

Web Service AT&T

Page 11: How to avoid the latency trap and lessons  about software design

AT&TWeb Service

Page 12: How to avoid the latency trap and lessons  about software design

AT&T

Web Services

Page 13: How to avoid the latency trap and lessons  about software design

Bigger than mobile?

Page 14: How to avoid the latency trap and lessons  about software design
Page 15: How to avoid the latency trap and lessons  about software design

Wifi sucks.

Page 16: How to avoid the latency trap and lessons  about software design

Ofcom study•UK study into Wifi interfence (PDF)

•Upto 90% of bandwidth used on protocol

•Many other sources of interference

•Baby monitors

•Microwaves

•Cordless Phones

Page 17: How to avoid the latency trap and lessons  about software design

Interference sucks.

Page 18: How to avoid the latency trap and lessons  about software design

So how do we fix it?

Page 19: How to avoid the latency trap and lessons  about software design

1. Reduce Requests

Page 20: How to avoid the latency trap and lessons  about software design

AT&T

Web Services

Page 21: How to avoid the latency trap and lessons  about software design

Server

Web Services

AT&T

Page 22: How to avoid the latency trap and lessons  about software design

Reducing requests

•Yahoo! Performance Guidelines

•http://developer.yahoo.com/performance

•Reduce web service requests

•Bundle requests from device logically

•Gzip all web service responses

Page 23: How to avoid the latency trap and lessons  about software design

2. Shape to packets

Page 24: How to avoid the latency trap and lessons  about software design

Indiana Packet and the Byte of Doom

Page 25: How to avoid the latency trap and lessons  about software design

Packet #1 Payload ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ..................................................................... ...........................................................

Packet #2 Payload .

Page 26: How to avoid the latency trap and lessons  about software design

1 extra byte means

1 extra packet

Page 27: How to avoid the latency trap and lessons  about software design

Reduce number of packets

Page 28: How to avoid the latency trap and lessons  about software design

Packet sizes

•Make sure static assets (JS, images, etc) fit in discrete packet boundaries

•Don’t forget Gzip

•Try and figure out ‘high latency’ connections to send inlined assets to

•E.g. detect ‘iPhone’

Page 29: How to avoid the latency trap and lessons  about software design

Packet Researchhttp://developer.yahoo.net/blog/archives/2009/10/a_engineers_gui.html

Page 30: How to avoid the latency trap and lessons  about software design

•What is YQL?

•Why is YQL bad-ass for mobile development?

•How you can use YQL in mobile development

•Examples

Page 31: How to avoid the latency trap and lessons  about software design

What is YQL?

Page 32: How to avoid the latency trap and lessons  about software design
Page 33: How to avoid the latency trap and lessons  about software design

var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…

…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…

http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2

http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c

??

????

??

Page 34: How to avoid the latency trap and lessons  about software design

var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…

…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…

http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2

http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c

??

????

??

Page 35: How to avoid the latency trap and lessons  about software design

http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c

…if (flickcurl_prepare(fc, "flickr.photos.geo.correctLocation", parameters, count)) { … }…

http://search.yahooapis.com/ImageSearchService/V1/imageSearch?appid=YahooDemo&query=Corvette&results=2

var map = new YMap(document.getElementById('map'));…var currentGeoPoint = new YGeoPoint( _c.Lat, _c.Lon ); map.addMarker(currentGeoPoint);…

YQL

Bindings

Page 36: How to avoid the latency trap and lessons  about software design

YQL

•Unified interface to Web services

•Self-describing to avoid documentation

•Uses a common way to return data

Page 37: How to avoid the latency trap and lessons  about software design

YQL is like SQL

•Uses SQL verbs

•Uses SQL syntax

•Returns rows of data

•Self-describing

•show tables;

•desc table;

Page 38: How to avoid the latency trap and lessons  about software design

Verbs• show - show tables;

• desc - desc search.web;

• select - select * from flickr.photos.recent;

• use

• insert

• update

• delete

Page 39: How to avoid the latency trap and lessons  about software design

Demohttp://developer.yahoo.com/yql/console

Page 40: How to avoid the latency trap and lessons  about software design

Server

Web Services

AT&T

Page 41: How to avoid the latency trap and lessons  about software design

YQL Example

Page 42: How to avoid the latency trap and lessons  about software design

select * from flickr.photos.info where

photo_id in (select id from flickr.photos.search where

query = “lolcats”)

Page 43: How to avoid the latency trap and lessons  about software design

Conclusion•Latency hurts anything wireless

•Fight latency by reducing connections

•Fight latency by reducing the number of unnecessary packets

•YQL can help you bundle your requests to mobile device without a dedicated backend

Page 44: How to avoid the latency trap and lessons  about software design

Application design

•Web

•Stateless scales

•Statelessness allows “combining”

•Statelessness encourages single-purpose functions

•RESTful!

Page 45: How to avoid the latency trap and lessons  about software design

ReST

•Representational State Transfer

•Roy Fielding Dissertation

•Transfer state with each request

Page 46: How to avoid the latency trap and lessons  about software design

follow me on twitter.com/sh1mm

er

Slides? Feedback? www.speakerrate.com/sh1mmer