observer, a "real life" time series application

40
Observer A real life time-series application Kévin Lovato - @alprema

Upload: kevin-lovato

Post on 22-Jan-2018

961 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Observer, a "real life" time series application

Observer A real life time-series application

Kévin Lovato - @alprema

Page 2: Observer, a "real life" time series application

Index • Observer introduction • Architecture overview • CQL schema • Feedback

– Schema – Read/Write access

• Numbers

Page 3: Observer, a "real life" time series application

Observer introduction

Page 4: Observer, a "real life" time series application

Key features

• Publish metrics from anywhere

• Track & investigate business issues

• Alert users in case of unusual behavior

• Integrate with the infrastructure features

Page 5: Observer, a "real life" time series application
Page 6: Observer, a "real life" time series application
Page 7: Observer, a "real life" time series application
Page 8: Observer, a "real life" time series application

Architecture overview

Page 9: Observer, a "real life" time series application

C*

Aggregator

Publisher

Send raw metrics

Page 10: Observer, a "real life" time series application

C*

Aggregator

Publisher

Aggregate metrics (sec, min, hour)

Page 11: Observer, a "real life" time series application

C*

WebDashboard

Client

Load metrics data

HTTP

Page 12: Observer, a "real life" time series application

C*

WebDashboard

Client

Receive live metrics data through bus Push

(WebSocket)

Page 13: Observer, a "real life" time series application

C*

DataCruncher Load and compute all metrics for the day

Write daily computations (avg, percentiles, etc.)

Page 14: Observer, a "real life" time series application

C*

Alertor

Catch up on startup

Receive live metrics data through bus

Send alerts on the bus

Page 15: Observer, a "real life" time series application

CQL schema

Page 16: Observer, a "real life" time series application

Metric_OneSec • Schema:

((MetricId, Day), UtcDate), Value

MetricId + Day

UtcDate UtcDate …

Value Value

Page 17: Observer, a "real life" time series application

Metric_OneSec

• TTL: 8 days

• Max column per row: 86 400 • Average size: 1.4 MB

Page 18: Observer, a "real life" time series application

Metric_OneMin • Schema:

((MetricId, FirstDayOfWeek), UtcDate), Value

MetricId + FirstDayOfWeek

UtcDate UtcDate …

Value Value

Page 19: Observer, a "real life" time series application

Metric_OneMin

• TTL: 60 days

• Max column per row: 10 080 • Average size: 300 KB

Page 20: Observer, a "real life" time series application

Metric_OneHour • Schema:

(MetricId, UtcDate), Value

MetricId UtcDate UtcDate …

Value Value

Page 21: Observer, a "real life" time series application

Metric_OneHour

• TTL: 10 years

• Average size: 45 KB

Page 22: Observer, a "real life" time series application

Daily_Aggregate • Schema:

(MetricId, Date), Average, Count, Percentiles, …

MetricId Date.Average Date.Count …

Page 23: Observer, a "real life" time series application

Daily_Aggregate

• No TTL

• Average size: 23 KB

Page 24: Observer, a "real life" time series application

Feedback - Schema

Page 25: Observer, a "real life" time series application

Row sizing • Avoid having rows spanning over long

periods • Avoid large amounts of data / row (<100

MB is good) • Make buckets using another component

(ex: Day, FirstDayOfWeek, etc.)

Page 26: Observer, a "real life" time series application

TTLs • Don’t use them if you don’t really need them

(extra space wasted) • Make sure to set it right the first time (or you

will need to reinsert your data) • Consider changing gc_grace_period for your

CF (tombstones useless for TTLed time-series)

Page 27: Observer, a "real life" time series application

General best practices • Consider disabling inter-DC read repair on

your CF (read_repair_chance) • Use collection types (map<>, etc.)

Page 28: Observer, a "real life" time series application

Feedback – Read / Write

Page 29: Observer, a "real life" time series application

Obvious but… • Avoid Thrift (can take down your cluster on

huge rows reads) • Do not disable paging (same effect as using

Thrift) • Use prepared statements

Page 30: Observer, a "real life" time series application

Batches • Warning: Not intended for performance • But… • Can improve insert performance under

adequate conditions • Use small (< 5 KB) "Unlogged" batches • Benchmark with your own use case • Don’t tell @PatrickMcFadin you did it

Page 31: Observer, a "real life" time series application

Asynchronous queries • Mandatory if you want to be fast (from

anything over 1 query)

Page 32: Observer, a "real life" time series application

Asynchronous queries

Vs.

Page 33: Observer, a "real life" time series application

Asynchronous queries

• For massive reads, send your queries by

bunches and wait for them

Page 34: Observer, a "real life" time series application

General best practices • Benchmark all heavy operations in terms of

cluster load (a faster implem might just be killing the cluster for everyone else)

• Watch out for CL: ONE (we experienced slowdowns as the coordinator asked a different DC under heavy load)

Page 35: Observer, a "real life" time series application

Numbers time

Page 36: Observer, a "real life" time series application

• Total number of metrics: 17K

• Metrics inserted: 10K/s

• Data points daily aggregation speed: 500K/s

• DC size: 3 nodes (spinning disks)

Page 37: Observer, a "real life" time series application

Future • Use DTCS (MaybeTWCS? CASSANDRA-

9666 / CASSANDRA-10195) • Move to SSDs everywhere

Page 38: Observer, a "real life" time series application

Interested? We’re hiring

Page 39: Observer, a "real life" time series application

Questions?

Page 40: Observer, a "real life" time series application

Image credits – The Noun Project • Björn Andersson • Creative Stall • Gregor Cresnar • Justin Blake • Lemon Liu • Mark Shorter • Shawn Schmidt • Stéphanie Rusch