Bản dịch của bài viết được chuẩn bị riêng cho các học viên của khóa học
Hai năm trước tôi đã dành
ClickHouse bao gồm 170 nghìn dòng mã C++, không bao gồm thư viện của bên thứ ba và là một trong những cơ sở mã cơ sở dữ liệu phân tán nhỏ nhất. Để so sánh, SQLite không hỗ trợ phân phối và bao gồm 235 nghìn dòng mã C. Tính đến thời điểm viết bài này, 207 kỹ sư đã đóng góp cho ClickHouse và cường độ cam kết gần đây đã tăng lên.
Tháng 2017 năm XNUMX, ClickHouse bắt đầu tiến hành
Trong bài viết này, tôi sẽ xem xét hiệu suất của cụm ClickHouse trên AWS EC2 bằng bộ xử lý 36 lõi và bộ lưu trữ NVMe.
CẬP NHẬT: Một tuần sau khi xuất bản bài đăng này lần đầu, tôi đã chạy lại bài kiểm tra với cấu hình được cải thiện và đạt được kết quả tốt hơn nhiều. Bài đăng này đã được cập nhật để phản ánh những thay đổi này.
Khởi chạy cụm AWS EC2
Tôi sẽ sử dụng ba phiên bản EC5 c9d.2xlarge cho bài đăng này. Mỗi trong số chúng chứa 36 CPU ảo, RAM 72 GB, bộ nhớ SSD NVMe 900 GB và hỗ trợ mạng 10 Gigabit. Chúng có giá 1,962 USD/giờ mỗi chiếc ở khu vực eu-west-1 khi chạy theo yêu cầu. Tôi sẽ sử dụng Ubuntu Server 16.04 LTS làm hệ điều hành.
Tường lửa được định cấu hình để mỗi máy có thể giao tiếp với nhau mà không bị hạn chế và chỉ địa chỉ IPv4 của tôi được SSH đưa vào danh sách trắng trong cụm.
Ổ NVMe ở trạng thái sẵn sàng hoạt động
Để ClickHouse hoạt động, tôi sẽ tạo một hệ thống tệp ở định dạng EXT4 trên ổ NVMe trên mỗi máy chủ.
$ sudo mkfs -t ext4 /dev/nvme1n1
$ sudo mkdir /ch
$ sudo mount /dev/nvme1n1 /ch
Sau khi mọi thứ đã được định cấu hình, bạn có thể thấy điểm gắn kết và 783 GB dung lượng trống trên mỗi hệ thống.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 87.9M 1 loop /snap/core/5742
loop1 7:1 0 16.5M 1 loop /snap/amazon-ssm-agent/784
nvme0n1 259:1 0 8G 0 disk
└─nvme0n1p1 259:2 0 8G 0 part /
nvme1n1 259:0 0 838.2G 0 disk /ch
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 35G 0 35G 0% /dev
tmpfs 6.9G 8.8M 6.9G 1% /run
/dev/nvme0n1p1 7.7G 967M 6.8G 13% /
tmpfs 35G 0 35G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 35G 0 35G 0% /sys/fs/cgroup
/dev/loop0 88M 88M 0 100% /snap/core/5742
/dev/loop1 17M 17M 0 100% /snap/amazon-ssm-agent/784
tmpfs 6.9G 0 6.9G 0% /run/user/1000
/dev/nvme1n1 825G 73M 783G 1% /ch
Tập dữ liệu tôi sẽ sử dụng trong thử nghiệm này là kết xuất dữ liệu tôi tạo ra từ 1.1 tỷ lượt đi taxi được thực hiện ở Thành phố New York trong hơn sáu năm. Trên blog
$ sudo apt update
$ sudo apt install awscli
$ aws configure
Tôi sẽ đặt giới hạn yêu cầu đồng thời của khách hàng là 100 để các tệp tải xuống nhanh hơn cài đặt mặc định.
$ aws configure set
default.s3.max_concurrent_requests
100
Tôi sẽ tải xuống tập dữ liệu về các chuyến đi taxi từ AWS S3 và lưu trữ trên ổ NVMe trên máy chủ đầu tiên. Tập dữ liệu này có dung lượng ~104GB ở định dạng CSV được nén bằng GZIP.
$ sudo mkdir -p /ch/csv
$ sudo chown -R ubuntu /ch/csv
$ aws s3 sync s3://<bucket>/csv /ch/csv
Cài đặt ClickHouse
Tôi sẽ cài đặt bản phân phối OpenJDK cho Java 8 vì nó cần thiết để chạy Apache ZooKeeper, bản phân phối này cần thiết cho quá trình cài đặt ClickHouse phân tán trên cả ba máy.
$ sudo apt update
$ sudo apt install
openjdk-8-jre
openjdk-8-jdk-headless
Sau đó tôi đặt biến môi trường JAVA_HOME
.
$ sudo vi /etc/profile
export JAVA_HOME=/usr
$ source /etc/profile
Sau đó tôi sẽ sử dụng hệ thống quản lý gói của Ubuntu để cài đặt ClickHouse 18.16.1, liếc nhìn và ZooKeeper trên cả ba máy.
$ sudo apt-key adv
--keyserver hkp://keyserver.ubuntu.com:80
--recv E0C56BD4
$ echo "deb http://repo.yandex.ru/clickhouse/deb/stable/ main/" |
sudo tee /etc/apt/sources.list.d/clickhouse.list
$ sudo apt-get update
$ sudo apt install
clickhouse-client
clickhouse-server
glances
zookeeperd
Tôi sẽ tạo một thư mục cho ClickHouse và cũng thực hiện một số ghi đè cấu hình trên cả ba máy chủ.
$ sudo mkdir /ch/clickhouse
$ sudo chown -R clickhouse /ch/clickhouse
$ sudo mkdir -p /etc/clickhouse-server/conf.d
$ sudo vi /etc/clickhouse-server/conf.d/taxis.conf
Đây là các phần ghi đè cấu hình mà tôi sẽ sử dụng.
<?xml version="1.0"?>
<yandex>
<listen_host>0.0.0.0</listen_host>
<path>/ch/clickhouse/</path>
<remote_servers>
<perftest_3shards>
<shard>
<replica>
<host>172.30.2.192</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<host>172.30.2.162</host>
<port>9000</port>
</replica>
</shard>
<shard>
<replica>
<host>172.30.2.36</host>
<port>9000</port>
</replica>
</shard>
</perftest_3shards>
</remote_servers>
<zookeeper-servers>
<node>
<host>172.30.2.192</host>
<port>2181</port>
</node>
<node>
<host>172.30.2.162</host>
<port>2181</port>
</node>
<node>
<host>172.30.2.36</host>
<port>2181</port>
</node>
</zookeeper-servers>
<macros>
<shard>03</shard>
<replica>01</replica>
</macros>
</yandex>
Sau đó tôi sẽ chạy ZooKeeper và máy chủ ClickHouse trên cả ba máy.
$ sudo /etc/init.d/zookeeper start
$ sudo service clickhouse-server start
Đang tải dữ liệu lên ClickHouse
Trên máy chủ đầu tiên tôi sẽ tạo một bảng chuyến đi (trips
), sẽ lưu trữ tập dữ liệu về các chuyến đi taxi bằng công cụ Log.
$ clickhouse-client --host=0.0.0.0
CREATE TABLE trips (
trip_id UInt32,
vendor_id String,
pickup_datetime DateTime,
dropoff_datetime Nullable(DateTime),
store_and_fwd_flag Nullable(FixedString(1)),
rate_code_id Nullable(UInt8),
pickup_longitude Nullable(Float64),
pickup_latitude Nullable(Float64),
dropoff_longitude Nullable(Float64),
dropoff_latitude Nullable(Float64),
passenger_count Nullable(UInt8),
trip_distance Nullable(Float64),
fare_amount Nullable(Float32),
extra Nullable(Float32),
mta_tax Nullable(Float32),
tip_amount Nullable(Float32),
tolls_amount Nullable(Float32),
ehail_fee Nullable(Float32),
improvement_surcharge Nullable(Float32),
total_amount Nullable(Float32),
payment_type Nullable(String),
trip_type Nullable(UInt8),
pickup Nullable(String),
dropoff Nullable(String),
cab_type Nullable(String),
precipitation Nullable(Int8),
snow_depth Nullable(Int8),
snowfall Nullable(Int8),
max_temperature Nullable(Int8),
min_temperature Nullable(Int8),
average_wind_speed Nullable(Int8),
pickup_nyct2010_gid Nullable(Int8),
pickup_ctlabel Nullable(String),
pickup_borocode Nullable(Int8),
pickup_boroname Nullable(String),
pickup_ct2010 Nullable(String),
pickup_boroct2010 Nullable(String),
pickup_cdeligibil Nullable(FixedString(1)),
pickup_ntacode Nullable(String),
pickup_ntaname Nullable(String),
pickup_puma Nullable(String),
dropoff_nyct2010_gid Nullable(UInt8),
dropoff_ctlabel Nullable(String),
dropoff_borocode Nullable(UInt8),
dropoff_boroname Nullable(String),
dropoff_ct2010 Nullable(String),
dropoff_boroct2010 Nullable(String),
dropoff_cdeligibil Nullable(String),
dropoff_ntacode Nullable(String),
dropoff_ntaname Nullable(String),
dropoff_puma Nullable(String)
) ENGINE = Log;
Sau đó tôi trích xuất và tải từng tệp CSV vào bảng chuyến đi (trips
). Phần sau được hoàn thành trong 55 phút 10 giây. Sau thao tác này, kích thước của thư mục dữ liệu là 134 GB.
$ time (for FILENAME in /ch/csv/trips_x*.csv.gz; do
echo $FILENAME
gunzip -c $FILENAME |
clickhouse-client
--host=0.0.0.0
--query="INSERT INTO trips FORMAT CSV"
done)
Tốc độ nhập là 155 MB nội dung CSV không nén mỗi giây. Tôi nghi ngờ điều này là do tắc nghẽn trong quá trình giải nén GZIP. Có thể nhanh hơn nếu giải nén song song tất cả các tệp được nén bằng xargs và sau đó tải dữ liệu đã giải nén. Dưới đây là mô tả về nội dung được báo cáo trong quá trình nhập CSV.
$ sudo glances
ip-172-30-2-200 (Ubuntu 16.04 64bit / Linux 4.4.0-1072-aws) Uptime: 0:11:42
CPU 8.2% nice: 0.0% LOAD 36-core MEM 9.8% active: 5.20G SWAP 0.0%
user: 6.0% irq: 0.0% 1 min: 2.24 total: 68.7G inactive: 61.0G total: 0
system: 0.9% iowait: 1.3% 5 min: 1.83 used: 6.71G buffers: 66.4M used: 0
idle: 91.8% steal: 0.0% 15 min: 1.01 free: 62.0G cached: 61.6G free: 0
NETWORK Rx/s Tx/s TASKS 370 (507 thr), 2 run, 368 slp, 0 oth sorted automatically by cpu_percent, flat view
ens5 136b 2Kb
lo 343Mb 343Mb CPU% MEM% VIRT RES PID USER NI S TIME+ IOR/s IOW/s Command
100.4 1.5 1.65G 1.06G 9909 ubuntu 0 S 1:01.33 0 0 clickhouse-client --host=0.0.0.0 --query=INSERT INTO trips FORMAT CSV
DISK I/O R/s W/s 85.1 0.0 4.65M 708K 9908 ubuntu 0 R 0:50.60 32M 0 gzip -d -c /ch/csv/trips_xac.csv.gz
loop0 0 0 54.9 5.1 8.14G 3.49G 8091 clickhous 0 S 1:44.23 0 45M /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml
loop1 0 0 4.5 0.0 0 0 319 root 0 S 0:07.50 1K 0 kworker/u72:2
nvme0n1 0 3K 2.3 0.0 91.1M 28.9M 9912 root 0 R 0:01.56 0 0 /usr/bin/python3 /usr/bin/glances
nvme0n1p1 0 3K 0.3 0.0 0 0 960 root -20 S 0:00.10 0 0 kworker/28:1H
nvme1n1 32.1M 495M 0.3 0.0 0 0 1058 root -20 S 0:00.90 0 0 kworker/23:1H
Tôi sẽ giải phóng dung lượng trên ổ NVMe bằng cách xóa các tệp CSV gốc trước khi tiếp tục.
$ sudo rm -fr /ch/csv
Chuyển đổi sang dạng cột
Công cụ Log ClickHouse sẽ lưu trữ dữ liệu ở định dạng theo hàng. Để truy vấn dữ liệu nhanh hơn, tôi chuyển đổi nó sang định dạng cột bằng công cụ MergeTree.
$ clickhouse-client --host=0.0.0.0
Phần sau được hoàn thành trong 34 phút 50 giây. Sau thao tác này, kích thước của thư mục dữ liệu là 237 GB.
CREATE TABLE trips_mergetree
ENGINE = MergeTree(pickup_date, pickup_datetime, 8192)
AS SELECT
trip_id,
CAST(vendor_id AS Enum8('1' = 1,
'2' = 2,
'CMT' = 3,
'VTS' = 4,
'DDS' = 5,
'B02512' = 10,
'B02598' = 11,
'B02617' = 12,
'B02682' = 13,
'B02764' = 14)) AS vendor_id,
toDate(pickup_datetime) AS pickup_date,
ifNull(pickup_datetime, toDateTime(0)) AS pickup_datetime,
toDate(dropoff_datetime) AS dropoff_date,
ifNull(dropoff_datetime, toDateTime(0)) AS dropoff_datetime,
assumeNotNull(store_and_fwd_flag) AS store_and_fwd_flag,
assumeNotNull(rate_code_id) AS rate_code_id,
assumeNotNull(pickup_longitude) AS pickup_longitude,
assumeNotNull(pickup_latitude) AS pickup_latitude,
assumeNotNull(dropoff_longitude) AS dropoff_longitude,
assumeNotNull(dropoff_latitude) AS dropoff_latitude,
assumeNotNull(passenger_count) AS passenger_count,
assumeNotNull(trip_distance) AS trip_distance,
assumeNotNull(fare_amount) AS fare_amount,
assumeNotNull(extra) AS extra,
assumeNotNull(mta_tax) AS mta_tax,
assumeNotNull(tip_amount) AS tip_amount,
assumeNotNull(tolls_amount) AS tolls_amount,
assumeNotNull(ehail_fee) AS ehail_fee,
assumeNotNull(improvement_surcharge) AS improvement_surcharge,
assumeNotNull(total_amount) AS total_amount,
assumeNotNull(payment_type) AS payment_type_,
assumeNotNull(trip_type) AS trip_type,
pickup AS pickup,
pickup AS dropoff,
CAST(assumeNotNull(cab_type)
AS Enum8('yellow' = 1, 'green' = 2))
AS cab_type,
precipitation AS precipitation,
snow_depth AS snow_depth,
snowfall AS snowfall,
max_temperature AS max_temperature,
min_temperature AS min_temperature,
average_wind_speed AS average_wind_speed,
pickup_nyct2010_gid AS pickup_nyct2010_gid,
pickup_ctlabel AS pickup_ctlabel,
pickup_borocode AS pickup_borocode,
pickup_boroname AS pickup_boroname,
pickup_ct2010 AS pickup_ct2010,
pickup_boroct2010 AS pickup_boroct2010,
pickup_cdeligibil AS pickup_cdeligibil,
pickup_ntacode AS pickup_ntacode,
pickup_ntaname AS pickup_ntaname,
pickup_puma AS pickup_puma,
dropoff_nyct2010_gid AS dropoff_nyct2010_gid,
dropoff_ctlabel AS dropoff_ctlabel,
dropoff_borocode AS dropoff_borocode,
dropoff_boroname AS dropoff_boroname,
dropoff_ct2010 AS dropoff_ct2010,
dropoff_boroct2010 AS dropoff_boroct2010,
dropoff_cdeligibil AS dropoff_cdeligibil,
dropoff_ntacode AS dropoff_ntacode,
dropoff_ntaname AS dropoff_ntaname,
dropoff_puma AS dropoff_puma
FROM trips;
Đây là kết quả đầu ra trong quá trình hoạt động:
ip-172-30-2-200 (Ubuntu 16.04 64bit / Linux 4.4.0-1072-aws) Uptime: 1:06:09
CPU 10.3% nice: 0.0% LOAD 36-core MEM 16.1% active: 13.3G SWAP 0.0%
user: 7.9% irq: 0.0% 1 min: 1.87 total: 68.7G inactive: 52.8G total: 0
system: 1.6% iowait: 0.8% 5 min: 1.76 used: 11.1G buffers: 71.8M used: 0
idle: 89.7% steal: 0.0% 15 min: 1.95 free: 57.6G cached: 57.2G free: 0
NETWORK Rx/s Tx/s TASKS 367 (523 thr), 1 run, 366 slp, 0 oth sorted automatically by cpu_percent, flat view
ens5 1Kb 8Kb
lo 2Kb 2Kb CPU% MEM% VIRT RES PID USER NI S TIME+ IOR/s IOW/s Command
241.9 12.8 20.7G 8.78G 8091 clickhous 0 S 30:36.73 34M 125M /usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml
DISK I/O R/s W/s 2.6 0.0 90.4M 28.3M 9948 root 0 R 1:18.53 0 0 /usr/bin/python3 /usr/bin/glances
loop0 0 0 1.3 0.0 0 0 203 root 0 S 0:09.82 0 0 kswapd0
loop1 0 0 0.3 0.1 315M 61.3M 15701 ubuntu 0 S 0:00.40 0 0 clickhouse-client --host=0.0.0.0
nvme0n1 0 3K 0.3 0.0 0 0 7 root 0 S 0:00.83 0 0 rcu_sched
nvme0n1p1 0 3K 0.0 0.0 0 0 142 root 0 S 0:00.22 0 0 migration/27
nvme1n1 25.8M 330M 0.0 0.0 59.7M 1.79M 2764 ubuntu 0 S 0:00.00 0 0 (sd-pam)
Trong thử nghiệm trước, một số cột đã được chuyển đổi và tính toán lại. Tôi nhận thấy rằng một số chức năng này không còn hoạt động như mong đợi trên tập dữ liệu này. Để giải quyết vấn đề này, tôi đã loại bỏ các chức năng không phù hợp và tải dữ liệu mà không chuyển đổi sang các loại chi tiết hơn.
Phân phối dữ liệu trên toàn cụm
Tôi sẽ phân phối dữ liệu trên cả ba nút cụm. Để bắt đầu, bên dưới tôi sẽ tạo một bảng trên cả ba máy.
$ clickhouse-client --host=0.0.0.0
CREATE TABLE trips_mergetree_third (
trip_id UInt32,
vendor_id String,
pickup_date Date,
pickup_datetime DateTime,
dropoff_date Date,
dropoff_datetime Nullable(DateTime),
store_and_fwd_flag Nullable(FixedString(1)),
rate_code_id Nullable(UInt8),
pickup_longitude Nullable(Float64),
pickup_latitude Nullable(Float64),
dropoff_longitude Nullable(Float64),
dropoff_latitude Nullable(Float64),
passenger_count Nullable(UInt8),
trip_distance Nullable(Float64),
fare_amount Nullable(Float32),
extra Nullable(Float32),
mta_tax Nullable(Float32),
tip_amount Nullable(Float32),
tolls_amount Nullable(Float32),
ehail_fee Nullable(Float32),
improvement_surcharge Nullable(Float32),
total_amount Nullable(Float32),
payment_type Nullable(String),
trip_type Nullable(UInt8),
pickup Nullable(String),
dropoff Nullable(String),
cab_type Nullable(String),
precipitation Nullable(Int8),
snow_depth Nullable(Int8),
snowfall Nullable(Int8),
max_temperature Nullable(Int8),
min_temperature Nullable(Int8),
average_wind_speed Nullable(Int8),
pickup_nyct2010_gid Nullable(Int8),
pickup_ctlabel Nullable(String),
pickup_borocode Nullable(Int8),
pickup_boroname Nullable(String),
pickup_ct2010 Nullable(String),
pickup_boroct2010 Nullable(String),
pickup_cdeligibil Nullable(FixedString(1)),
pickup_ntacode Nullable(String),
pickup_ntaname Nullable(String),
pickup_puma Nullable(String),
dropoff_nyct2010_gid Nullable(UInt8),
dropoff_ctlabel Nullable(String),
dropoff_borocode Nullable(UInt8),
dropoff_boroname Nullable(String),
dropoff_ct2010 Nullable(String),
dropoff_boroct2010 Nullable(String),
dropoff_cdeligibil Nullable(String),
dropoff_ntacode Nullable(String),
dropoff_ntaname Nullable(String),
dropoff_puma Nullable(String)
) ENGINE = MergeTree(pickup_date, pickup_datetime, 8192);
Sau đó, tôi sẽ đảm bảo rằng máy chủ đầu tiên có thể nhìn thấy cả ba nút trong cụm.
SELECT *
FROM system.clusters
WHERE cluster = 'perftest_3shards'
FORMAT Vertical;
Row 1:
──────
cluster: perftest_3shards
shard_num: 1
shard_weight: 1
replica_num: 1
host_name: 172.30.2.192
host_address: 172.30.2.192
port: 9000
is_local: 1
user: default
default_database:
Row 2:
──────
cluster: perftest_3shards
shard_num: 2
shard_weight: 1
replica_num: 1
host_name: 172.30.2.162
host_address: 172.30.2.162
port: 9000
is_local: 0
user: default
default_database:
Row 3:
──────
cluster: perftest_3shards
shard_num: 3
shard_weight: 1
replica_num: 1
host_name: 172.30.2.36
host_address: 172.30.2.36
port: 9000
is_local: 0
user: default
default_database:
Sau đó tôi sẽ xác định một bảng mới trên máy chủ đầu tiên dựa trên lược đồ trips_mergetree_third
và sử dụng công cụ phân phối.
CREATE TABLE trips_mergetree_x3
AS trips_mergetree_third
ENGINE = Distributed(perftest_3shards,
default,
trips_mergetree_third,
rand());
Sau đó tôi sẽ sao chép dữ liệu từ bảng dựa trên MergeTree sang cả ba máy chủ. Phần sau được hoàn thành trong 34 phút 44 giây.
INSERT INTO trips_mergetree_x3
SELECT * FROM trips_mergetree;
Sau thao tác trên, tôi cho ClickHouse 15 phút để di chuyển khỏi mốc mức lưu trữ tối đa. Các thư mục dữ liệu lần lượt có dung lượng 264 GB, 34 GB và 33 GB trên mỗi máy chủ trong số ba máy chủ.
Đánh giá hiệu suất cụm ClickHouse
Điều tôi thấy tiếp theo là thời gian nhanh nhất mà tôi từng thấy khi chạy từng truy vấn trên một bảng nhiều lần trips_mergetree_x3
.
$ clickhouse-client --host=0.0.0.0
Phần sau hoàn thành trong 2.449 giây.
SELECT cab_type, count(*)
FROM trips_mergetree_x3
GROUP BY cab_type;
Phần sau hoàn thành trong 0.691 giây.
SELECT passenger_count,
avg(total_amount)
FROM trips_mergetree_x3
GROUP BY passenger_count;
Phần sau hoàn thành trong 0 giây.
SELECT passenger_count,
toYear(pickup_date) AS year,
count(*)
FROM trips_mergetree_x3
GROUP BY passenger_count,
year;
Phần sau hoàn thành trong 0.983 giây.
SELECT passenger_count,
toYear(pickup_date) AS year,
round(trip_distance) AS distance,
count(*)
FROM trips_mergetree_x3
GROUP BY passenger_count,
year,
distance
ORDER BY year,
count(*) DESC;
Để so sánh, tôi đã chạy các truy vấn tương tự trên bảng dựa trên MergeTree chỉ nằm trên máy chủ đầu tiên.
Đánh giá hiệu suất của một nút ClickHouse
Điều tôi thấy tiếp theo là thời gian nhanh nhất mà tôi từng thấy khi chạy từng truy vấn trên một bảng nhiều lần trips_mergetree_x3
.
Phần sau hoàn thành trong 0.241 giây.
SELECT cab_type, count(*)
FROM trips_mergetree
GROUP BY cab_type;
Phần sau hoàn thành trong 0.826 giây.
SELECT passenger_count,
avg(total_amount)
FROM trips_mergetree
GROUP BY passenger_count;
Phần sau hoàn thành trong 1.209 giây.
SELECT passenger_count,
toYear(pickup_date) AS year,
count(*)
FROM trips_mergetree
GROUP BY passenger_count,
year;
Phần sau hoàn thành trong 1.781 giây.
SELECT passenger_count,
toYear(pickup_date) AS year,
round(trip_distance) AS distance,
count(*)
FROM trips_mergetree
GROUP BY passenger_count,
year,
distance
ORDER BY year,
count(*) DESC;
Phản ánh về kết quả
Đây là lần đầu tiên cơ sở dữ liệu dựa trên CPU miễn phí có thể hoạt động tốt hơn cơ sở dữ liệu dựa trên GPU trong các thử nghiệm của tôi. Cơ sở dữ liệu dựa trên GPU đó đã trải qua hai lần sửa đổi kể từ đó, nhưng hiệu suất mà ClickHouse mang lại trên một nút vẫn rất ấn tượng.
Đồng thời, khi thực hiện Truy vấn 1 trên công cụ phân tán, chi phí chung sẽ cao hơn rất nhiều. Tôi hy vọng tôi đã bỏ lỡ điều gì đó trong nghiên cứu của mình cho bài đăng này vì thật tuyệt khi thấy thời gian truy vấn giảm xuống khi tôi thêm nhiều nút hơn vào cụm. Tuy nhiên, điều tuyệt vời là khi thực hiện các truy vấn khác, hiệu suất tăng lên khoảng 2 lần.
Thật tuyệt khi thấy ClickHouse phát triển theo hướng có thể tách biệt bộ nhớ và tính toán để chúng có thể mở rộng quy mô một cách độc lập. Hỗ trợ HDFS, được bổ sung vào năm ngoái, có thể là một bước tiến tới mục tiêu này. Về mặt điện toán, nếu một truy vấn có thể được tăng tốc bằng cách thêm nhiều nút hơn vào cụm thì tương lai của phần mềm này rất tươi sáng.
Cảm ơn bạn đã dành thời gian để đọc bài viết này. Tôi cung cấp các dịch vụ tư vấn, kiến trúc và phát triển thực hành cho khách hàng ở Bắc Mỹ và Châu Âu. Nếu bạn muốn thảo luận về cách đề xuất của tôi có thể giúp ích cho doanh nghiệp của bạn, vui lòng liên hệ với tôi qua
Nguồn: www.habr.com