metrics - coda hale€¦ · the enterprise social network. saturday, april 9, 2011

248
METRICS METRICS EVERYWHERE Saturday, April 9, 2011

Upload: others

Post on 07-Jun-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

METRICS

METRICS EVERYWHERESaturday, April 9, 2011

Page 2: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

METRICS

METRICS EVERYWHERESaturday, April 9, 2011

Page 3: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Make better decisions by using numbers.

Saturday, April 9, 2011

Page 4: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Coda Hale@coda

github.com/codahale

Saturday, April 9, 2011

Page 5: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

www.yammer.comThe enterprise social network.

Saturday, April 9, 2011

Page 6: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

I write code.

Saturday, April 9, 2011

Page 7: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

But that’s notactually my job.

Saturday, April 9, 2011

Page 8: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

code

Saturday, April 9, 2011

Page 9: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

codebusiness

value

Saturday, April 9, 2011

Page 10: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

What the hell is business value?

Saturday, April 9, 2011

Page 11: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

A new feature.

Saturday, April 9, 2011

Page 12: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

An improvedexisting feature.

Saturday, April 9, 2011

Page 13: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Fewer bugs.

Saturday, April 9, 2011

Page 14: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Not pissing our users off with a slow site.

Saturday, April 9, 2011

Page 15: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Not pissing our users off with a slow site.

ugly

Saturday, April 9, 2011

Page 16: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Not pissing our users off with a slow site.

uglypretty

Saturday, April 9, 2011

Page 17: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Making futurechanges easier.

Saturday, April 9, 2011

Page 18: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Adding a unit test before fixing that bug.

Saturday, April 9, 2011

Page 19: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Business value is anything which makes people more likely to

give us money.

Saturday, April 9, 2011

Page 20: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We want to generate more business value.

Saturday, April 9, 2011

Page 21: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We need to makebetter decisionsabout our code.

Saturday, April 9, 2011

Page 22: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Our code generates business valuewhen it runs.

Saturday, April 9, 2011

Page 23: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Our code generates business valuewhen it runs,

not when we write it.

Saturday, April 9, 2011

Page 24: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We need to knowwhat our code does

when it runs.

Saturday, April 9, 2011

Page 25: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We can’t do this unless we measure it.

Saturday, April 9, 2011

Page 26: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Why measure it?

Saturday, April 9, 2011

Page 27: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

territorymap ≠

Saturday, April 9, 2011

Page 28: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

cityofSanFrancisco

mapof

SanFrancisco

Saturday, April 9, 2011

Page 29: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

thewayitis

thewaywetalk

Saturday, April 9, 2011

Page 30: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

thethinginitself

thething

wethink of

Saturday, April 9, 2011

Page 31: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

realityperception ≠

Saturday, April 9, 2011

Page 32: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 33: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We have amental model

of what our code does.

Saturday, April 9, 2011

Page 34: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

It’s a mental model.It’s not the code.

Saturday, April 9, 2011

Page 35: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

It is often wrong.

Saturday, April 9, 2011

Page 36: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Confusion.

Saturday, April 9, 2011

Page 37: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“This code can’t possibly work.”

Saturday, April 9, 2011

Page 38: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

(It works.)

Saturday, April 9, 2011

Page 39: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 40: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“This code can’t possibly fail.”

Saturday, April 9, 2011

Page 41: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

(It fails.)

Saturday, April 9, 2011

Page 42: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 43: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Which is faster?

Saturday, April 9, 2011

Page 44: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Which is faster?items.sort_by { |i| i.name }

Saturday, April 9, 2011

Page 45: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Which is faster?items.sort_by { |i| i.name }

items.sort { |a, b| a.name <=> b.name }

Saturday, April 9, 2011

Page 46: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We don’t know.

Saturday, April 9, 2011

Page 47: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We don’t know.

def sort_by(&blk) sleep(100) # FIXME: I AM POISON super(&blk)end

Saturday, April 9, 2011

Page 48: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We don’t know.

def sort_by(&blk) sleep(100) # FIXME: I AM POISON super(&blk)end

def sort(&blk) # TODO: make not explode raise Exception.new("Haw haw!")end

Saturday, April 9, 2011

Page 49: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We can’t know untilwe measure it.

Saturday, April 9, 2011

Page 50: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

This affects how we make decisions.

Saturday, April 9, 2011

Page 51: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“Our application is slow. This page takes 500ms.

Fix it.”

Saturday, April 9, 2011

Page 52: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find the bottleneck!

Saturday, April 9, 2011

Page 53: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find the bottleneck!

SQL Query

Saturday, April 9, 2011

Page 54: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find the bottleneck!

SQL Query

Template Rendering

Saturday, April 9, 2011

Page 55: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find the bottleneck!

SQL Query

Template Rendering

Session Storage

Saturday, April 9, 2011

Page 56: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We don’t know.

Saturday, April 9, 2011

Page 57: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find The Bottleneck 2.0!

SQL Query

Template Rendering

Session Storage

Saturday, April 9, 2011

Page 58: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find The Bottleneck 2.0!

SQL Query

Template Rendering

Session Storage

53ms

Saturday, April 9, 2011

Page 59: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find The Bottleneck 2.0!

SQL Query

Template Rendering

Session Storage

53ms

1ms

Saturday, April 9, 2011

Page 60: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find The Bottleneck 2.0!

SQL Query

Template Rendering

Session Storage

53ms

1ms

315ms

Saturday, April 9, 2011

Page 61: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Find The Bottleneck 2.0!

SQL Query

Template Rendering

Session Storage

53ms

1ms

315ms

Saturday, April 9, 2011

Page 62: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Confusion.

Saturday, April 9, 2011

Page 63: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Saturday, April 9, 2011

Page 64: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We made a better decision.

Saturday, April 9, 2011

Page 65: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We improve our mental model by measuringwhat our code does.

Saturday, April 9, 2011

Page 66: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

territorymap ≠

Saturday, April 9, 2011

Page 67: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

territorymap→

Saturday, April 9, 2011

Page 68: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We use ourmental model

to decide what to do.

Saturday, April 9, 2011

Page 69: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

A bettermental model

makes us better at deciding what to do.

Saturday, April 9, 2011

Page 70: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

A bettermental model

makes us better at generating

business value.

Saturday, April 9, 2011

Page 71: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Measuring makes your decisions better.

Saturday, April 9, 2011

Page 72: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

But only if we’re measuring

the right thing.

Saturday, April 9, 2011

Page 73: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We need to measure our code where it

matters.

Saturday, April 9, 2011

Page 74: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

In the wild.

Saturday, April 9, 2011

Page 75: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Generatingbusiness value.

Saturday, April 9, 2011

Page 76: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Saturday, April 9, 2011

Page 77: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

PRODUCTION

Saturday, April 9, 2011

Page 78: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Continuously measuring code in production.

Saturday, April 9, 2011

Page 79: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Metrics

Saturday, April 9, 2011

Page 80: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MetricsJava/Scala

Saturday, April 9, 2011

Page 81: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

github.com/codahale/metrics

MetricsJava/Scala

Saturday, April 9, 2011

Page 82: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 83: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Each metric is associated with a class

and has a name.

Saturday, April 9, 2011

Page 84: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

An autocomplete service for city names.

Saturday, April 9, 2011

Page 85: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

An autocomplete service for city names.

> GET /complete?q=San%20Fra

Saturday, April 9, 2011

Page 86: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

An autocomplete service for city names.

> GET /complete?q=San%20Fra

< HTTP/1.1 200 RAD<< ["San Francisco"]

Saturday, April 9, 2011

Page 87: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

What does this code do that affects its business value?

Saturday, April 9, 2011

Page 88: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

And how can we measure that?

Saturday, April 9, 2011

Page 89: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 90: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 91: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugeThe instantaneous value of something.

Saturday, April 9, 2011

Page 92: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# of cities

Saturday, April 9, 2011

Page 93: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

metrics.gauge("cities") { cities.size }

Saturday, April 9, 2011

Page 94: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

metrics.gauge("cities") { cities.size }

Saturday, April 9, 2011

Page 95: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

metrics.gauge("cities") { cities.size }

Saturday, April 9, 2011

Page 96: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“The service has 589 cities registered.”

Saturday, April 9, 2011

Page 97: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 98: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCounters

MetersHistograms

Timers

Saturday, April 9, 2011

Page 99: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

CounterAn incrementing and decrementing value.

Saturday, April 9, 2011

Page 100: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# of open connections

Saturday, April 9, 2011

Page 101: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val counter = metrics.counter("connections")

counter.inc()

counter.dec()

Saturday, April 9, 2011

Page 102: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val counter = metrics.counter("connections")

counter.inc()

counter.dec()

Saturday, April 9, 2011

Page 103: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val counter = metrics.counter("connections")

counter.inc()

counter.dec()

Saturday, April 9, 2011

Page 104: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val counter = metrics.counter("connections")

counter.inc()

counter.dec()

Saturday, April 9, 2011

Page 105: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“There are 594 active sessions on that server.”

Saturday, April 9, 2011

Page 106: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCounters

MetersHistograms

Timers

Saturday, April 9, 2011

Page 107: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 108: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MeterThe average rate of events

over a period of time.

Saturday, April 9, 2011

Page 109: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# of requests/sec

Saturday, April 9, 2011

Page 110: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val meter = metrics.meter("requests", SECONDS)

meter.mark()

Saturday, April 9, 2011

Page 111: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val meter = metrics.meter("requests", SECONDS)

meter.mark()

Saturday, April 9, 2011

Page 112: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val meter = metrics.meter("requests", SECONDS)

meter.mark()

Saturday, April 9, 2011

Page 113: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val meter = metrics.meter("requests", SECONDS)

meter.mark()

Saturday, April 9, 2011

Page 114: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

mean rate = # of events

elapsed time

Saturday, April 9, 2011

Page 115: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# ofrequests

Saturday, April 9, 2011

Page 116: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 117: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 118: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 119: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Recency.

Saturday, April 9, 2011

Page 120: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

mean rate = # of events

elapsed time

Saturday, April 9, 2011

Page 121: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

mean rate = # of events

elapsed time

Saturday, April 9, 2011

Page 122: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

COGNITIVE HAZARD

Saturday, April 9, 2011

Page 123: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Exponentially weighted moving average.

Saturday, April 9, 2011

Page 124: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

-(1-α)kmt-1 + (1-(1-α)k)Yt

k

Saturday, April 9, 2011

Page 125: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

-(1-α)kmt-1 + (1-(1-α)k)Yt

k

Saturday, April 9, 2011

Page 126: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 127: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 128: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 129: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# ofrequests

time

Saturday, April 9, 2011

Page 130: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1-minute rate

Saturday, April 9, 2011

Page 131: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1-minute rate5-minute rate

Saturday, April 9, 2011

Page 132: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1-minute rate5-minute rate15-minute rate

Saturday, April 9, 2011

Page 133: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“We went from 3,000 requests/sec to<500 a second.”

Saturday, April 9, 2011

Page 134: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 135: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 136: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

HistogramThe statistical distribution of values in a stream of data.

Saturday, April 9, 2011

Page 137: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# of cities returned

Saturday, April 9, 2011

Page 138: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val histogram = metrics.histogram("response-sizes")

histogram.update(response.cities.size)

Saturday, April 9, 2011

Page 139: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val histogram = metrics.histogram("response-sizes")

histogram.update(response.cities.size)

Saturday, April 9, 2011

Page 140: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val histogram = metrics.histogram("response-sizes")

histogram.update(response.cities.size)

Saturday, April 9, 2011

Page 141: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

minimum

Saturday, April 9, 2011

Page 142: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

minimummaximum

Saturday, April 9, 2011

Page 143: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

minimummaximum

mean

Saturday, April 9, 2011

Page 144: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

minimummaximum

meanstandard deviation

Saturday, April 9, 2011

Page 145: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantiles

Saturday, April 9, 2011

Page 146: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

Saturday, April 9, 2011

Page 147: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

75th percentile

Saturday, April 9, 2011

Page 148: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

75th percentile95th percentile

Saturday, April 9, 2011

Page 149: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

75th percentile95th percentile98th percentile

Saturday, April 9, 2011

Page 150: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

75th percentile95th percentile98th percentile99th percentile

Saturday, April 9, 2011

Page 151: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Quantilesmedian

75th percentile95th percentile98th percentile99th percentile

99.9th percentileSaturday, April 9, 2011

Page 152: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We can’t keep all of these values.

Saturday, April 9, 2011

Page 153: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

Saturday, April 9, 2011

Page 154: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×

Saturday, April 9, 2011

Page 155: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

Saturday, April 9, 2011

Page 156: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×

Saturday, April 9, 2011

Page 157: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×1 day

Saturday, April 9, 2011

Page 158: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×1 day

=

Saturday, April 9, 2011

Page 159: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×1 day

=>86 billion values

Saturday, April 9, 2011

Page 160: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×1 day

=>86 billion values

>640GB of data/day

Saturday, April 9, 2011

Page 161: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

1,000 req/sec

×1,000 actions/req

×1 day

=>86 billion values

>640GB of data/dayNot gonna happen.

Saturday, April 9, 2011

Page 162: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

COGNITIVE HAZARD

Saturday, April 9, 2011

Page 163: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Reservoir sampling.Keep a statistically representative sample

of measurements as they happen.

Saturday, April 9, 2011

Page 164: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Vitter’s Algorithm R.

Vitter, J. (1985).Random sampling with a reservoir.

ACM Transactions on Mathematical Software (TOMS), 11(1), 57.Saturday, April 9, 2011

Page 165: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# ofcities

Saturday, April 9, 2011

Page 166: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# ofcities

Saturday, April 9, 2011

Page 167: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# ofcities

Saturday, April 9, 2011

Page 168: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 169: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 170: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 171: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Vitter’s Algorithm R produces uniform

samples.

Saturday, April 9, 2011

Page 172: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Recency.

Saturday, April 9, 2011

Page 173: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

SUPER-DUPERCOGNITIVE HAZARD

Saturday, April 9, 2011

Page 174: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Saturday, April 9, 2011

Page 175: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Forward-decaying priority sampling.

Cormode, G., Shkapenyuk, V., Srivastava, D., & Xu, B. (2009).Forward Decay: A Practical Time Decay Model for Streaming Systems.

ICDE '09: Proceedings of the 2009 IEEE International Conference on Data Engineering.Saturday, April 9, 2011

Page 176: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Maintain a statistically representative sample of the last 5 minutes.

Saturday, April 9, 2011

Page 177: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 178: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 179: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 180: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

time

# of cities

Saturday, April 9, 2011

Page 181: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Uniform Biased

Saturday, April 9, 2011

Page 182: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“95% of autocomplete results return 3 cities or

less.”

Saturday, April 9, 2011

Page 183: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 184: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 185: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

TimerA histogram of durations and

a meter of calls.

Saturday, April 9, 2011

Page 186: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

# of ms to respond

Saturday, April 9, 2011

Page 187: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val timer = metrics.timer("requests", MILLISECONDS, SECONDS)

timer.time { handle(req, resp) }

Saturday, April 9, 2011

Page 188: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val timer = metrics.timer("requests", MILLISECONDS, SECONDS)

timer.time { handle(req, resp) }

Saturday, April 9, 2011

Page 189: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val timer = metrics.timer("requests", MILLISECONDS, SECONDS)

timer.time { handle(req, resp) }

Saturday, April 9, 2011

Page 190: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val timer = metrics.timer("requests", MILLISECONDS, SECONDS)

timer.time { handle(req, resp) }

Saturday, April 9, 2011

Page 191: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

val timer = metrics.timer("requests", MILLISECONDS, SECONDS)

timer.time { handle(req, resp) }

Saturday, April 9, 2011

Page 192: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

“At ~2,000 req/sec, our 99% latency jumps

from 13ms to 453ms.”

Saturday, April 9, 2011

Page 193: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 194: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 195: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Now what?

Saturday, April 9, 2011

Page 196: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Instrument it.

Saturday, April 9, 2011

Page 197: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Instrument it.If it could affect your code’s

business value, add a metric.

Saturday, April 9, 2011

Page 198: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Instrument it.If it could affect your code’s

business value, add a metric.Our services have 40-50 metrics.

Saturday, April 9, 2011

Page 199: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Collect it.

Saturday, April 9, 2011

Page 200: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Collect it.JSON via HTTP.

Saturday, April 9, 2011

Page 201: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Collect it.JSON via HTTP.Every minute.

Saturday, April 9, 2011

Page 202: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Monitor it.

Saturday, April 9, 2011

Page 203: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Monitor it.Nagios/Zabbix/Whatever

Saturday, April 9, 2011

Page 204: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Monitor it.Nagios/Zabbix/Whatever

If it affects business value, someone should get woken up.

Saturday, April 9, 2011

Page 205: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Aggregate it.

Saturday, April 9, 2011

Page 206: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Aggregate it.Ganglia/Graphite/Cacti/Whatever

Saturday, April 9, 2011

Page 207: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Aggregate it.Ganglia/Graphite/Cacti/Whatever

Place current values in historical context.

Saturday, April 9, 2011

Page 208: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Aggregate it.Ganglia/Graphite/Cacti/Whatever

Place current values in historical context.See long-term patterns.

Saturday, April 9, 2011

Page 209: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Go faster.

Saturday, April 9, 2011

Page 210: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Shorten ourdecision-making cycle.

Saturday, April 9, 2011

Page 211: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Observe

Saturday, April 9, 2011

Page 212: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

ObserveOrient

Saturday, April 9, 2011

Page 213: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

ObserveOrientDecide

Saturday, April 9, 2011

Page 214: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

ObserveOrientDecideAct

Saturday, April 9, 2011

Page 215: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

ObserveOrientDecideAct

Saturday, April 9, 2011

Page 216: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Observe

What is the 99% latency of our autocomplete service right now?

Saturday, April 9, 2011

Page 217: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Observe

What is the 99% latency of our autocomplete service right now?

~500ms

Saturday, April 9, 2011

Page 218: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Orient

How does this compare toother parts of our system,

both currently and historically?

Saturday, April 9, 2011

Page 219: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Orient

How does this compare toother parts of our system,

both currently and historically?

way slower

Saturday, April 9, 2011

Page 220: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Decide

Should we make it faster?Or should we add feature X?

Saturday, April 9, 2011

Page 221: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Decide

Should we make it faster?Or should we add feature X?

make it faster

Saturday, April 9, 2011

Page 222: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Act!

Write some code.

Saturday, April 9, 2011

Page 223: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Act!

Write some code.

def sort_by(&blk) #sleep(100) # WTF DUDE super(&blk)end

Saturday, April 9, 2011

Page 224: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

10 Print "Rinse"20 Print "Repeat"30 Goto 10

Saturday, April 9, 2011

Page 225: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

If we do this fasterwe will win.

Saturday, April 9, 2011

Page 226: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Fewer bugs.

Saturday, April 9, 2011

Page 227: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

More features.

Saturday, April 9, 2011

Page 228: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Happier users.

Saturday, April 9, 2011

Page 229: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Money.Saturday, April 9, 2011

Page 230: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

tl;dr

Saturday, April 9, 2011

Page 231: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We might write code.

Saturday, April 9, 2011

Page 232: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

We have to generatebusiness value.

Saturday, April 9, 2011

Page 233: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

In order to know how well our code is generating

business value, we need metrics.

Saturday, April 9, 2011

Page 234: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

GaugesCountersMeters

HistogramsTimers

Saturday, April 9, 2011

Page 235: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Monitor them for current problems.

Saturday, April 9, 2011

Page 236: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Aggregate them for historical perspective.

Saturday, April 9, 2011

Page 237: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

territorymap ≠

Saturday, April 9, 2011

Page 238: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

territorymap→

Saturday, April 9, 2011

Page 239: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Improve our mental model of our code.

Saturday, April 9, 2011

Page 240: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

MIND THE GAP

Saturday, April 9, 2011

Page 241: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

ObserveOrientDecideAct

Saturday, April 9, 2011

Page 242: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

If you’re on the JVM, use Metrics.

Saturday, April 9, 2011

Page 243: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

If you’re on the JVM, use Metrics.

github.com/codahale/metrics

Saturday, April 9, 2011

Page 244: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

If not,you can build this.

Saturday, April 9, 2011

Page 245: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Please build this.

Saturday, April 9, 2011

Page 246: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Make better decisions by using numbers.

Saturday, April 9, 2011

Page 247: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Thank you.

Saturday, April 9, 2011

Page 248: METRICS - Coda Hale€¦ ·  The enterprise social network. Saturday, April 9, 2011

Saturday, April 9, 2011