# Apache Druid

**Apache Druid** 是一个开源、分布式的实时分析数据库，专为面向事件的大型数据集上的快速切片切块分析（OLAP 查询）而设计，其主要需求是低延迟摄取、亚秒级查询性能和高可用性<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup><sup> • </sup><sup>[2](https://druid.apache.org/docs/latest/design/)</sup>。用户可通过内置的 SQL 和 JSON API 以及第三方应用与之交互，它通常被用作分析型应用图形界面和需要快速聚合的高并发 API 的后端<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup><sup> • </sup><sup>[2](https://druid.apache.org/docs/latest/design/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 类型 | 面向事件数据的分布式、列式、实时分析（OLAP）数据库<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup><sup> • </sup><sup>[2](https://druid.apache.org/docs/latest/design/)</sup> |
| 起源 | 2011 年在 Metamarkets 开始开发；2012 年末以 GPL 协议开源，2015 年初改用 Apache 2.0 协议<sup>[3](https://www.slideshare.net/slideshow/premier-insideout-apache-druid/98313708)</sup> |
| Apache 项目 | 2019 年 12 月 18 日经董事会决议成为 Apache 项目；截至 2026 年 3 月报告，有 75 名提交者和 41 名 PMC 成员<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup> |
| 最新版本 | 38.0.0，2026 年 10 月 1 日发布，包含来自 38 位贡献者的 291 项以上变更<sup>[4](https://druid.apache.org/docs/latest/release-info/release-notes.html/)</sup> |
| 存储模型 | 按时间分区的不可变列式段文件；建议段大小为 300 至 700 MB<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup> |
| 流式摄取 | 与 Apache Kafka 和 Amazon Kinesis 原生集成，具备精确一次保证和迟到数据处理能力<sup>[6](https://druid.apache.org/docs/latest/ingestion/)</sup> |
| 查询语言 | Druid SQL（在 Broker 上规划，转换为原生查询）和原生查询<sup>[7](https://druid.apache.org/docs/latest/querying/sql/)</sup> |

## 历史

Druid 最初是 Metamarkets 广告技术分析产品的基础设施，开发始于 2011 年<sup>[3](https://www.slideshare.net/slideshow/premier-insideout-apache-druid/98313708)</sup>。最初的开发者在 2012 年末以 GPL 许可证开源了代码，并于 2015 年初切换到 Apache 2.0 许可证<sup>[3](https://www.slideshare.net/slideshow/premier-insideout-apache-druid/98313708)</sup>。该项目进入 Apache 孵化器，Apache 软件基金会董事会于 2019 年 12 月 18 日批准将 Apache Druid 项目确立为顶级项目<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup>。

该项目向 ASF 董事会报告为持续活跃状态，活动频繁。在经历了一段被用户批评发布间隔过长的时期后，它已转向持续的季度节奏，通常每年发布三到四次主要版本<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup>。

## 架构

Druid 采用分布式的微服务风格架构，各服务可独立配置和扩展，因此某个组件故障不会立即影响其他组件<sup>[8](https://druid.apache.org/docs/latest/design/architecture/)</sup>。主要服务包括<sup>[8](https://druid.apache.org/docs/latest/design/architecture/)</sup>：

- **Coordinator**，管理集群上的数据可用性，将段分配给服务器并在 Historical 之间进行均衡。
- **Overlord**，控制摄取工作负载向 Middle Manager 的分配，并协调段的发布。
- **Broker**，处理来自外部客户端的查询。
- **Router**，将请求路由到 Broker、Coordinator 和 Overlord。
- **Historical**，存储可查询的数据。
- **Middle Manager 和 Peon**，负责摄取数据；**Indexer** 作为替代的任务执行系统。

在部署方面，文档建议将这些服务归为三种服务器类型：Master、Query 和 Data<sup>[8](https://druid.apache.org/docs/latest/design/architecture/)</sup>。

Druid 还与更广泛的生态系统相连：Apache Calcite 用于 SQL 规划，Apache Curator 和 ZooKeeper 用于协调，Kafka、Hadoop 和 Iceberg 作为数据源，Avro、ORC 或 Parquet 作为输入格式，DataSketches 用于可扩展的近似算法；Superset 则可以将 Druid 作为数据源进行查询<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup>。

## 段与存储

Druid 将数据和索引存储在按时间分区的段文件中，每个包含数据的时间间隔创建一个段；间隔粒度由 `segmentGranularity` 参数设置<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup>。段文件是列式的，即每一列存储在独立的数据结构中，因此查询只扫描它需要的列<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup>。有三种基本列类型：时间戳和指标，以压缩的整数或浮点数组存储；维度列，支持过滤和分组聚合，并带有将值映射到整数 ID 的字典以及位图索引<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup>。

段大小是一个调优目标：文档建议每个段文件为 300 至 700 MB，`targetRowsPerSegment` 参数的起始值约为 500 万行，因为每个段在每次查询中由单个线程处理，过大和过小的段都会降低并行度<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup><sup> • </sup><sup>[9](https://druid.staged.apache.org/docs/37.0.0/operations/segment-optimization/)</sup>。压缩任务读取某个时间间隔的现有段并将其重写为最优大小的集合，从而减少每段处理和内存开销<sup>[5](https://druid.apache.org/docs/latest/design/segments/)</sup><sup> • </sup><sup>[10](https://druid.apache.org/docs/latest/data-management/compaction/)</sup>。

## 摄取

将数据加载到 Druid 称为摄取或索引<sup>[6](https://druid.apache.org/docs/latest/ingestion/)</sup>。在摄取过程中，Druid 创建段并将其存储在深度存储中；Historical 节点将段加载到内存中以回答查询，而对于流式摄取，Middle Manager 和 Indexer 可以利用到达的数据实时回答查询<sup>[6](https://druid.apache.org/docs/latest/ingestion/)</sup>。

有两种流式方法可用，均由持续运行的 supervisor 控制：Kafka，Druid 直接从 [Apache Kafka](https://www.edgepedia.org/zh/apache-kafka) 读取；Kinesis，直接从 [Amazon Kinesis](https://www.edgepedia.org/zh/amazon-kinesis) 读取。两者都能摄取迟到数据并提供精确一次保证<sup>[6](https://druid.apache.org/docs/latest/ingestion/)</sup>。批量摄取同样有两种形式：使用 `index_parallel` 任务的原生批处理作业，以及以 INSERT 或 REPLACE 语句提交的基于 SQL 的批处理作业，后者始终使用完美汇总<sup>[6](https://druid.apache.org/docs/latest/ingestion/)</sup>。

Druid 始终按时间将数据源分区为时间块，并进一步将每个块分区为不可变的段；按时间过滤的查询可以剪枝其考虑的段，而覆盖和压缩等数据管理操作会在时间分区上获取独占写锁<sup>[11](https://druid.apache.org/docs/latest/ingestion/partitioning/)</sup>。最常见的时间块选择是 `hour` 和 `day`，其中 `hour` 在流式摄取中尤为常见，因为压缩可以在摄取后以更小的延迟跟进<sup>[11](https://druid.apache.org/docs/latest/ingestion/partitioning/)</sup>。

## 查询

Druid 支持两种查询语言：Druid SQL 和原生查询。Druid SQL 查询在 Broker 上规划，并在执行前转换为原生查询语言<sup>[7](https://druid.apache.org/docs/latest/querying/sql/)</sup>。该项目宣传该引擎可在数十亿至数万亿行的高基数数据集上执行毫秒级 OLAP 查询，无需预定义或缓存查询，并支持每秒数百至数十万次查询的应用<sup>[12](https://druid.apache.org/index.html)</sup>。

缓存可以改善频繁访问数据的查询时间。每段缓存适合混合实时和历史数据的查询，因为缓存的历史结果可以与新计算的实时结果合并；Broker 上的全查询缓存适合批量摄取的数据，因为摄取很少使缓存结果失效<sup>[13](https://druid.apache.org/docs/latest/querying/caching/)</sup>。

## 用例

Druid 最适合面向事件的数据<sup>[2](https://druid.apache.org/docs/latest/design/)</sup>。文档记载的应用领域包括点击流分析、网络遥测、服务器指标存储、供应链分析、应用性能指标、数字营销分析、商业智能和客户分析<sup>[2](https://druid.apache.org/docs/latest/design/)</sup>。它常用于点击流、浏览流和活动流，包括衡量用户参与度、跟踪 A/B 测试，以及精确或近似计算去重计数<sup>[14](https://druid.apache.org/use-cases/)</sup>。与 Presto 和 Hive 等 SQL-on-Hadoop 引擎的构建方式不同，Druid 旨在处理大量并发用户，并在不到一秒内交付查询以进行交互式数据探索<sup>[14](https://druid.apache.org/use-cases/)</sup>。

## 对比基准中的性能

[ClickBench](https://www.edgepedia.org/zh/clickbench) 基准套件（在 100 GB hits 数据集、c6a.4xlarge 上运行 43 个查询）在此工作负载上将 Druid 排在较新引擎之后：它在 43 个查询中赢得 1 个，已完成查询的热查询时间中位数为 1.77 秒，14 个查询失败，加载时间为 5.5 小时，压缩大小为 42.09 GiB，基准发布者将此归因于 Druid 的段构建和索引密集型摄取模型<sup>[15](https://clickhouse.com/resources/engineering/fastest-olap-databases)</sup>。同一来源指出，在该套件上失败五次或以上的引擎，包括 Druid 和 [Apache Pinot](https://www.edgepedia.org/zh/apache-pinot)，在部署前需要工作负载预验证<sup>[15](https://clickhouse.com/resources/engineering/fastest-olap-databases)</sup>。供应商发布的基准结果应结合其赞助背景来解读，而 Druid 的设计目标是并发的、面向用户的、时间过滤的工作负载，而非任意分析查询<sup>[14](https://druid.apache.org/use-cases/)</sup><sup> • </sup><sup>[15](https://clickhouse.com/resources/engineering/fastest-olap-databases)</sup>。

## 项目状态与发布

最新稳定版本为 38.0.0，日期为 2026 年 10 月 1 日<sup>[4](https://druid.apache.org/docs/latest/release-info/release-notes.html/)</sup>。它包含来自 38 位贡献者的超过 291 项变更，增加了对 Java 25 的支持，同时保留 Java 21，并放弃了对 Java 17 的支持<sup>[4](https://druid.apache.org/docs/latest/release-info/release-notes.html/)</sup>。近期主要版本包括 37.0.0（2026 年 5 月 8 日）和 36.0.0（2026 年 2 月 9 日）<sup>[16](https://druid.apache.org/downloads/)</sup>。2026 年 3 月的董事会报告统计了自上次报告以来来自 35 位贡献者的 274 次提交和新建的 359 个拉取请求，Slack 社区有 3,365 名成员，75 名提交者和 41 名 PMC 成员<sup>[1](https://apache.org/foundation/board/minutes/Druid.html)</sup>。

## References

1. [Board history: Druid, Apache Software Foundation](https://apache.org/foundation/board/minutes/Druid.html)
2. [Introduction to Apache Druid, Apache Druid documentation](https://druid.apache.org/docs/latest/design/)
3. [Premier Inside-Out: Apache Druid (SlideShare)](https://www.slideshare.net/slideshow/premier-insideout-apache-druid/98313708)
4. [Release notes, Apache Druid documentation](https://druid.apache.org/docs/latest/release-info/release-notes.html/)
5. [Segments, Apache Druid documentation](https://druid.apache.org/docs/latest/design/segments/)
6. [Ingestion overview, Apache Druid documentation](https://druid.apache.org/docs/latest/ingestion/)
7. [Druid SQL overview, Apache Druid documentation](https://druid.apache.org/docs/latest/querying/sql/)
8. [Architecture, Apache Druid documentation](https://druid.apache.org/docs/latest/design/architecture/)
9. [Segment size optimization, Apache Druid 37.0.0 documentation](https://druid.staged.apache.org/docs/37.0.0/operations/segment-optimization/)
10. [Compaction, Apache Druid documentation](https://druid.apache.org/docs/latest/data-management/compaction/)
11. [Partitioning, Apache Druid documentation](https://druid.apache.org/docs/latest/ingestion/partitioning/)
12. [Apache Druid project homepage](https://druid.apache.org/index.html)
13. [Query caching, Apache Druid documentation](https://druid.apache.org/docs/latest/querying/caching/)
14. [Use Cases, Apache Druid](https://druid.apache.org/use-cases/)
15. [The fastest OLAP databases in 2026 (ranked by ClickBench), ClickHouse](https://clickhouse.com/resources/engineering/fastest-olap-databases)
16. [Download, Apache Druid](https://druid.apache.org/downloads/)

---
*Initially written Oct 26, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Database engines and systems › Time-series and streaming data stores

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/apache-druid

English original: https://www.edgepedia.org/apache-druid
