Hello everyone, I am a newbie in Apache Druid and ...
# general
a
Hello everyone, I am a newbie in Apache Druid and big data. I am worried about the lack of performance. I have 21 columns; most are string, and one is geospatial data. All columns are indexed. My system specs are: 8 core, 32GB RAM and apache setup is single server, micro-quickstart. I have 5.6 billion rows in the data source, and the segment granularity is the hour. The total number of segments is 26200. Here is my query and it takes 4-5 min.
Copy code
{
  "queryType": "scan",
  "dataSource": "mobility",
  "intervals": [
    "2024-01-01T00:00:00.000Z/2025-01-01T00:00:00.000Z"
  ],
  "columns": [
    "advertiserid"
  ],
  "filter": {
    "type": "selector",
    "dimension": "advertiserid",
    "value": "0104c0fe-b9b0-6e03-1b7f-f186d7f16b3e"
  }
}
Is it normal to take this much time?
g
this is basically equivalent to the SQL
Copy code
SELECT advertiserid
FROM mobility
WHERE
  advertiserid = '0104c0fe-b9b0-6e03-1b7f-f186d7f16b3e'
  AND __time >= TIMESTAMP '2024-01-01 00:00:00'
  AND __time < TIMESTAMP '2025-01-01 00:00:00'
it would return every row containing that advertiserid
each row would just have that same advertiserid, so it would be potentially lots of copies of the same advertiserid
this could be quite a lot of redundant data & i wonder if it's really what you want?
a
This was about measuring only the query time. So the actual query will be like that
Copy code
SELECT "__time", "advertiserid", "coordinates", name 
FROM mobility
WHERE
  "advertiserid" IN ('0104c0fe-b9b0-6e03-1b7f-f186d7f16b3e','02a2dc7e-62db-480b-9387-61ba28988007','04b027f3-3e66-6d40-ae0c-c0f0f69903f2')
  AND "__time" >= TIMESTAMP '2024-01-01 00:00:00'
  AND "__time" < TIMESTAMP '2025-01-01 00:00:00'
We have some list of ids and need to retrieve geolocation and name based on advertiserid.
g
how much data does the query return? the query should run pretty efficiently assuming there are indexes on
advertiserid
(which would be there by default unless you switched them off). perhaps it's returning a very large amount of data?
a
return size is 340. Here is the screenshot of previous query
g
that takes 4–5 minutes? that's surprising, I would have expected much shorter
it's possible your segments are too small. 26200 segments for 5.6 billion rows is an avg of about 200k rows/segment. the indexes are per-segment, so indexed operations are more efficient if segments are larger. i bet that compacting this data with a target segment size of 5 million rows would help
a
Yes, that's surprising to me, too. Just an assumption if the whole segments have 5M rows (around 130B total rows), so the query time takes this much or takes longer? In my dataset, the number of rows varies from 1 to 5M for each segment, but the average is 200K rows/segment, as you stated. When I try to compact them to 5M rows/segment, I got
Terminating due to java.lang.OutOfMemoryError: Java heap space
. I couldn't fix this issue, although I modified the middle manager's jvm config such that
-Xmx32g
,
-Xms8g
. However, this issue is another subject. Firstly, I need to check whether the druid performance is enough or not for me.
g
hmm, i'm curious why the task ran out of memory. it may work better if you use
bin/start-druid
to start Druid rather than the micro quickstart. that start script sizes memory pools automatically based on the amount of memory available on your machine
a
I will try this, and I will share the results. Thanks for your help by the way.
I accidentally removed the deep storage, so ingesting data will take 2 days. Then, I can share some results. Also, I updated the Druid version from 29 to 32.
Finally, all data is imported and the compact task gives the below error.
2025-04-08T14:37:17,933 INFO [[coordinator-issued_compact_mobility_pfenclia_2025-04-08T14:32:17.445Z]-batch-appenderator-push] org.apache.druid.segment.realtime.appenderator.BatchAppenderator - Push started, processsing[1] sinks
Terminating due to java.lang.OutOfMemoryError: Java heap space
Although I use
bin/start-druid
Hello, @Gian Merlino, I tested with the latest version of Apache Druid. It still lasts long (about 3,5 min.). Is the single-server setup not fast enough to handle such data?
g
how did you do the ingest? i do think that reorganizing the segments would help a huge amount. two things i would recommend: • target segment size in the 3–5 million row range • partition by
hour
, cluster by
advertiserid
. this will limit the number of segments that need to be checked for each query that uses
advertiserid IN (...)
and will speed things up as well
i understand the
OutOfMemoryError
make it tough to try that. i am not sure why that's happening. if you could capture a heap dump and see what the largest objects are, we could take a look. alternatively- you could try SQL
REPLACE
instead of a compaction. the command would be something like this:
Copy code
REPLACE INTO table2 OVERWRITE ALL
SELECT * FROM table1
PARTITIONED BY DAY
CLUSTERED BY advertiserId