18:15 Opening word (Javier Santana)
18:25 ClickHouse introduction (Alexander Zaitsev, Altinity)
19:00 ClickHouse 2019 new features (Alexey Milovidov, Yandex)
19:40 Coffee break
20:00 From legacy to ClickHouse (Iago Enriquez, Idealista)
20:25 1027 predictive models in 10 seconds (David Pardo Villaverde, Corunet)
21:55 Shipping Data from Postgres to Clickhouse (Murat Kabilov, Adjust)
21:20 More Q&A and closing remarks
21:30 Networking, beer etc.
What Is ClickHouse?
© http://mattturck.com/
ClickHouse DBMS is
Column Store
MPP
Realtime
SQL
Open Source
http://clickhouse.yandex
• Developed by Yandex for Yandex.Metrica
• Yandex (NASDAQ: YNDX) – “Russian Google” (50% market share in
search, 50+ b2b and b2c products)
• Yandex.Metrica – world 2nd largest web analytics platform
• Open Source since June 2016 (Apache 2.0 license)
• 200+ companies using in production today
• Several hundred experimenting, doing POC etc.
• Dozens of contributors to the source code
Why Yet Another DBMS?
SQLFlexible
ClickHouse
•Fast!
•Flexible!
•Free!
•Fun!
How Fast?
:) select count(*) from dw.ad8_fact_event;
SELECT count(*)
FROM dw.ad8_fact_event
┌───────count()─┐
│ 1261705085657 │
└───────────────┘
1 rows in set. Elapsed: 3.552 sec. Processed 1.26 trillion rows, 1.26 TB (355.22 billion
rows/s., 355.22 GB/s.)
Altinity Ltd. www.altinity.com
1+ trillion rows table
:) select sum(price_cpm) from dw.ad8_fact_event where access_day=today()-1 and event_key=-2;
SELECT sum(price_cpm)
FROM dw.ad8_fact_event
WHERE (access_day = (today() - 1)) AND (event_key = -2)
┌────sum(price_cpm)─┐
│ 87579.09035192338 │
└───────────────────┘
1 rows in set. Elapsed: 0.168 sec. Processed 161.89 million rows, 2.91 GB (961.83 million
rows/s., 17.31 GB/s.)
Altinity Ltd. www.altinity.com
1+ trillion rows table
WikiStat data, 28B rows.
https://www.percona.com/blog/2017/03/17/column-store-database-benchmarks-mariadb-columnstore-vs-clickhouse-vs-apache-spark/
Query 1 Query 2 Query 3 Query 4 Setup
0.009 0.027 0.287 0.428 BrytlytDB 2.0 & 2-node p2.16xlarge cluster
0.034 0.061 0.178 0.498 MapD & 2-node p2.8xlarge cluster
0.051 0.146 0.047 0.794 kdb+/q & 4 Intel Xeon Phi 7210 CPUs
0.241 0.826 1.209 1.781 ClickHouse, 3 x c5d.9xlarge cluster
0.762 2.472 4.131 6.041 BrytlytDB 1.0 & 2-node p2.16xlarge cluster
1.034 3.058 5.354 12.748 ClickHouse, Intel Core i5 4670K
1.56 1.25 2.25 2.97 Redshift, 6-node ds2.8xlarge cluster
2 2 1 3 BigQuery
2.362 3.559 4.019 20.412 Spark 2.4 & 21 x m3.xlarge HDFS cluster
6.41 6.19 6.09 6.63 Amazon Athena
8.1 18.18 n/a n/a Elasticsearch (heavily tuned)
14.389 32.148 33.448 67.312 Vertica, Intel Core i5 4670K
22 25 27 65 Spark 2.3.0 & single i3.8xlarge w/ HDFS
35 39 64 81 Presto, 5-node m3.xlarge cluster w/ HDFS
152 175 235 368 PostgreSQL 9.5 & cstore_fdw
“1.1 Billion Taxi Rides Benchmarks” http://tech.marksblogg.com/benchmarks.html
“This is the first time a free CPU-based database has managed to out-perform a GPU-based database in my
benchmarks.” Mark Litwintschik
Time Series Benchmarks
• https://github.com/timescale/tsbs
• Benchmark suite to automate testing
• Loads 103M rows, 10 metrics per row
• Runs 15 queries, 1000 runs each in 8 parallel threads
• Supports TimescaleDB, InfluxDB, Cassandra, MongoDB and
ClickHouse (Altinity PR is submitted)
0
100
200
300
400
500
600
700
800
900
ClickHouse TimescaleDB InfluxDB
Load time (s)
1.20
26
0.46
0.00
5.00
10.00
15.00
20.00
25.00
30.00
ClickHouse TimescaleDB InfluxDB
Data Size on disk (GB)
0
10
20
30
40
50
60
70
80
“Light” queries, time in ms
ClickHouse
TimescaleDB
InfluxDB
0
10
20
30
40
50
60
70
80
90
“Heavy” queries, time in sec
ClickHouse
TimescaleDB
InfluxDB
How Flexible?
ClickHouse runs at
• Bare metal (any Linux)
• Public clouds: Amazon, Azure, Google, Alibaba
• Private clouds
• Docker, Kubernetes
ClickHouse solves business problems at:
• Mobile App and Web analytics
• AdTech
• Retail and E-Commerce
• Operational Logs analytics
• Telecom/Monitoring
• Financial Markets analytics
• Security Audit
• BlockChain transactions analysis
ClickHouse Migrations
Size does not matter
Yandex: 500+ servers, 25B rec/day
LifeStreet: 60 servers, 100B rec/day
CloudFlare: 76 servers, 200B rec/day
Bloomberg: 102 servers, 1000B rec/day
Toutiao: 1000 servers
How fun ☺
life←{↑1 ω∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂ω}
with (select groupArray(C) from C) as Ca
select id,
groupArray(S) Sa, groupArray(V) Va, groupArray(D) Da, groupArray(P) Pa,
arrayMap(c -> arrayFirstIndex(s -> s > c, Sa)-1, Ca) Ka,
arrayMap((c,k) -> Va[k] + (Va[k+1] - Va[k])/(Sa[k+1] - Sa[k])*(c-
Sa[k]),Ca,Ka) Ta,
arrayMap(s -> arrayFirstIndex(c -> c>s, Ca)>0 ? arrayFirstIndex(c ->
c>s, Ca)-1 : toInt32(length(Ca)), Sa) Ja,
arrayMap(i -> Ta[i], Ja) Ra,
arrayMap((v,r) -> v - r, Va, Ra) ARa,
arraySum((x,y,z) -> x*y*z, ARa, Da, Pa) result
from T group by id
What’s new in 2019
… Alexey Milovidov will disclose latest coolest features in 15 minutes
More user friendly than ever!
• GDPR compliance – thanks to UPDATE/DELETE
• Easier BI integration – thanks to SQL compatibility changes and
improvements in ODBC driver
• Easier cluster operation – thanks to clickhouse-copier, distributed DDL and
upcoming Altinity ClickHouse operator for Kubernetes
• Easier integration with other systems. Thanks to:
• HTTP/TCP protocols
• Table functions to access external data
• Kafka storage engine
• Logs integration with Logstash, ClickTail and other tools
• Integration wth MySQL, PostgreSQL
Integrates with MySQL
• mysql() table function
• MySQL table engine
• MySQL external dictionaries
• ProxySQL
• Binary log replication with clickhouse-mysql
mysql() table function
select * from mysql('host:port', database, 'table', 'user', 'password');
https://www.altinity.com/blog/2018/2/12/aggregate-mysql-data-at-high-speed-with-clickhouse
• Easiest and fastest way to get data from MySQL
• Load to CH table and run queries much faster
MySQL table engine
CREATE TABLE …
Engine = MySQL('host:port', 'database', 'table', 'user',
'password'[, replace_query, 'on_duplicate_clause']);
• SELECTs and INSERTs!
• No caching, data is queried from th remote server
https://clickhouse.yandex/docs/en/operations/table_engines/mysql/
MySQL external dictionaries
• Makes data from mysql database accessible in ClickHouse queries
• Stores in memory
• Updates when the source data changes
SELECT dictGet(‘dim_geo’, ‘country_name’, geo_key)
country_name,sum(imps)
FROM T
GROUP BY country_name;
Binary log replication from MySQL
to ClickHouse
MySQL
clickhouse-mysql
Queries
Source Data
See details at:
https://www.altinity.com/blog/2018/6/30/realtime-mysql-clickhouse-replication-in-practice
Integrates with PostgreSQL
• odbc() table function
• ODBC engine
• ODBC dictionaries
• PostgreSQL foreign data wrapper – clickhouse_fwd by Percona
• pg2ch -- binary log replication, Murat Kibilov will present later today
hello-kubernetes.yaml:
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "hello-kubernetes"
spec:
configuration:
clusters:
- name: "sharded"
layout:
type: Standard
shardsCount: 3
$ kubectl -n test apply -f docs/examples/hello-kubernetes.yaml
clickhouseinstallation.clickhouse.altinity.com/hello-kubernetes created
$ kubectl -n test get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S)
AGE
chi-a9cffb-347e-0-0 ClusterIP None <none>
8123/TCP,9000/TCP,9009/TCP 7s
chi-a9cffb-347e-1-0 ClusterIP None <none>
8123/TCP,9000/TCP,9009/TCP 7s
chi-a9cffb-347e-2-0 ClusterIP None <none>
8123/TCP,9000/TCP,9009/TCP 7s
clickhouse-example-02 LoadBalancer 10.98.156.78 <pending>
8123:30703/TCP,9000:30348/TCP 7s
$ docker run -it yandex/clickhouse-client clickhouse-client -h 10.98.156.78
ClickHouse client version 19.1.14.
Connecting to 10.98.156.78:9000.
Connected to ClickHouse server version 19.1.14 revision 54413.
chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :)
chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :) create table
test_distr as system.one Engine = Distributed('sharded', system, one);
CREATE TABLE test_distr AS system.one
ENGINE = Distributed('sharded', system, one)
Ok.
0 rows in set. Elapsed: 0.016 sec.
chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :) select * from
test_distr;
SELECT *
FROM test_distr
┌─dummy─┐
│ 0 │
└───────┘
┌─dummy─┐
│ 0 │
└───────┘
┌─dummy─┐
│ 0 │
└───────┘
3 rows in set. Elapsed: 0.054 sec.
…coming soon
• Managing persistent volumes to be used for ClickHouse data
• Configuring pod deployment (pod templates, affinity rules and so on)
• Creating replicated tables
• Managing users/profiles configuration
• Exporting ClickHouse metrics to Prometheus
• Handling ClickHouse version upgrades
… and more
ClickHouse Today
• Mature Analytic DBMS. Proven by many companies
• Almost 3+ years in Open Source
• Constantly improves
• Solid community
• Emerging eco-system
• Support from Altinity
Q&A
Contact me:
alz@altinity.com
skype: alex.zaitsev
telegram: @alexanderzaitsev
Altinity

ClickHouse Introduction by Alexander Zaitsev, Altinity CTO

  • 1.
    18:15 Opening word(Javier Santana) 18:25 ClickHouse introduction (Alexander Zaitsev, Altinity) 19:00 ClickHouse 2019 new features (Alexey Milovidov, Yandex) 19:40 Coffee break 20:00 From legacy to ClickHouse (Iago Enriquez, Idealista) 20:25 1027 predictive models in 10 seconds (David Pardo Villaverde, Corunet) 21:55 Shipping Data from Postgres to Clickhouse (Murat Kabilov, Adjust) 21:20 More Q&A and closing remarks 21:30 Networking, beer etc.
  • 2.
  • 3.
  • 4.
    ClickHouse DBMS is ColumnStore MPP Realtime SQL Open Source
  • 5.
    http://clickhouse.yandex • Developed byYandex for Yandex.Metrica • Yandex (NASDAQ: YNDX) – “Russian Google” (50% market share in search, 50+ b2b and b2c products) • Yandex.Metrica – world 2nd largest web analytics platform • Open Source since June 2016 (Apache 2.0 license) • 200+ companies using in production today • Several hundred experimenting, doing POC etc. • Dozens of contributors to the source code
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
    :) select count(*)from dw.ad8_fact_event; SELECT count(*) FROM dw.ad8_fact_event ┌───────count()─┐ │ 1261705085657 │ └───────────────┘ 1 rows in set. Elapsed: 3.552 sec. Processed 1.26 trillion rows, 1.26 TB (355.22 billion rows/s., 355.22 GB/s.) Altinity Ltd. www.altinity.com 1+ trillion rows table
  • 11.
    :) select sum(price_cpm)from dw.ad8_fact_event where access_day=today()-1 and event_key=-2; SELECT sum(price_cpm) FROM dw.ad8_fact_event WHERE (access_day = (today() - 1)) AND (event_key = -2) ┌────sum(price_cpm)─┐ │ 87579.09035192338 │ └───────────────────┘ 1 rows in set. Elapsed: 0.168 sec. Processed 161.89 million rows, 2.91 GB (961.83 million rows/s., 17.31 GB/s.) Altinity Ltd. www.altinity.com 1+ trillion rows table
  • 12.
    WikiStat data, 28Brows. https://www.percona.com/blog/2017/03/17/column-store-database-benchmarks-mariadb-columnstore-vs-clickhouse-vs-apache-spark/
  • 13.
    Query 1 Query2 Query 3 Query 4 Setup 0.009 0.027 0.287 0.428 BrytlytDB 2.0 & 2-node p2.16xlarge cluster 0.034 0.061 0.178 0.498 MapD & 2-node p2.8xlarge cluster 0.051 0.146 0.047 0.794 kdb+/q & 4 Intel Xeon Phi 7210 CPUs 0.241 0.826 1.209 1.781 ClickHouse, 3 x c5d.9xlarge cluster 0.762 2.472 4.131 6.041 BrytlytDB 1.0 & 2-node p2.16xlarge cluster 1.034 3.058 5.354 12.748 ClickHouse, Intel Core i5 4670K 1.56 1.25 2.25 2.97 Redshift, 6-node ds2.8xlarge cluster 2 2 1 3 BigQuery 2.362 3.559 4.019 20.412 Spark 2.4 & 21 x m3.xlarge HDFS cluster 6.41 6.19 6.09 6.63 Amazon Athena 8.1 18.18 n/a n/a Elasticsearch (heavily tuned) 14.389 32.148 33.448 67.312 Vertica, Intel Core i5 4670K 22 25 27 65 Spark 2.3.0 & single i3.8xlarge w/ HDFS 35 39 64 81 Presto, 5-node m3.xlarge cluster w/ HDFS 152 175 235 368 PostgreSQL 9.5 & cstore_fdw “1.1 Billion Taxi Rides Benchmarks” http://tech.marksblogg.com/benchmarks.html “This is the first time a free CPU-based database has managed to out-perform a GPU-based database in my benchmarks.” Mark Litwintschik
  • 14.
    Time Series Benchmarks •https://github.com/timescale/tsbs • Benchmark suite to automate testing • Loads 103M rows, 10 metrics per row • Runs 15 queries, 1000 runs each in 8 parallel threads • Supports TimescaleDB, InfluxDB, Cassandra, MongoDB and ClickHouse (Altinity PR is submitted)
  • 15.
  • 16.
  • 17.
    0 10 20 30 40 50 60 70 80 “Light” queries, timein ms ClickHouse TimescaleDB InfluxDB
  • 18.
    0 10 20 30 40 50 60 70 80 90 “Heavy” queries, timein sec ClickHouse TimescaleDB InfluxDB
  • 19.
  • 20.
    ClickHouse runs at •Bare metal (any Linux) • Public clouds: Amazon, Azure, Google, Alibaba • Private clouds • Docker, Kubernetes
  • 21.
    ClickHouse solves businessproblems at: • Mobile App and Web analytics • AdTech • Retail and E-Commerce • Operational Logs analytics • Telecom/Monitoring • Financial Markets analytics • Security Audit • BlockChain transactions analysis
  • 22.
  • 23.
    Size does notmatter Yandex: 500+ servers, 25B rec/day LifeStreet: 60 servers, 100B rec/day CloudFlare: 76 servers, 200B rec/day Bloomberg: 102 servers, 1000B rec/day Toutiao: 1000 servers
  • 24.
    How fun ☺ life←{↑1ω∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂ω}
  • 25.
    with (select groupArray(C)from C) as Ca select id, groupArray(S) Sa, groupArray(V) Va, groupArray(D) Da, groupArray(P) Pa, arrayMap(c -> arrayFirstIndex(s -> s > c, Sa)-1, Ca) Ka, arrayMap((c,k) -> Va[k] + (Va[k+1] - Va[k])/(Sa[k+1] - Sa[k])*(c- Sa[k]),Ca,Ka) Ta, arrayMap(s -> arrayFirstIndex(c -> c>s, Ca)>0 ? arrayFirstIndex(c -> c>s, Ca)-1 : toInt32(length(Ca)), Sa) Ja, arrayMap(i -> Ta[i], Ja) Ra, arrayMap((v,r) -> v - r, Va, Ra) ARa, arraySum((x,y,z) -> x*y*z, ARa, Da, Pa) result from T group by id
  • 26.
    What’s new in2019 … Alexey Milovidov will disclose latest coolest features in 15 minutes
  • 27.
    More user friendlythan ever! • GDPR compliance – thanks to UPDATE/DELETE • Easier BI integration – thanks to SQL compatibility changes and improvements in ODBC driver • Easier cluster operation – thanks to clickhouse-copier, distributed DDL and upcoming Altinity ClickHouse operator for Kubernetes • Easier integration with other systems. Thanks to: • HTTP/TCP protocols • Table functions to access external data • Kafka storage engine • Logs integration with Logstash, ClickTail and other tools • Integration wth MySQL, PostgreSQL
  • 28.
    Integrates with MySQL •mysql() table function • MySQL table engine • MySQL external dictionaries • ProxySQL • Binary log replication with clickhouse-mysql
  • 29.
    mysql() table function select* from mysql('host:port', database, 'table', 'user', 'password'); https://www.altinity.com/blog/2018/2/12/aggregate-mysql-data-at-high-speed-with-clickhouse • Easiest and fastest way to get data from MySQL • Load to CH table and run queries much faster
  • 30.
    MySQL table engine CREATETABLE … Engine = MySQL('host:port', 'database', 'table', 'user', 'password'[, replace_query, 'on_duplicate_clause']); • SELECTs and INSERTs! • No caching, data is queried from th remote server https://clickhouse.yandex/docs/en/operations/table_engines/mysql/
  • 31.
    MySQL external dictionaries •Makes data from mysql database accessible in ClickHouse queries • Stores in memory • Updates when the source data changes SELECT dictGet(‘dim_geo’, ‘country_name’, geo_key) country_name,sum(imps) FROM T GROUP BY country_name;
  • 32.
    Binary log replicationfrom MySQL to ClickHouse MySQL clickhouse-mysql Queries Source Data See details at: https://www.altinity.com/blog/2018/6/30/realtime-mysql-clickhouse-replication-in-practice
  • 33.
    Integrates with PostgreSQL •odbc() table function • ODBC engine • ODBC dictionaries • PostgreSQL foreign data wrapper – clickhouse_fwd by Percona • pg2ch -- binary log replication, Murat Kibilov will present later today
  • 34.
    hello-kubernetes.yaml: apiVersion: "clickhouse.altinity.com/v1" kind: "ClickHouseInstallation" metadata: name:"hello-kubernetes" spec: configuration: clusters: - name: "sharded" layout: type: Standard shardsCount: 3
  • 35.
    $ kubectl -ntest apply -f docs/examples/hello-kubernetes.yaml clickhouseinstallation.clickhouse.altinity.com/hello-kubernetes created $ kubectl -n test get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE chi-a9cffb-347e-0-0 ClusterIP None <none> 8123/TCP,9000/TCP,9009/TCP 7s chi-a9cffb-347e-1-0 ClusterIP None <none> 8123/TCP,9000/TCP,9009/TCP 7s chi-a9cffb-347e-2-0 ClusterIP None <none> 8123/TCP,9000/TCP,9009/TCP 7s clickhouse-example-02 LoadBalancer 10.98.156.78 <pending> 8123:30703/TCP,9000:30348/TCP 7s
  • 36.
    $ docker run-it yandex/clickhouse-client clickhouse-client -h 10.98.156.78 ClickHouse client version 19.1.14. Connecting to 10.98.156.78:9000. Connected to ClickHouse server version 19.1.14 revision 54413. chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :)
  • 37.
    chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :) createtable test_distr as system.one Engine = Distributed('sharded', system, one); CREATE TABLE test_distr AS system.one ENGINE = Distributed('sharded', system, one) Ok. 0 rows in set. Elapsed: 0.016 sec.
  • 38.
    chi-a9cffb-347e-1-0-0.chi-a9cffb-347e-1-0.test.svc.cluster.local :) select* from test_distr; SELECT * FROM test_distr ┌─dummy─┐ │ 0 │ └───────┘ ┌─dummy─┐ │ 0 │ └───────┘ ┌─dummy─┐ │ 0 │ └───────┘ 3 rows in set. Elapsed: 0.054 sec.
  • 39.
    …coming soon • Managingpersistent volumes to be used for ClickHouse data • Configuring pod deployment (pod templates, affinity rules and so on) • Creating replicated tables • Managing users/profiles configuration • Exporting ClickHouse metrics to Prometheus • Handling ClickHouse version upgrades … and more
  • 40.
    ClickHouse Today • MatureAnalytic DBMS. Proven by many companies • Almost 3+ years in Open Source • Constantly improves • Solid community • Emerging eco-system • Support from Altinity
  • 41.