Nir Bar On
07/28/2025, 1:36 PMdruid_query_groupBy_maxResults=500000
druid_query_groupBy_maxIntermediateRows=1000000
druid_query_groupBy_maxMergingDictionarySize=268435456
what can be the cause broker is crashing .. , how can I trouble shot this to figure out what I need to do to fix it ?
can be that broker is not using the direct memory and instead keep using the heap memory ?
broker status paylodd
“memory”: {
“maxMemory”: 8589934592,
“totalMemory”: 8589934592,
“freeMemory”: 6974955008,
“usedMemory”: 1614979584,
“directMemory”: 4294967296
}Nir Bar On
07/28/2025, 1:42 PMJRob
08/01/2025, 2:38 PMJRob
08/01/2025, 2:44 PM# HTTP server settings
druid.server.http.numThreads=60
druid.server.http.maxSubqueryRows=100000
druid.server.http.maxIdleTime=PT10M
# Query prioritization and laning
druid.query.scheduler.numThreads=50
# HTTP client settings
druid.broker.http.numConnections=50
druid.broker.http.maxQueuedBytes=10000000
# Processing threads and buffers
druid.processing.buffer.sizeBytes=1000000000
druid.processing.numMergeBuffers=2
druid.processing.numThreads=4
druid.processing.tmpDir=var/druid/processing
# Query cache disabled -- push down caching and merging instead
druid.broker.cache.useCache=false
druid.broker.cache.populateCache=false
# Group By Query Tuning
druid.query.groupBy.maxMergingDictionarySize=1073741824
druid.query.groupBy.maxOnDiskStorage=0
druid.sql.planner.requireTimeCondition=falseJRob
08/01/2025, 2:45 PM-server
-Xms16g
-Xmx16g
-XX:MaxDirectMemorySize=16g
-XX:+ExitOnOutOfMemoryError
-XX:+UseG1GC
-Duser.timezone=UTC
-Dfile.encoding=UTF-8
-Djava.io.tmpdir=var/tmp
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager
-Dservice=brokerJRob
08/01/2025, 2:45 PMMaxDirectMemorySize. Druid uses a LOT of that.JRob
08/01/2025, 2:46 PMNir Bar On
08/01/2025, 3:09 PMJRob
08/01/2025, 3:09 PMThe amount of direct memory needed by Druid is at least druid.processing.buffer.sizeBytes * (druid.processing.numMergeBuffers + druid.processing.numThreads + 1). You can ensure at least this amount of direct memory is available by providing -XX:MaxDirectMemorySize=<VALUE> in druid.indexer.runner.javaOptsArray as documented above.
Assuming you have 4 cores your default values would end up being:
druid.processing.buffer.sizeBytes = auto (max: 1GiB)
druid.processing.numMergeBuffers = 2
druid.processing.numThreads = 3
Total: max 6 GiB
The documentation on druid.processing.buffer.sizeBytes states the size is automatically determined to a maximum of 1GiB. We set ours a little bit lower than that maximum because we found that the calculation from the documentation requires some additional headroom. You may want to consider as well. But the primary thing is to set the MaxDirectMemorySize based on the above.JRob
08/01/2025, 3:11 PMnumMergeBuffers is needed for the groupBy queries. We found that 2 works. We decreased numThreads to fit the memory available.Nir Bar On
08/01/2025, 3:11 PMJRob
08/01/2025, 3:12 PMJRob
08/01/2025, 3:13 PMNir Bar On
08/01/2025, 3:13 PMJRob
08/01/2025, 3:14 PMJRob
08/01/2025, 3:14 PMNote: Even if cache is enabled, for groupBy queries, segment level cache does not work on Brokers. See Query caching for more information.JRob
08/01/2025, 3:20 PM# Query cache
druid.historical.cache.useCache=true
druid.historical.cache.populateCache=true
druid.cache.type=caffeine
druid.cache.sizeInBytes=2000000000Nir Bar On
08/03/2025, 5:57 PM- Name: JAVA_OPTS
Value: "-Xms10g -Xmx10g -XX:MaxDirectMemorySize=5g -XX:+UseG1GC"
and set useCache / populateCache both to false
with this setup query working , broker is not crash with out-of-memory excetption