timecard : controlling user-perceived delays in server-based mobile applications

88
Timecard: Controlling User-Perceived Delays in Server-Based Mobile Applications MIT, Microsoft Research Lenin Ravindranath, Jitendra Padhye, Ratul Mahajan, Hari Balakrishnan

Upload: calla

Post on 23-Feb-2016

39 views

Category:

Documents


0 download

DESCRIPTION

Timecard : Controlling User-Perceived Delays in Server-Based Mobile Applications. Lenin Ravindranath, Jitendra Padhye, Ratul Mahajan, Hari Balakrishnan. MIT, Microsoft Research. Cloud Services. Mobile Apps. Response Time Matters. Users are impatient. Rendering. User interaction. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard:Controlling User-Perceived Delays in

Server-Based Mobile Applications

MIT, Microsoft Research

Lenin Ravindranath, Jitendra Padhye, Ratul Mahajan, Hari Balakrishnan

Page 2: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Cloud Services

Mobile Apps

Page 3: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Response Time MattersUsers are impatient

Page 4: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications
Page 5: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

User interaction Rendering

User-perceived delay

Tightly control

Page 6: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

App App

ServerUplink Downlink

User interaction Rendering

Server processing delay

App processing delay

Appprocessing delayRequest

transfer delayResponse

transfer delay

User-perceived delay

Tightly control

Page 7: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

ServerUplink Downlink

Server delayControl

App AppUser interaction Rendering

Server processing delay

User-perceived delay

Tightly control

Control Server Delay

Page 8: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Request Response

Deadline

Server processing

Controlling the Server Delay

• Trade-off quality of result for processing time– More time to process, better quality results

Server

Page 9: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Request Response

Deadline

Controlling the Server Delay

WorkerWorker

Worker

Worker

Worker

Server

Page 10: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Request Response

Deadline

Controlling the Server Delay

WorkerWorker

Worker

Worker

Worker

Better result

Server

Page 11: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Deadline

Controlling the Server Delay

Server

Server processing

• Servers keep fixed deadlines– No consideration about external delays– Assume constant external delays

Assumed external delay

Assumed external delay

Page 12: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Device type Data size

TCP stateTCP state

Device type

Significant Variability in External Delays

App App

Server

User interaction Rendering

Server processing

Reading sensors

Radio state

Network(3G, WiFi, LTE, ..)

RTT, tput

Highly variable[AppInsight – OSDI ’12]

Page 13: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Significant Variability in External Delays

Server

• Client with high external delays– Poor end-to-end response time

• Client with low external delays– Do not produce the best quality result

Deadline

Page 14: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Significant Variability in External Delays

Server

Servers should adapt to external delaysto control the user-perceived delay

Page 15: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Significant Variability in External Delays

Server

Deadline

Page 16: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Significant Variability in External Delays

Server

Adapt

Page 17: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Significant Variability in External Delays

Server

User interaction Rendering

End-to-end deadline

Adapt

App App

Page 18: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

Page 19: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Time elapsed since user interaction

Predicted downlink & app processing delay

Adapt

Page 20: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Desired end-to-end delay

Adapt Processing Time

Page 21: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Processing Time

Trade-off on quality of the result

Desired end-to-end delay

Page 22: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Response

Desired end-to-end delay

Page 23: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Response

Desired end-to-end delay

Page 24: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Better quality result

Desired end-to-end delay

Page 25: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Time elapsed since user interaction

Predicted downlink & app processing delay

Page 26: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Challenges

Server

App App

Page 27: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Challenges

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Server

App

UI dispatcherWeb callback

AppHighly asynchronous

Page 28: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Challenges

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

Transaction

Highly asynchronous

Page 29: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Challenges

Server

App App

GetElapsedTime();

No single reference clock

Variable network delaysand processing delays

PredictRemainingTime(responseSize);

Transaction

Highly asynchronous

Page 30: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

Server

App App

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Transaction

Transaction Tracking

TimeSync Delay Predictors

Page 31: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App

App Instrument

er

InstrumentedApp

Service

Developer

Timecard.dll

GetElapsedTime();PredictRemainingTime

(responseSize);

Desired end-to-end delay

config

App Store

Page 32: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

Server

App App

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Transaction

Transaction Tracking

TimeSync Delay Predictors

Page 33: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

Server

App App

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Transaction

Transaction Tracking

TimeSync Delay Predictors

Page 34: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

Transaction

Page 35: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Track across thread boundaries o at the app and at the server

Page 36: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

Track between app and server

Page 37: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

Transaction

Page 38: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

TC

TC

TC

TC

TC

TC

Transaction context (TC) attached to every thread– Carry along timestamps, transaction information

Page 39: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

• Event handler – create new Transaction context (TC)– Timestamp and attach to thread

• Asynchronous call – Pass TC from current thread to callback thread– Pass TC by detouring callbacks [AppInsight – OSDI ‘12]

Page 40: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

Page 41: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

TC

HTTP[“x-Timecard-Request”]

TC

• Web Request – pass TC from current thread to server– Encode TC in a special HTTP header

• Request handler at server – Parse TC and attach to server thread

Page 42: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

TC

TC

Page 43: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Server Threads

Transaction Tracking

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

Spawn workers

Send response

UI dispatcherWeb callback

Server

App App

Request handler

TC

TC

TC

TC

TC

TC

TC

TC

TC

TC

TC

GetElapsedTime();

Page 44: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

Server

App App

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Transaction

Transaction Tracking

TimeSync Delay Predictors

Page 45: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

GPS

• Sync with Cell Tower– Off my several seconds to minutes

• GPS– Does not work indoors

• Probing

Probe

Page 46: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Instrument app to automatically send probes

Probe

Symmetric Asymmetric

Clock offsetClock drift

Smartphone clock Server clock

Page 47: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Probe

Radio wakeup delay

with large extra delay

Active

IdleIdle

Network Radio States

Page 48: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Queuing delay

with large extra delay

Probe

Network traffic

Active

Idle

Active

Page 49: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Network busy

Radio idle

> 100ms error

min RTT

Page 50: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Optimal time to send the probes Radio is active No network traffic from the phone

Need to be radio-aware and network-aware

Probe

Page 51: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

Server

App App

Page 52: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

UI Thread

Background Thread

Background Thread

Thread start

GPS start

Web requestGPS callback

Event handler

App

Probe

Page 53: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

TimeSync

~5ms error

Network busy

Radio idleTimecard

min RTT

Page 54: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime();

Time elapsed since user interaction

Page 55: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Remaining Time

App App

Server

PredictRemainingTime(responseSize);

Downlink delay App processing delay

Page 56: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Downlink Delay

Response sizeLatencyThroughput

Loss rate

TCP window state• Most transfers are short– Median – 3KB– 90% percentile – 37KB

Analysis of 4000 apps

• Cellular networks– High-bandwidth, rare-loss,

high-latency,

• 99% transfers over HTTP– TCP window state matters -> multiple RTTs

Page 57: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Downlink Delay

TCP Window

1 extra RTT

Page 58: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Downlink Delay

Response sizeLatency

TCP parameters

Determined by RTT Number of round trips

Page 59: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Downlink Delay

• Use recent estimate of RTT– Use time sync probes

Read TCP window state

• Read TCP window state at serverMiddlebo

x• Do not work with middleboxes

– Split-TCP connection

• TCP window state at the middlebox matters– No easy way to estimate

TCP window state

Build an empirical data-driven model

RTT

Number of round trips

Page 60: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Downlink DelayPredictRemainingTime(responseSize);

Learn

• Decision tree model– Response size– Recent RTT– Network provider– Bytes already transferred in

the TCP connection o Proxy for TCP window state at the

middlebox

Middlebox

Downlink Delay Predictor

Page 61: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

• 20 users + controlled experiments– 1 month, two cities

• 250,000 downloads– 1 KB to 500KB

• AT&T, T-Mobile, Sprint, Verizon, Wi-Fi– 3G, 4G (HSPA+), LTE

• Indoors, outdoors, static, walking, driving

Predicting Downlink Delay

• Split the data into training and testing

Wi-Fi Median error - 12 ms, 90th percentile - 31ms

Cellular Median error - 17 ms, 90th percentile - 86 ms

Page 62: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting App Processing Delay

App App

Server

PredictRemainingTime(responseSize);

Page 63: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting Remaining Time

App App

Server

PredictRemainingTime(responseSize);

Processing Delay Predictor

Downlink Delay Predictor

Page 64: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

D

e rd = D – e – r

Desired end-to-end delay

Page 65: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

• Mobile ads service• Twitter analysis service

Deployment

Page 66: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads ServiceContextual ads to mobile apps [Mobisys ’13]

Page 67: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads Service

Fetch and process ads for keywords

Extract keywords Render adSend keywordsBest Ad

Page 68: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads Service

Extract keywords Render adSend keywordsAd

Ad providerAd provider

Ad provider

Ad provider

Ad provider

A

Keywords

Page 69: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads Service

Extract keywords Render adSend keywordsAd

Page 70: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads Service

Extract keywords Render adSend keywordsAd

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Processing Time

Page 71: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Mobile Ads Service• ~200,000 transactions• Significant variability in external delay

Within 50ms of the target delay 90% of the time

With Timecard

Without Timecard

Target delay

Page 72: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

• Mobile ads service• Twitter analysis service

Deployment

Page 73: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Twitter Analysis Service

Fetch from Twitter and analyze

Get keyword Parse and renderSend keywordScore and tweets

Page 74: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Twitter Analysis Service

Fetch from Twitter and analyze

Get keyword Parse and renderSend keywordScore and tweets

Page 75: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Twitter Analysis ServiceGetElapsedTime(

); PredictRemainingTime(responseSize);

Adapt Processing Time

Adapt Response

Get keyword Parse and renderSend keywordScore and tweets

10KB to 50 KB

Page 76: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Twitter Analysis Service• ~150,000 transactions• Adapt server processing time in steps of 150ms

With Timecard

Without Timecard

Target delay

Tightly control end-to-end delay with Timecard

Page 77: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

• 0.1% runtime overhead

• Less than 1% memory overhead

• Less than 1% network overhead

• Negligible battery overhead

Timecard Overhead

Page 78: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Limitations

• Bootstrapping– Training the downlink and app processing delay predictors– Learn app processing delay for every transaction type– Turn off adaptation till enough data is collected

• Complex transactions– Multiple parallel or serial requests– Elapsed time will work!– Need to model complex interactions or need developer help

Page 79: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Processing Time

Adapt Response

End-to-end deadline

Page 80: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Adapt Resources Used

End-to-end deadline

Page 81: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);Request Prioritization

End-to-end deadline

Page 82: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

GetElapsedTime();

PredictRemainingTime(responseSize);

Deadlines

Scheduler

Page 83: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

• Controlling end-to-end delays– Elapsed time– Prediction on remaining time

• Can be applied in several context

Take-Away

Adapt quality of the paper

SOSP Deadline

GetElapsedTime();

PredictRemainingTime(paper);

Page 84: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Timecard

App App

Server

GetElapsedTime(); PredictRemainingTi

me(responseSize);

Time elapsed since user interaction

Predicted downlink & app processing delay

Page 85: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Backup

Page 86: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting App Processing Delay

AppResponse size

• Correlated with response size

Analysis of AppInsight data 1653 types of transactions

Response size (KB)

Proc

essin

g de

lay

(ms)

Page 87: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting App Processing Delay

AppResponse size• Parsing delay

– Correlated with data size• Rendering delay– Correlated with data size

• Dependent on device type– Processing speed

• Correlated with response size

Analysis of AppInsight data 1653 types of transactions

Page 88: Timecard : Controlling User-Perceived Delays in  Server-Based Mobile Applications

Predicting App Processing Delay

App

PredictRemainingTime(responseSize);

Processing Delay Predictor

Learn

• Decision tree model– Response size– Device type

Analysis of AppInsight data 1653 types of transactions

Median error - 8ms90th percentile error - 100ms