Serving low-latency analytics directly to end users is notoriously difficult when your backend must ingest high-velocity data streams simultaneously. Traditional RDBMS instances lock up under massive write concurrency, while classic cloud data warehouses incur latency and cost penalties when querying streaming data.
Apache Doris has emerged as a premier modern real-time data warehouse because it pairs a decoupled architecture (Frontend query coordinators and vectorized Backend execution nodes) with native LSM-tree storage engines. It easily handles millions of rows ingested per second while serving ad-hoc SQL queries in under 500 milliseconds.
Here is how to design your tables and ingestion pipelines to achieve sub-second analytical throughput.
1. Select the Right Data Model (Aggregate vs. Unique Key)
Doris avoids generic table layouts by letting you choose the underlying storage engine semantics via three core models: Duplicate, Aggregate, and Unique.
When tracking time-series events, clickstreams, or metrics, the Aggregate Model pre-aggregates dimensions upon insertion, reducing storage footprint and compute cost during queries:
CREATE TABLE IF NOT EXISTS page_views_daily ( event_date DATE NOT NULL, site_id INT NOT NULL, channel VARCHAR(32) NOT NULL, page_views BIGINT SUM DEFAULT "0", distinct_users BITMAP BITMAP_UNION ) AGGREGATE KEY(event_date, site_id, channel) PARTITION BY RANGE(event_date) () DISTRIBUTED BY HASH(site_id) BUCKETS 16 PROPERTIES ( "replication_num" = "3" ); By leveraging the BITMAP_UNION aggregate function, Doris dynamically calculates exact real-time unique visitor counts (count(distinct)) via fast bitwise operations at query time without scanning raw events.
For transactional change-data-capture (CDC) where record updates occur frequently, choose the Unique Key Model with Merge-on-Write (MoW) enabled:
CREATE TABLE IF NOT EXISTS customer_orders ( order_id BIGINT NOT NULL, customer_id INT NOT NULL, order_status VARCHAR(20), total_amount DECIMAL(12, 2), updated_at DATETIME ) UNIQUE KEY(order_id) DISTRIBUTED BY HASH(order_id) BUCKETS 32 PROPERTIES ( "replication_num" = "3", "enable_unique_key_merge_on_write" = "true" ); Merge-on-Write eliminates on-read reconciliation overhead, providing standard read speeds comparable to append-only tables.
2. High-Throughput Stream Ingestion via Routine Load
Instead of provisioning intermediate Spark or Flink clusters to stream records from Kafka into storage, Doris provides an internal ingestion coordinator known as Routine Load.
The Frontend (FE) divides Kafka topic partitions among Backend (BE) nodes, pulling messages continuously and committing checkpoints atomically:
CREATE ROUTINE LOAD direct_orders_stream ON customer_orders COLUMNS(order_id, customer_id, order_status, total_amount, updated_at) PROPERTIES ( "desired_concurrent_number" = "4", "max_batch_interval" = "5", "max_batch_rows" = "200000", "format" = "json" ) FROM KAFKA ( "kafka_broker_list" = "kafka-broker-1:9092,kafka-broker-2:9092", "kafka_topic" = "orders.events", "property.group.id" = "doris_orders_consumer", "property.client.id" = "doris_routine_load_01" ); Monitor consumption lag directly within MySQL CLI:
SHOW ROUTINE LOAD FOR direct_orders_stream\G 3. Sizing Buckets and Tablet Pruning
A common mistake in real-time OLAP deployments is setting an arbitrary bucket count. Buckets represent physical tablets managed by backend daemons.
- Aim for 1GB to 10GB per tablet: Over-sharding leads to excessive file metadata, slow compactions, and memory bloat on FE nodes. Under-sharding prevents Doris from distributing vectorized segment scanners across CPU cores.
- Partition by time, distribute by entity: Partitioning by day or month enables instant partition pruning during queries and lets dynamic TTL drop historical data without running expensive
DELETEqueries.
Deepen Your Real-Time OLAP Knowledge
Scaling Apache Doris for production requires careful configuration of Frontend BDB JE consensus, compaction thread management, and lakehouse query acceleration over Apache Iceberg and Hudi.
If you want ready-to-run configurations, architecture blueprints, and battle-tested operational playbooks, check out The Apache Doris & Real-Time OLAP Handbook: Sub-Second Analytics, Stream Ingestion & Lakehouse Queries ($24).
The handbook covers:
- Complete Frontend and Backend cluster sizing, memory limit tuning, and compaction strategies
- End-to-end CDC streaming pipelines (Debezium, Flink-Doris-Connector, and Native Routine Load)
- Lakehouse federated acceleration over Iceberg, Hudi, and Hive with unified metadata catalogs
- Production runbooks for high availability, rolling upgrades, and disaster recovery
