53
You Can't Optimise What You Can't Measure Juozas Kaziukėnas // juokaz.com // @juokaz

You can't optimize what you cannot measure - PHP UK

Embed Size (px)

Citation preview

Page 1: You can't optimize what you cannot measure - PHP UK

You Can't Optimise What You Can't

MeasureJuozas Kaziukėnas // juokaz.com // @juokaz

Page 2: You can't optimize what you cannot measure - PHP UK

Juozas Kaziukėnas, Lithuanian

You can call me Joe

More info http://juokaz.com

Page 3: You can't optimize what you cannot measure - PHP UK
Page 4: You can't optimize what you cannot measure - PHP UK
Page 5: You can't optimize what you cannot measure - PHP UK
Page 6: You can't optimize what you cannot measure - PHP UK

Why?

Page 7: You can't optimize what you cannot measure - PHP UK

Data

Page 8: You can't optimize what you cannot measure - PHP UK

Looking for lies

Page 9: You can't optimize what you cannot measure - PHP UK

Looking for lies

Page 10: You can't optimize what you cannot measure - PHP UK

Looking for lies

Page 11: You can't optimize what you cannot measure - PHP UK

Data

• Metrics

• Removes subjective decisions

• Can be aggregated and related

• If it’s 0, it is 0

• Tesla was probably right

Page 12: You can't optimize what you cannot measure - PHP UK

Debugging production

Page 13: You can't optimize what you cannot measure - PHP UK

Debugging production

• Behavioral patterns

• When something changes - something is not right

• You better notice it

• Facebook deployment process

• What caused it?

Page 14: You can't optimize what you cannot measure - PHP UK

What happened?

Page 15: You can't optimize what you cannot measure - PHP UK

What happened?

• Previous and current state

• Events

• Correlated events

• State information

Page 16: You can't optimize what you cannot measure - PHP UK

What happened here?

Page 17: You can't optimize what you cannot measure - PHP UK

What happened here?

Page 18: You can't optimize what you cannot measure - PHP UK

Nothing happened here

Page 19: You can't optimize what you cannot measure - PHP UK

Something happened here

Page 20: You can't optimize what you cannot measure - PHP UK

Logs suck

Page 21: You can't optimize what you cannot measure - PHP UK

Logs suck

• Someone needs to be checking them

• Need to be aggregated

• Need to be vizualized

• High I/O to write

• Distributed logs?

Page 22: You can't optimize what you cannot measure - PHP UK

I want to sleep

Page 23: You can't optimize what you cannot measure - PHP UK

I want to sleep

• Call me when things go wrong

• Otherwise everything is working

• Things don’t break silently anymore

Page 24: You can't optimize what you cannot measure - PHP UK

Business problems

Page 25: You can't optimize what you cannot measure - PHP UK

Business problems

• Detecting when business tools stop working

• No PHP errors, no database errors

• Failures of APIs, empty responses, invalid data

• Things stop working silently

Page 26: You can't optimize what you cannot measure - PHP UK

Counting and timing

Page 27: You can't optimize what you cannot measure - PHP UK

Counting and timing

• Record when something happens

• Record how long it takes for something to happen

• Use this to know how many things are happening

Page 28: You can't optimize what you cannot measure - PHP UK

The solution

Page 29: You can't optimize what you cannot measure - PHP UK

Statsd

Page 30: You can't optimize what you cannot measure - PHP UK

Statsd

• Counters and timing

• No need to initialize or set up counters

• Non-blocking writes

• Originally written by Etsy.com

• Just works

• https://github.com/etsy/statsd/

Page 31: You can't optimize what you cannot measure - PHP UK

StatsD::increment("phpuk.visitors");

Page 32: You can't optimize what you cannot measure - PHP UK

$start = microtime(true);

attend_conference();

$spent = (microtime(true) - $start) * 1000;

StatsD::timing("phpuk.timespent", $spent);

Page 33: You can't optimize what you cannot measure - PHP UK

How it works

Page 34: You can't optimize what you cannot measure - PHP UK

Graphite

Page 35: You can't optimize what you cannot measure - PHP UK

Graphite

• Real-time charts

• Data collection

• Data aggregation

• Specialized database

• http://graphite.wikidot.com/

Page 36: You can't optimize what you cannot measure - PHP UK

How it works

Page 37: You can't optimize what you cannot measure - PHP UK

Lobster

Page 38: You can't optimize what you cannot measure - PHP UK

Logster

Page 39: You can't optimize what you cannot measure - PHP UK

Logster

• Parse log files

• Send data to graphite

• Integration with existing applications easier

• Also from Etsy.com

• https://github.com/etsy/logster

Page 40: You can't optimize what you cannot measure - PHP UK

DataDogHQ.com

Page 41: You can't optimize what you cannot measure - PHP UK

DataDogHQ.com

Page 42: You can't optimize what you cannot measure - PHP UK

DataDogHQ.com

• Hosted solution

• Collect data from statsd

• Store and aggregate from multiple servers

• Chart combining any data

• Real time charts

• Alerts

Page 43: You can't optimize what you cannot measure - PHP UK

Amazon outage

Page 44: You can't optimize what you cannot measure - PHP UK

Amazon outage

Page 45: You can't optimize what you cannot measure - PHP UK

Amazon outage

Page 46: You can't optimize what you cannot measure - PHP UK

Amazon outage

Page 47: You can't optimize what you cannot measure - PHP UK

How I use this

Page 48: You can't optimize what you cannot measure - PHP UK

Web spiders

Page 49: You can't optimize what you cannot measure - PHP UK

Web spiders

• ~250 nodes

• Couple thousand requests per second

• Increasing throughput - main goal

• Increasing reliability - secondary goal

• Metrics for: request time, error rate, error types, proxy failures, unknown responses, etc.

Page 50: You can't optimize what you cannot measure - PHP UK

Web spiders

• Performance increased 1000% in 3 months

• Reliability increased to being 24/7 stable

• I can sleep

Page 51: You can't optimize what you cannot measure - PHP UK

Wrapping up

Page 52: You can't optimize what you cannot measure - PHP UK

Wrapping up

• Measure things

• Use statsd to collect data

• Graph it

• Sleep

Page 53: You can't optimize what you cannot measure - PHP UK

THANKS!Juozas Kaziukėnas

@juokaz