概念
Timeplus是一個流處理器。它提供強大的端到端功能,利用開源流引擎Proton來幫助數據團隊快速直觀地處理流數據和歷史數據,可供各種規模和行業的組織使用。它使數據工程師和平臺工程師能夠使用 SQL 釋放流數據價值。
Timeplus 控制臺可以輕松連接到不同的數據源(例如 Apache Kafka、Confluence Cloud、Redpanda、NATS、Web Socket/SSE、CSV 文件上傳等)、通過 SQL 查詢探索流模式、發送實時見解和向其他系統或個人發出警報,并創建儀表板和可視化。
-
關于Timeplus 與 proton的關系
Proton是Timeplus開源的核心系統。 Timeplus Cloud是云端的Proton,支持多租戶,外加 Web UI,dashboard, alert,血緣圖,和一些Proton不支持的數據源(通過額外組建)。
對于 On-prem(私有化)部署,官方提供了Timeplus Enterprise,功能和 Timeplus Cloud 相似。 -
Timeplus 與Clickhouse的關系
Timeplus的Proton就是基于ClickHouse開發的或者說內置ClickHouse(就是一個 proton 進程),去掉一些不需要的ClickHouse 的功能和函數,加入流計算能力和一個流存儲。
event數據先進入這個 streaming storage,實現small batch write,然后再自動轉批寫到 OLAP 存儲。
必須明確的是Timeplus的Proton與現有Clickhouse集群沒關系,timeplus需要依賴自己內部Proton(改造的clickhouse)提供計算能力,而不能依賴現有的clickhouse提供的計算能力,但支持讀寫遠程的clickhouse集群。 -
Timeplus兩種運行方式
- 最簡單就是 All In One,用 Timeplus 自己做歷史存儲,也做流存儲,自己做流計算,也自己做歷史計算
- 當你有數據在 ClickHouse 時,也可以把 Timeplus 當 Flink等流處理框架用,從 Kafka 讀數據,寫到遠程的 ClickHouse
-
Timeplus語法
Timeplus的SQL語法類似Clickhouse語法,支持ClickHouse協議,加上自己的一些tumble/hop/session方法在Flink等流程處理常見的函數。 -
消息觸發機制
Timeplus的觸發機制是micro-batch,而不是per event trigger,但可以做到毫秒級。
如果是 global aggregation 默認是2秒發一次聚合數據,這個用戶可以自定義,最大可以支持到微秒。
Timeplus的觸發策略還是比較全的,也是一大優勢。 -
Timeplus與RisingWave比較
Timeplus與流處理數據庫RisingWave相比較,最大的優勢是Timeplus可以很好的支持隨機分析,因為其底層基于Clickhouse。
部署環境
獲取docker編排文件
wget https://github.com/timeplus-io/proton/blob/develop/examples/ecommerce/docker-compose.yml
啟動服務
docker compose up -d
進入客戶端:
docker exec -it proton-demo-ecommerce-proton-1 proton-client
實例demo
ecommerce case
DROP STREAM default.frontend_events0;
CREATE STREAM frontend_events0(raw string) \
SETTINGS type='kafka', \brokers='redpanda:9092',\topic='owlshop-frontend-events';-- Create externarl stream to read data from Kafka/Redpanda
CREATE EXTERNAL STREAM frontend_events(raw string)
SETTINGS type='kafka', brokers='redpanda:9092',topic='owlshop-frontend-events';-- Scan incoming events
select * from frontend_events;-- Get live count
select count() from frontend_events;-- Filter events by JSON attributes
select _tp_time, raw:ipAddress, raw:requestedUrl from frontend_events where raw:method='POST';-- Show a live ASCII bar chart
select raw:method, count() as cnt, bar(cnt, 0, 40,5) as bar from frontend_events group by raw:method order by cnt desc limit 5 by emit_version();
MATERIALIZED VIEW
CREATE MATERIALIZED VIEW IF NOT EXISTS mv01 \
AS select _tp_time, raw:ipAddress, raw:requestedUrl from frontend_events where raw:method='POST';--1. Streaming mode: SELECT * FROM materialized_view
SELECT * FROM mv01;--2.Historical mode: SELECT * FROM table(materialized_view)
SELECT * FROM table(mv01);--3.Historical + streaming mode: SELECT * FROM materialized_view WHERE _tp_time>='1970-01-01' Get all past results and as well as the future data.
SELECT * FROM mv01 WHERE _tp_time>='1970-01-01';--4.Pre-aggregation mode: SELECT * FROM table(materialized_view) where __tp_version in (SELECT max(__tp_version) as m from table(materialized_view)) This immediately returns the most recent query result. We will provide new syntax to simplify this.
監控case
數據按照預設的時間批次進行分組,例如:2024-01-01 08:00:00、2024-01-01 08-30:00,并實時統計每個批次內的數據計數。
當批次數據計數在指定的延遲時間內未達到預設數量時(例如,從2024-01-01 08:00:00延遲1小時,觸發時間為系統時間2024-01-01 09:00:00),會觸發警報。發布批量數據的指標包括批量時間、觸發報警時的計數數據量等
create stream s1(ts datetime64,cnt int32);
insert into s1(ts,cnt) values('2024-02-28 20:59:00',2);select * from s1 where ts < now()-1m \
emit last 5m on proctime;
關于Timeplus
github 倉庫
官方文檔
Timeplus知乎主頁
Slack