RisingWave
A cloud-native streaming database
A cloud-native streaming database
RisingWave is a cloud-native streaming database developed in Rust by RisingWave Labs, founded in 2021. It supports the PostgreSQL wire protocol, so you can query streaming data with SQL using existing PostgreSQL clients and tools.
The core concept is the Materialized View. When you define aggregations, joins, and window queries over streaming data with CREATE MATERIALIZED VIEW, the results are automatically updated incrementally whenever new data arrives. It processes only the changes without full recomputation, enabling real-time analytics.
It ingests data from various sources such as Kafka, Redpanda, Kinesis, S3, and PostgreSQL CDC, and exports results to PostgreSQL, Kafka, Elasticsearch, and more. By defining Sources (input) and Sinks (output) with SQL DDL, you can build ETL pipelines without code.
With a cloud-native architecture, compute and storage are separated, and S3-compatible object storage is used as persistent storage. It scales horizontally with ease in Kubernetes environments and is gaining attention as an alternative to Apache Flink or ksqlDB.
-- Kafka Source 생성 (이벤트 스트림 입력)
CREATE SOURCE user_events (
user_id VARCHAR,
event_type VARCHAR,
page_url VARCHAR,
event_time TIMESTAMPTZ,
properties JSONB
) WITH (
connector = 'kafka',
topic = 'user-events',
properties.bootstrap.server = 'redpanda:9092',
scan.startup.mode = 'latest'
) FORMAT PLAIN ENCODE JSON;
-- 기본 테이블 (디멘션 데이터)
CREATE TABLE users (
user_id VARCHAR PRIMARY KEY,
name VARCHAR,
email VARCHAR,
created_at TIMESTAMPTZ
);
-- Materialized View: 실시간 페이지뷰 집계
CREATE MATERIALIZED VIEW page_views_per_minute AS
SELECT
DATE_TRUNC('minute', event_time) AS minute,
page_url,
COUNT(*) AS view_count,
COUNT(DISTINCT user_id) AS unique_users
FROM user_events
WHERE event_type = 'page_view'
GROUP BY 1, 2;
-- Materialized View: 사용자 세션 분석 (윈도우 함수)
CREATE MATERIALIZED VIEW user_sessions AS
SELECT
user_id,
event_time,
event_type,
LAG(event_time) OVER (PARTITION BY user_id ORDER BY event_time) AS prev_event_time,
CASE
WHEN event_time - LAG(event_time) OVER (PARTITION BY user_id ORDER BY event_time) > INTERVAL '30 minutes'
THEN 1 ELSE 0
END AS new_session_flag
FROM user_events;
-- Materialized View: 스트림-테이블 조인
CREATE MATERIALIZED VIEW enriched_events AS
SELECT
e.user_id,
e.event_type,
e.event_time,
u.name AS user_name,
u.email
FROM user_events e
LEFT JOIN users u ON e.user_id = u.user_id;
-- Sink: 결과를 Kafka로 출력
CREATE SINK alerts_sink FROM (
SELECT * FROM page_views_per_minute
WHERE view_count > 1000 -- 비정상 트래픽 감지
)
WITH (
connector = 'kafka',
topic = 'traffic-alerts',
properties.bootstrap.server = 'redpanda:9092'
) FORMAT PLAIN ENCODE JSON;
-- PostgreSQL 호환 쿼리 (MV 결과 조회)
SELECT * FROM page_views_per_minute
WHERE minute >= NOW() - INTERVAL '5 minutes'
ORDER BY view_count DESC
LIMIT 10;
-- psql로 연결
-- psql -h localhost -p 4566 -d dev -U root
-- Python에서 연결 (psycopg2)
-- import psycopg2
-- conn = psycopg2.connect(
-- host="localhost", port=4566,
-- database="dev", user="root"
-- )
-- cursor = conn.cursor()
-- cursor.execute("SELECT * FROM page_views_per_minute LIMIT 10")
Senior: "If you use RisingWave instead of Flink, you can build streaming pipelines with SQL alone. You don't have to write Java code."
Junior: "Can I connect with a PostgreSQL client?"
Senior: "Yes, psql and DBeaver both work. You can also integrate your existing BI tools."
Interviewer: "Please tell me about your experience with real-time data processing."
Candidate: "I built a real-time dashboard backend with RisingWave. I aggregated Kafka events with Materialized Views to serve metrics with under 1 second of latency, and thanks to the PostgreSQL protocol, I connected our existing Metabase as is, which reduced development costs."
Take a mock interview on this topic → WIA SOOM AI Interview · Start for free
Reviewer: "When joining in an MV, you need a Primary Key for efficient incremental updates. Set a PRIMARY KEY on the Source."
Developer: "I guess I should set user_id as the Primary Key."