41
Percona Live 2017 Santa Clara, California | April 24th – 27th, 2017

Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Embed Size (px)

Citation preview

Page 1: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Percona Live 2017

Santa Clara, California | April 24th – 27th, 2017

Page 2: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

ClickHouse as Time-Series Database for Graphite

Dmitry Andreev, Yandex

Page 3: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

〉Software Engineer

〉Head of Infrastructure Development Group in Yandex Market

[email protected]

About me

3

Page 4: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

› One of the largest internet companies in Europe

› Over 5000 employees

› Top-1 Search in Russia

› More than 50 different b2c and b2b products

› Big Data, Machine Learning

About Yandex

4

Page 5: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

History

ClickHouse as Time-Series Database for Graphite

Page 6: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

End of 2014

› Couple of graphite installations is Yandex

› We use installations on Ceres

› We intensively add new metrics

History, part 1

6

Page 7: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Beginning of 2015

› The graphite installation is overloaded

› We are launching a prototype on ClickHouse

April 2015

› First Graphouse commit

History, part 2

7

Page 8: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Open-source column-oriented DBMS

Linearly scalable

Blazingly fast

SQL dialect with extensions

ClickHouse briefly

8

Page 9: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Yandex.Metrica is one of the largest web analytic tools

20+ billions of events daily

Millions of websites

100+ thousands of analysts every day

We need fast and feature-rich database capable to handle our clients data

Yandex.Metrica

9

Page 10: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Why ClickHouse?

ClickHouse as Time-Series Database for Graphite

Page 11: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

1. …

Time Series Database Requirements

11

Page 12: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

1. High write performance

2. Fast range queries

3. Data compaction (rollup)

Time Series Database Requirements

12

Page 13: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Table consists of partitions

Partition is sorted by Primary Key(PK is not unique)

ClickHouse MergeTree Table Engine

13

Page 14: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Table consists of partitions

Partition is sorted by Primary Key(PK is not unique)

Insert creates new partition

ClickHouse MergeTree Table Engine

14

Page 15: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Primary Key - (Metric, Timestamp)

Time Series Database Requirements:

1. Fast range queries2. High write performance

ClickHouse MergeTree Table Engine

15

Page 16: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

•Compacting data during the merge

GraphiteMergeTree Table Engine

16

Page 17: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Who the **** is Mr. Graphouse?

ClickHouse as Time-Series Database for Graphite

Page 18: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Common Graphite Architecture

18

Page 19: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Graphite query workflow

19

Graphite-webavg(servers.clickhouse0{1,2}.disk*.util), period1.

Graphite-web StorageFinderservers.clickhouse0{1,2}.disk*.util

servers.clickhouse01.disk-sda1.utilservers.clickhouse01.disk-sda2.utilservers.clickhouse02.disk-sda1.utilservers.clickhouse02.disk-sda2.util

StorageReader

2.

Graphite-web StorageReaderPoints

3. 4.Graphite-web

(apply functions,render image, …)

Page 20: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Metric Tree

20

ROOT

servers

clickhouse02 clickhouse03clickhouse01

applications

disk-sda1 cpudisk-sda2

free util idle user

app1 app3app2

In memory

On demand

(with cache)

app3 BAN

Page 21: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Architecture with Graphouse

21

Page 22: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Sharding and replication

ClickHouse as Time-Series Database for Graphite

Page 23: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

ClickHouse Cluster Scheme

23

Shard

Data Center

Page 24: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Metric tree synchronisation via ClickHouse Table

Eventual Consistency

Graphouse replications

24

GraphouseGraphouse

Page 25: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Graphite cluster. Case 1.

25

Graphite-web

Graphouse

Host

Graphite-web

Graphouse

Host

Graphite-web

Graphouse

Host

Page 26: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Graphite cluster. Case 2.

26

Graphite-web

Graphouse

Load

Graphite-web

Graphouse

Page 27: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Graphite cluster. Case 3.

27

Graphite-web

Load

GraphouseGraphouse

Load

Graphite-web

Page 28: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

SSD is good, but HDD is fine too

Don’t use sharding unless you really need

Our experience

28

Page 29: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Benchmarks

ClickHouse as Time-Series Database for Graphite

Page 30: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

1. Carbon + Whisper

2. Go-carbon + Whisper

3. Biggraphite + Cassandra

4. Graphouse + Clickhouse

Candidates

30

Page 31: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Intel(R) Xeon(R) CPU E5-2650 v2 (2.60 GHz, 8 Cores, 16 Threads)

128 GB RAM

2 SSD in RAID1 (Limited by SATA-300)

Hardware

31

Page 32: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

› Storage schema: 60s:1d,10m:30d

› Send interval: 30 seconds

› Metrics per thread: 30 000

› Send timeout - 30 seconds

› Thread count - variable (average 1000 mps per thread)

Insert test

32

Page 33: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Benchmark Util

33

andreevdm@host:~/$ inputPerfTest --threads 2000 --metrics 30000 --interval 30 --prefix perf-

test. --runMinutes 600

2017-04-27 00:25:05,199 INFO [InsertTest main] Creating graphite insert perf test for

localhost:2003

2017-04-27 00:25:05,200 INFO [InsertTest main] Thread count: 2000, metric per thread:

30000, send interval: 30 seconds. Metrics per second: 2000000.0.

2017-04-27 00:25:05,261 INFO [InsertTest main] Test run time is 600 minutes

2017-04-27 00:26:05,815 INFO [InsertTest pool-2-thread-20] Finished sending metrics for

timestamp 1493241935 (Thu Apr 27 00:25:35 MSK 2017). Send 60000000 (61290000

total), failed to send 0 (0 total), errors 0.0% (0.0% total). Total send time 74525 ms, avg

Page 34: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Insert performance (metrics per second)

34

0

500.000

1.000.000

1.500.000

2.000.000

Graphouse + ClickHouse Carbon + Wisper Go-carbon + Wisper Biggraphite + Casandra

1 050 000

95 000 45 000

2 000 000

Page 35: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

What’s next?

ClickHouse as Time-Series Database for Graphite

Page 36: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Graphite query workflow

36

Graphite-webavg(servers.clickhouse0{1,2}.disk*.util), period1.

Graphite-web StorageFinderservers.clickhouse0{1,2}.disk*.util

servers.clickhouse01.disk-sda1.utilservers.clickhouse01.disk-sda2.utilservers.clickhouse02.disk-sda1.utilservers.clickhouse02.disk-sda2.util

StorageReader

2.

Graphite-web StorageReaderPoints

3. 4.Graphite-web

(apply functions,render image, …)(apply functions,render image, …)

Page 37: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

avg(servers.clickhouse0{1,2}.disk*.util)

Query Example

37

SELECT metric, timestamp, value

FROM graphite.data

WHERE metric IN (

'servers.clickhouse01.disk-sda1.util', ‘servers.clickhouse01.disk-sda2.util',

'servers.clickhouse02.disk-sda1.util', 'servers.clickhouse02.disk-sda2.util'

) AND DATE …

Page 38: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

avg(servers.clickhouse0{1,2}.disk*.util)

We can do better

38

SELECT timestamp, avg(value)

FROM graphite.data

WHERE metric IN (

'servers.clickhouse01.disk-sda1.util', ‘servers.clickhouse01.disk-sda2.util',

'servers.clickhouse02.disk-sda1.util', 'servers.clickhouse02.disk-sda2.util'

) AND DATE …

GROUP BY timestamp

Page 39: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Notice: ClickHouse is not TSDBIt can do much more

Page 40: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites
Page 41: Percona Live 2017 · SQL dialect with extensions ClickHouse briefly 8. Yandex.Metrica is one of the largest web analytic tools 20+ billions of events daily Millions of websites

Dmitry AndreevHead of Infrastructure Development Group in Yandex Market

https://github.com/yandex/graphouse (Apache License 2.0)

[email protected]

Contacts

https://t.me/graphouse