Loading data in Druid is called ingestion or indexing. When you ingest data into Druid, Druid reads the data from your source system and stores it in data files called segments. In general, segment files contain a few million rows.

For most ingestion methods, the Druid MiddleManager processes or the Indexer processes load your source data. One exception is Hadoop-based ingestion, which uses a Hadoop MapReduce job on YARN MiddleManager or Indexer processes to start and monitor Hadoop jobs.

During ingestion Druid creates segments and stores them in deep storage. Historical nodes load the segments into memory to respond to queries. For streaming ingestion, the Middle Managers and indexers can respond to queries in real-time with arriving data. See the Storage design section of the Druid design documentation for more information.

This topic introduces streaming and batch ingestion methods. The following topics describe ingestion concepts and information that apply to all ingestion methods:

  • Druid data model introduces concepts of datasources, primary timestamp, dimensions, and metrics.
  • Data rollup describes rollup as a concept and provides suggestions to maximize the benefits of rollup.
  • Partitioning describes time chunk and secondary partitioning in Druid.
  • Ingestion spec reference provides a reference for the configuration options in the ingestion spec.

For additional information about concepts and configurations that are unique to each ingestion method, see the topic for the ingestion method.

Ingestion methods

The tables below list Druid’s most common data ingestion methods, along with comparisons to help you choose the best one for your situation. Each ingestion method supports its own set of source systems to pull from. For details about how each method works, as well as configuration properties specific to that method, check out its documentation page.

Streaming

The most recommended, and most popular, method of streaming ingestion is the Kafka indexing service that reads directly from Kafka. Alternatively, the Kinesis indexing service works with Amazon Kinesis Data Streams.

Streaming ingestion uses an ongoing process called a supervisor that reads from the data stream to ingest data into Druid.

This table compares the options:

MethodKafkaKinesis
Supervisor typekafkakinesis
How it worksDruid reads directly from Apache Kafka.Druid reads directly from Amazon Kinesis.
Can ingest late data?YesYes
Exactly-once guarantees?YesYes

Batch

When doing batch loads from files, you should use one-time tasks, and you have three options: index_parallel (native batch; parallel), index_hadoop (Hadoop-based), or index (native batch; single-task).

In general, we recommend native batch whenever it meets your needs, since the setup is simpler (it does not depend on an external Hadoop cluster). However, there are still scenarios where Hadoop-based batch ingestion might be a better choice, for example when you already have a running Hadoop cluster and want to use the cluster resource of the existing cluster for batch ingestion.

This table compares the three available options:

MethodNative batch (parallel)Hadoop-basedNative batch (simple)
Task typeindex_parallelindex_hadoopindex
Parallel?Yes, if inputFormat is splittable and maxNumConcurrentSubTasks > 1 in tuningConfig. See data format documentation for details.Yes, always.No. Each task is single-threaded.
Can append or overwrite?Yes, both.Overwrite only.Yes, both.
External dependenciesNone.Hadoop cluster (Druid submits Map/Reduce jobs).None.
Input locationsAny inputSource.Any Hadoop FileSystem or Druid datasource.Any inputSource.
File formatsAny inputFormat.Any Hadoop InputFormat.Any inputFormat.
Rollup modesPerfect if forceGuaranteedRollup = true in the tuningConfig.Always perfect.Perfect if forceGuaranteedRollup = true in the tuningConfig.
Partitioning optionsDynamic, hash-based, and range-based partitioning methods are available. See partitionsSpec for details.Hash-based or range-based partitioning via partitionsSpec.Dynamic and hash-based partitioning methods are available. See partitionsSpec for details.