Sitemap
troy liu

troy liu

Apache Doris

5 min readDec 8, 2023

--

一、Introduction to Doris

Apache Doris is a high-performance real-time analytical database based on MPP architecture. Positioned within the data flow.

Press enter or click to view image in full size

It serves as a comprehensive MPP data warehouse that stores processed structured data from upstream OLTP systems, log systems, and tracking systems. Doris provides functionalities such as report analysis, information querying, and database analysis, and acts as an SQL engine for accelerated querying of external data sources including Hive, Iceberg, Hudi, MySQL, ElectricSearch, with official Flink and Spark Connectors. It supports federated analysis and ensures that Doris data does not become isolated.
Key features include MPP architecture, efficient columnar storage engine, high performance, availability, and elasticity, ANSI SQL support, multi-table joins, MySQL protocol support, pre-aggregation, materialized views with automatic updates, efficient batch and real-time data import, real-time data updates, and high-concurrency queries.

Introduction to Relevant Terminology

FE: Frontend, the front-end node of Doris. It primarily handles client requests, metadata, cluster management, and query plan generation.

BE: Backend, the back-end node of Doris. It is mainly responsible for data storage and management, as well as query plan execution.

bdbje: Oracle Berkeley DB Java Edition. In Doris, bdbje is used for persistent metadata operation logging and FE high availability functions.

Tablet: A physical storage unit representing the actual storage of a table. After partitioning and bucketing, a table is stored in the BE as Tablets. Each Tablet includes metadata and several continuous RowSets.

Rowset: A collection of data changes within a Tablet, including data import, deletion, and update. RowSets are recorded based on version information, with each change generating a version.

Version: Comprised of “Start” and “End” attributes, maintaining records of data changes. It is typically used to represent the version range of a Rowset. A new import generates a Rowset with equal “Start” and “End,” while Compaction generates a version with a range after the process.

Segment: Represents the data segment within a Rowset. Multiple Segments make up a Rowset.

Compaction: The process of merging continuous versions of Rowsets, which includes data compression operations.

Broker: A middleware service in Doris that interfaces with external data sources such as HDFS and object storage, assisting in import/export functions.

二、Doris Architecture Analysis

Doris primarily consists of two components, FE and BE. FE is responsible for query compilation, distribution, and metadata management (based on memory, similar to HDFS NN); BE primarily handles query execution and the storage system.

Press enter or click to view image in full size

From the perspective of data storage: FE stores and maintains cluster metadata; BE stores physical data.

Get troy liu’s stories in your inbox

Join Medium for free to get updates from this writer.

From the perspective of query processing: FE nodes receive and parse query requests, plan query execution, schedule queries, and return query results; BE nodes execute queries in a distributed manner based on the physical plan generated by FE.

1.FE
FE primarily consists of three roles: leader, follower, and observer. The leader and follower roles are primarily used to achieve high availability of metadata, ensuring that in the event of a single node failure, metadata can be restored online in real time without affecting the entire service. The observer, on the other hand, is used to expand query nodes. In other words, if the cluster experiences significant pressure, expanding the query capability can be achieved by adding observer nodes. Observers do not participate in any writes, only in reads.

FE: Primarily responsible for query compilation, distribution, and metadata management (based on memory, similar to HDFS NN)

Manages metadata, executes SQL DDL commands, and uses Catalog to record information such as databases, tables, partitions, tablet replicas, etc.
FE is deployed with high availability, using replication protocols to select a leader and synchronize metadata between leader and follower nodes. All metadata modification operations are completed by the FE leader node, while FE follower nodes can perform read operations. Metadata read and write operations adhere to sequential consistency. The number of FE nodes follows the formula 2n+1, tolerating the failure of n nodes. In the event of an FE leader failure, a new leader is selected from the existing follower nodes to complete failover.
FE’s SQL layer parses, analyzes, rewrites, performs semantic analysis, and optimizes relational algebra for user-submitted SQL, generating logical execution plans.
FE’s Planner converts logical plans into physically distributable execution plans and distributes them to a group of BE nodes.
FE supervises BE, manages BE’s online and offline status, and maintains the number of tablet replicas based on the survival and health status of BE nodes.
FE coordinates data imports to ensure data import consistency.

2.BE
BE is the backend node of Doris, responsible for data storage and SQL computation execution.

BE nodes are all equal peers, and FE distributes data to the corresponding BE nodes according to a specific strategy. During data import, data is written directly to BE nodes without passing through FE. BE is responsible for formatting imported data and generating relevant indexes. When executing SQL computations, a SQL statement is first planned into logical execution units according to specific semantics, and then split into specific physical execution units based on the distribution of data. Physical execution units are executed on the data storage nodes, thus avoiding data transmission and copying, which optimizes query performance.

When a query is executed in an MPP (Massively Parallel Processing) cluster, it is divided into a tree-like execution plan. The coordination of this tree’s execution is handled by the Coordinator. The leaf nodes of the tree, also called Plan Fragments, are assigned to query executors on BE nodes, representing the role of the query executor module.

Press enter or click to view image in full size

BE is specifically responsible for the following tasks:

  1. Managing tablet replicas, where a tablet is a subset of a table formed through partitioning and bucketing, utilizing columnar storage.
  2. Under the guidance of FE, creating or deleting sub-tables.
  3. Receiving physical execution plans distributed by FE and designating BE coordinator nodes. Under the coordination of the BE coordinator, working collaboratively with other BE workers to complete the execution.
  4. Reading from the local columnar storage engine to retrieve data and swiftly filter data through indexing and predicate pushdown.
  5. Executing compact tasks in the background to reduce read amplification during queries.

BTW:

If everyone has a need for a self-built website, they can purchase through this link, which offers many discounts.

https://www.interserver.net/r/938217

--

--