blob: 5d4512d23bc385348f4da823fd32e78495f04815 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Apache Druid">
<meta name="keywords" content="druid,kafka,database,analytics,streaming,real-time,real time,apache,open source">
<meta name="author" content="Apache Software Foundation">
<title>Druid | Basic Cluster Tuning</title>
<link rel="alternate" type="application/atom+xml" href="/feed">
<link rel="shortcut icon" href="/img/favicon.png">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700,300italic|Open+Sans:300italic,400italic,600italic,400,300,600,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/bootstrap-pure.css?v=1.1">
<link rel="stylesheet" href="/css/base.css?v=1.1">
<link rel="stylesheet" href="/css/header.css?v=1.1">
<link rel="stylesheet" href="/css/footer.css?v=1.1">
<link rel="stylesheet" href="/css/syntax.css?v=1.1">
<link rel="stylesheet" href="/css/docs.css?v=1.1">
<script>
(function() {
var cx = '000162378814775985090:molvbm0vggm';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
</head>
<body>
<!-- Start page_header include -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<div class="top-navigator">
<div class="container">
<div class="left-cont">
<a class="logo" href="/"><span class="druid-logo"></span></a>
</div>
<div class="right-cont">
<ul class="links">
<li class=""><a href="/technology">Technology</a></li>
<li class=""><a href="/use-cases">Use Cases</a></li>
<li class=""><a href="/druid-powered">Powered By</a></li>
<li class=""><a href="/docs/latest/design/">Docs</a></li>
<li class=""><a href="/community/">Community</a></li>
<li class="header-dropdown">
<a>Apache</a>
<div class="header-dropdown-menu">
<a href="https://www.apache.org/" target="_blank">Foundation</a>
<a href="https://www.apache.org/events/current-event" target="_blank">Events</a>
<a href="https://www.apache.org/licenses/" target="_blank">License</a>
<a href="https://www.apache.org/foundation/thanks.html" target="_blank">Thanks</a>
<a href="https://www.apache.org/security/" target="_blank">Security</a>
<a href="https://www.apache.org/foundation/sponsorship.html" target="_blank">Sponsorship</a>
</div>
</li>
<li class=" button-link"><a href="/downloads.html">Download</a></li>
</ul>
</div>
</div>
<div class="action-button menu-icon">
<span class="fa fa-bars"></span> MENU
</div>
<div class="action-button menu-icon-close">
<span class="fa fa-times"></span> MENU
</div>
</div>
<script type="text/javascript">
var $menu = $('.right-cont');
var $menuIcon = $('.menu-icon');
var $menuIconClose = $('.menu-icon-close');
function showMenu() {
$menu.fadeIn(100);
$menuIcon.fadeOut(100);
$menuIconClose.fadeIn(100);
}
$menuIcon.click(showMenu);
function hideMenu() {
$menu.fadeOut(100);
$menuIconClose.fadeOut(100);
$menuIcon.fadeIn(100);
}
$menuIconClose.click(hideMenu);
$(window).resize(function() {
if ($(window).width() >= 840) {
$menu.fadeIn(100);
$menuIcon.fadeOut(100);
$menuIconClose.fadeOut(100);
}
else {
$menu.fadeOut(100);
$menuIcon.fadeIn(100);
$menuIconClose.fadeOut(100);
}
});
</script>
<!-- Stop page_header include -->
<div class="container doc-container">
<p> Looking for the <a href="/docs/0.17.1/">latest stable documentation</a>?</p>
<div class="row">
<div class="col-md-9 doc-content">
<p>
<a class="btn btn-default btn-xs visible-xs-inline-block visible-sm-inline-block" href="#toc">Table of Contents</a>
</p>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<h1 id="basic-cluster-tuning">Basic Cluster Tuning</h1>
<p>This document provides basic guidelines for configuration properties and cluster architecture considerations related to performance tuning of an Apache Druid (incubating) deployment. </p>
<p>Please note that this document provides general guidelines and rules-of-thumb: these are not absolute, universal rules for cluster tuning, and this introductory guide is not an exhaustive description of all Druid tuning properties, which are described in the <a href="../configuration/index.html">configuration reference</a>.</p>
<p>If you have questions on tuning Druid for specific use cases, or questions on configuration properties not covered in this guide, please ask the <a href="https://druid.apache.org/community/">Druid user mailing list or other community channels</a>.</p>
<h2 id="process-specific-guidelines">Process-specific guidelines</h2>
<h3 id="historical">Historical</h3>
<h4 id="heap-sizing">Heap sizing</h4>
<p>The biggest contributions to heap usage on Historicals are:
- Partial unmerged query results from segments
- The stored maps for <a href="../querying/lookups.html">lookups</a>.</p>
<p>A general rule-of-thumb for sizing the Historical heap is <code>(0.5GB * number of CPU cores)</code>, with an upper limit of ~24GB.</p>
<p>This rule-of-thumb scales using the number of CPU cores as a convenient proxy for hardware size and level of concurrency (note: this formula is not a hard rule for sizing Historical heaps).</p>
<p>Having a heap that is too large can result in excessively long GC collection pauses, the ~24GB upper limit is imposed to avoid this.</p>
<p>If caching is enabled on Historicals, the cache is stored on heap, sized by <code>druid.cache.sizeInBytes</code>.</p>
<p>Running out of heap on the Historicals can indicate misconfiguration or usage patterns that are overloading the cluster.</p>
<h5 id="lookups">Lookups</h5>
<p>If you are using lookups, calculate the total size of the lookup maps being loaded. </p>
<p>Druid performs an atomic swap when updating lookup maps (both the old map and the new map will exist in heap during the swap), so the maximum potential heap usage from lookup maps will be (2 * total size of all loaded lookups).</p>
<p>Be sure to add <code>(2 * total size of all loaded lookups)</code> to your heap size in addition to the <code>(0.5GB * number of CPU cores)</code> guideline.</p>
<h4 id="processing-threads-and-buffers">Processing Threads and Buffers</h4>
<p>Please see the <a href="#general-guidelines-for-processing-threads-and-buffers">General Guidelines for Processing Threads and Buffers</a> section for an overview of processing thread/buffer configuration.</p>
<p>On Historicals:
- <code>druid.processing.numThreads</code> should generally be set to <code>(number of cores - 1)</code>: a smaller value can result in CPU underutilization, while going over the number of cores can result in unnecessary CPU contention.
- <code>druid.processing.buffer.sizeBytes</code> can be set to 500MB.
- <code>druid.processing.numMergeBuffers</code>, a 1:4 ratio of merge buffers to processing threads is a reasonable choice for general use.</p>
<h4 id="direct-memory-sizing">Direct Memory Sizing</h4>
<p>The processing and merge buffers described above are direct memory buffers.</p>
<p>When a historical processes a query, it must open a set of segments for reading. This also requires some direct memory space, described in <a href="#segment-decompression">segment decompression buffers</a>.</p>
<p>A formula for estimating direct memory usage follows:</p>
<p>(<code>druid.processing.numThreads</code> + <code>druid.processing.numMergeBuffers</code> + 1) * <code>druid.processing.buffer.sizeBytes</code></p>
<p>The <code>+ 1</code> factor is a fuzzy estimate meant to account for the segment decompression buffers.</p>
<h4 id="connection-pool-sizing">Connection Pool Sizing</h4>
<p>Please see the <a href="#general-connection-pool-guidelines">General Connection Pool Guidelines</a> section for an overview of connection pool configuration.</p>
<p>For Historicals, <code>druid.server.http.numThreads</code> should be set to a value slightly higher than the sum of <code>druid.broker.http.numConnections</code> across all the Brokers in the cluster.</p>
<p>Tuning the cluster so that each Historical can accept 50 queries and 10 non-queries is a reasonable starting point.</p>
<h4 id="segment-cache-size">Segment Cache Size</h4>
<p><code>druid.server.maxSize</code> controls the total size of segment data that can be assigned by the Coordinator to a Historical.</p>
<p><code>druid.segmentCache.locations</code> specifies locations where segment data can be stored on the Historical. The sum of available disk space across these locations should equal <code>druid.server.maxSize</code>.</p>
<p>Segments are memory-mapped by Historical processes using any available free system memory (i.e., memory not used by the Historical JVM and heap/direct memory buffers or other processes on the system). Segments that are not currently in memory will be paged from disk when queried.</p>
<p>Therefore, <code>druid.server.maxSize</code> should be set such that a Historical is not allocated an excessive amount of segment data. As the value of (<code>free system memory</code> / <code>druid.server.maxSize</code>) increases, a greater proportion of segments can be kept in memory, allowing for better query performance.</p>
<h4 id="number-of-historicals">Number of Historicals</h4>
<p>The number of Historicals needed in a cluster depends on how much data the cluster has. For good performance, you will want enough Historicals such that each Historical has a good (<code>free system memory</code> / <code>druid.server.maxSize</code>) ratio, as described in the segment cache size section above.</p>
<p>Having a smaller number of big servers is generally better than having a large number of small servers, as long as you have enough fault tolerance for your use case.</p>
<h4 id="ssd-storage">SSD storage</h4>
<p>We recommend using SSDs for storage on the Historicals, as they handle segment data stored on disk.</p>
<h4 id="total-memory-usage">Total Memory Usage</h4>
<p>To estimate total memory usage of the Historical under these guidelines:</p>
<ul>
<li>Heap: <code>(0.5GB * number of CPU cores) + (2 * total size of lookup maps) + druid.cache.sizeInBytes</code></li>
<li>Direct Memory: <code>(druid.processing.numThreads + druid.processing.numMergeBuffers + 1) * druid.processing.buffer.sizeBytes</code></li>
</ul>
<p>The Historical will use any available free system memory (i.e., memory not used by the Historical JVM and heap/direct memory buffers or other processes on the system) for memory-mapping of segments on disk. For better query performance, you will want to ensure a good (<code>free system memory</code> / <code>druid.server.maxSize</code>) ratio so that a greater proportion of segments can be kept in memory.</p>
<h3 id="broker">Broker</h3>
<h4 id="heap-sizing">Heap Sizing</h4>
<p>The biggest contributions to heap usage on Brokers are:
- Partial unmerged query results from Historicals and Tasks
- The segment timeline: this consists of location information (which Historical/Task is serving a segment) for all currently <a href="../ingestion/index.html#segment-states">available</a> segments.
- Cached segment metadata: this consists of metadata, such as per-segment schemas, for all currently available segments.</p>
<p>The Broker heap requirements scale based on the number of segments in the cluster, and the total data size of the segments. </p>
<p>The heap size will vary based on data size and usage patterns, but 4G to 8G is a good starting point for a small or medium cluster (~15 servers or less). For a rough estimate of memory requirements on the high end, very large clusters with a node count on the order of ~100 nodes may need Broker heaps of 30GB-60GB.</p>
<p>If caching is enabled on the Broker, the cache is stored on heap, sized by <code>druid.cache.sizeInBytes</code>.</p>
<h4 id="direct-memory-sizing">Direct Memory Sizing</h4>
<p>On the Broker, the amount of direct memory needed depends on how many merge buffers (used for merging GroupBys) are configured. The Broker does not generally need processing threads or processing buffers, as query results are merged on-heap in the HTTP connection threads instead.</p>
<ul>
<li><code>druid.processing.buffer.sizeBytes</code> can be set to 500MB.</li>
<li><code>druid.processing.numThreads</code>: set this to 1 (the minimum allowed)</li>
<li><code>druid.processing.numMergeBuffers</code>: set this to the same value as on Historicals or a bit higher</li>
</ul>
<h5 id="note-on-the-deprecated-chunkperiod">Note on the deprecated <code>chunkPeriod</code></h5>
<p>There is one exception to the Broker not needing processing threads and processing buffers:</p>
<p>If the deprecated <code>chunkPeriod</code> property in the <a href="../querying/query-context.html">query context</a> is set, GroupBy V1 queries will use processing threads and processing buffers on the Broker.</p>
<p>Both <code>chunkPeriod</code> and GroupBy V1 are deprecated (use GroupBy V2 instead) and will be removed in the future, we do not recommend using them. The presence of the deprecated <code>chunkPeriod</code> feature is why a minimum of 1 processing thread must be configured, even if it&#39;s unused.</p>
<h4 id="connection-pool-sizing">Connection Pool Sizing</h4>
<p>Please see the <a href="#general-connection-pool-guidelines">General Connection Pool Guidelines</a> section for an overview of connection pool configuration.</p>
<p>On the Brokers, please ensure that the sum of <code>druid.broker.http.numConnections</code> across all the Brokers is slightly lower than the value of <code>druid.server.http.numThreads</code> on your Historicals and Tasks.</p>
<p><code>druid.server.http.numThreads</code> on the Broker should be set to a value slightly higher than <code>druid.broker.http.numConnections</code> on the same Broker.</p>
<p>Tuning the cluster so that each Historical can accept 50 queries and 10 non-queries, adjusting the Brokers accordingly, is a reasonable starting point.</p>
<h4 id="broker-backpressure">Broker Backpressure</h4>
<p>When retrieving query results from Historical processes or Tasks, the Broker can optionally specify a maximum buffer size for queued, unread data, and exert backpressure on the channel to the Historical or Tasks when limit is reached (causing writes to the channel to block on the Historical/Task side until the Broker is able to drain some data from the channel).</p>
<p>This buffer size is controlled by the <code>druid.broker.http.maxQueuedBytes</code> setting.</p>
<p>The limit is divided across the number of Historicals/Tasks that a query would hit: suppose I have <code>druid.broker.http.maxQueuedBytes</code> set to 5MB, and the Broker receives a query that needs to be fanned out to 2 Historicals. Each per-historical channel would get a 2.5MB buffer in this case.</p>
<p>You can generally set this to a value of approximately <code>2MB * number of Historicals</code>. As your cluster scales up with more Historicals and Tasks, consider increasing this buffer size and increasing the Broker heap accordingly.</p>
<ul>
<li>If the buffer is too small, this can lead to inefficient queries due to the buffer filling up rapidly and stalling the channel</li>
<li>If the buffer is too large, this puts more memory pressure on the Broker due to more queued result data in the HTTP channels.</li>
</ul>
<h4 id="number-of-brokers">Number of Brokers</h4>
<p>A 1:15 ratio of Brokers to Historicals is a reasonable starting point (this is not a hard rule).</p>
<p>If you need Broker HA, you can deploy 2 initially and then use the 1:15 ratio guideline for additional Brokers.</p>
<h4 id="total-memory-usage">Total Memory Usage</h4>
<p>To estimate total memory usage of the Broker under these guidelines:</p>
<ul>
<li>Heap: allocated heap size</li>
<li>Direct Memory: <code>(druid.processing.numThreads + druid.processing.numMergeBuffers + 1) * druid.processing.buffer.sizeBytes</code></li>
</ul>
<h3 id="middlemanager">MiddleManager</h3>
<p>The MiddleManager is a lightweight task controller/manager that launches Task processes, which perform ingestion work.</p>
<h4 id="middlemanager-heap-sizing">MiddleManager Heap Sizing</h4>
<p>The MiddleManager itself does not require much resources, you can set the heap to ~128MB generally.</p>
<h4 id="ssd-storage">SSD storage</h4>
<p>We recommend using SSDs for storage on the MiddleManagers, as the Tasks launched by MiddleManagers handle segment data stored on disk.</p>
<h4 id="task-count">Task Count</h4>
<p>The number of tasks a MiddleManager can launch is controlled by the <code>druid.worker.capacity</code> setting. </p>
<p>The number of workers needed in your cluster depends on how many concurrent ingestion tasks you need to run for your use cases. The number of workers that can be launched on a given machine depends on the size of resources allocated per worker and available system resources.</p>
<p>You can allocate more MiddleManager machines to your cluster to add task capacity.</p>
<h4 id="task-configurations">Task Configurations</h4>
<p>The following section below describes configuration for Tasks launched by the MiddleManager. The Tasks can be queried and perform ingestion workloads, so they require more resources than the MM.</p>
<h5 id="task-heap-sizing">Task Heap Sizing</h5>
<p>A 1GB heap is usually enough for Tasks.</p>
<h6 id="lookups">Lookups</h6>
<p>If you are using lookups, calculate the total size of the lookup maps being loaded. </p>
<p>Druid performs an atomic swap when updating lookup maps (both the old map and the new map will exist in heap during the swap), so the maximum potential heap usage from lookup maps will be (2 * total size of all loaded lookups).</p>
<p>Be sure to add <code>(2 * total size of all loaded lookups)</code> to your Task heap size if you are using lookups.</p>
<h5 id="task-processing-threads-and-buffers">Task processing threads and buffers</h5>
<p>For Tasks, 1 or 2 processing threads are often enough, as the Tasks tend to hold much less queryable data than Historical processes.</p>
<ul>
<li><code>druid.indexer.fork.property.druid.processing.numThreads</code>: set this to 1 or 2</li>
<li><code>druid.indexer.fork.property.druid.processing.numMergeBuffers</code>: set this to 2</li>
<li><code>druid.indexer.fork.property.druid.processing.buffer.sizeBytes</code>: can be set to 100MB</li>
</ul>
<h5 id="direct-memory-sizing">Direct Memory Sizing</h5>
<p>The processing and merge buffers described above are direct memory buffers.</p>
<p>When a Task processes a query, it must open a set of segments for reading. This also requires some direct memory space, described in <a href="#segment-decompression">segment decompression buffers</a>.</p>
<p>An ingestion Task also needs to merge partial ingestion results, which requires direct memory space, described in <a href="#segment-merging">segment merging</a>.</p>
<p>A formula for estimating direct memory usage follows:</p>
<p>(<code>druid.processing.numThreads</code> + <code>druid.processing.numMergeBuffers</code> + 1) * <code>druid.processing.buffer.sizeBytes</code></p>
<p>The <code>+ 1</code> factor is a fuzzy estimate meant to account for the segment decompression buffers and dictionary merging buffers.</p>
<h5 id="connection-pool-sizing">Connection Pool Sizing</h5>
<p>Please see the <a href="#general-connection-pool-guidelines">General Connection Pool Guidelines</a> section for an overview of connection pool configuration.</p>
<p>For Tasks, <code>druid.server.http.numThreads</code> should be set to a value slightly higher than the sum of <code>druid.broker.http.numConnections</code> across all the Brokers in the cluster.</p>
<p>Tuning the cluster so that each Task can accept 50 queries and 10 non-queries is a reasonable starting point.</p>
<h4 id="total-memory-usage">Total Memory Usage</h4>
<p>To estimate total memory usage of a Task under these guidelines:</p>
<ul>
<li>Heap: <code>1GB + (2 * total size of lookup maps)</code></li>
<li>Direct Memory: <code>(druid.processing.numThreads + druid.processing.numMergeBuffers + 1) * druid.processing.buffer.sizeBytes</code></li>
</ul>
<p>The total memory usage of the MiddleManager + Tasks:</p>
<p><code>MM heap size + druid.worker.capacity * (single task memory usage)</code></p>
<h5 id="configuration-guidelines-for-specific-ingestion-types">Configuration Guidelines for Specific Ingestion Types</h5>
<h6 id="kafka-kinesis-ingestion">Kafka/Kinesis Ingestion</h6>
<p>If you use the <a href="../development/extensions-core/kafka-ingestion.html">Kafka Indexing Service</a> or <a href="../development/extensions-core/kinesis-ingestion.html">Kinesis Indexing Service</a>, the number of tasks required will depend on the number of partitions and your taskCount/replica settings.</p>
<p>On top of those requirements, allocating more task slots in your cluster is a good idea, so that you have free task slots available for <a href="../ingestion/compaction.html">Compaction Tasks</a>.</p>
<h6 id="hadoop-ingestion">Hadoop Ingestion</h6>
<p>If you are only using <a href="../ingestion/hadoop.html">Hadoop Batch Ingestion</a> with no other ingestion types, you can lower the amount of resources allocated per Task. Batch ingestion tasks do not need to answer queries, and the bulk of the ingestion workload will be executed on the Hadoop cluster, so the Tasks do not require much resources.</p>
<h6 id="parallel-native-ingestion">Parallel Native Ingestion</h6>
<p>If you are using <a href="../ingestion/native_tasks.html">Parallel Native Ingestion</a>, allocating more available task slots is a good idea and will allow greater ingestion concurrency.</p>
<h2 id="coordinator">Coordinator</h2>
<p>The main performance-related setting on the Coordinator is the heap size.</p>
<p>The heap requirements of the Coordinator scale with the number of servers, segments, and tasks in the cluster.</p>
<p>You can set the Coordinator heap to the same size as your Broker heap, or slightly smaller: both services have to process cluster-wide state and answer API requests about this state.</p>
<h2 id="overlord">Overlord</h2>
<p>The main performance-related setting on the Overlord is the heap size.</p>
<p>The heap requirements of the Overlord scale primarily with the number of running Tasks.</p>
<p>The Overlord tends to require less resources than the Coordinator or Broker. You can generally set the Overlord heap to a value that&#39;s 25-50% of your Coordinator heap.</p>
<h2 id="router">Router</h2>
<p>The Router has light resource requirements, as it proxies requests to Brokers without performing much computational work itself.</p>
<p>You can assign it 256MB heap as a starting point, growing it if needed.</p>
<h1 id="general-guidelines-for-processing-threads-and-buffers">General Guidelines for Processing Threads and Buffers</h1>
<h2 id="processing-threads">Processing Threads</h2>
<p>The <code>druid.processing.numThreads</code> configuration controls the size of the processing thread pool used for computing query results. The size of this pool limits how many queries can be concurrently processed.</p>
<h2 id="processing-buffers">Processing Buffers</h2>
<p><code>druid.processing.buffer.sizeBytes</code> is a closely related property that controls the size of the off-heap buffers allocated to the processing threads. </p>
<p>One buffer is allocated for each processing thread. A size between 500MB and 1GB is a reasonable choice for general use.</p>
<p>The TopN and GroupBy queries use these buffers to store intermediate computed results. As the buffer size increases, more data can be processed in a single pass.</p>
<h2 id="groupby-merging-buffers">GroupBy Merging Buffers</h2>
<p>If you plan to issue GroupBy V2 queries, <code>druid.processing.numMergeBuffers</code> is an important configuration property. </p>
<p>GroupBy V2 queries use an additional pool of off-heap buffers for merging query results. These buffers have the same size as the processing buffers described above, set by the <code>druid.processing.buffer.sizeBytes</code> property.</p>
<p>Non-nested GroupBy V2 queries require 1 merge buffer per query, while a nested GroupBy V2 query requires 2 merge buffers (regardless of the depth of nesting). </p>
<p>The number of merge buffers determines the number of GroupBy V2 queries that can be processed concurrently.</p>
<h1 id="general-connection-pool-guidelines">General Connection Pool Guidelines</h1>
<p>Each Druid process has a configuration property for the number of HTTP connection handling threads, <code>druid.server.http.numThreads</code>.</p>
<p>The number of HTTP server threads limits how many concurrent HTTP API requests a given process can handle. </p>
<h2 id="sizing-the-connection-pool-for-queries">Sizing the connection pool for queries</h2>
<p>The Broker has a setting <code>druid.broker.http.numConnections</code> that controls how many outgoing connections it can make to a given Historical or Task process.</p>
<p>These connections are used to send queries to the Historicals or Tasks, with one connection per query; the value of <code>druid.broker.http.numConnections</code> is effectively a limit on the number of concurrent queries that a given broker can process.</p>
<p>Suppose we have a cluster with 3 Brokers and <code>druid.broker.http.numConnections</code> is set to 10.</p>
<p>This means that each Broker in the cluster will open up to 10 connections to each individual Historical or Task (for a total of 30 incoming query connections per Historical/Task).</p>
<p>On the Historical/Task side, this means that <code>druid.server.http.numThreads</code> must be set to a value at least as high as the sum of <code>druid.broker.http.numConnections</code> across all the Brokers in the cluster. </p>
<p>In practice, you will want to allocate additional server threads for non-query API requests such as status checks; adding 10 threads for those is a good general guideline. Using the example with 3 Brokers in the cluster and <code>druid.broker.http.numConnections</code> set to 10, a value of 40 would be appropriate for <code>druid.server.http.numThreads</code> on Historicals and Tasks.</p>
<p>As a starting point, allowing for 50 concurrent queries (requests that read segment data from datasources) + 10 non-query requests (other requests like status checks) on Historicals and Tasks is reasonable (i.e., set <code>druid.server.http.numThreads</code> to 60 there), while sizing <code>druid.broker.http.numConnections</code> based on the number of Brokers in the cluster to fit within the 50 query connection limit per Historical/Task.</p>
<ul>
<li>If the connection pool across Brokers and Historicals/Tasks is too small, the cluster will be underutilized as there are too few concurrent query slots.</li>
<li>If the connection pool is too large, you may get out-of-memory errors due to excessive concurrent load, and increased resource contention.</li>
<li>The connection pool sizing matters most when you require QoS-type guarantees and use query priorities; otherwise, these settings can be more loosely configured.</li>
<li>If your cluster usage patterns are heavily biased towards a high number of small concurrent queries (where each query takes less than ~15ms), enlarging the connection pool can be a good idea.</li>
<li>The 50/10 general guideline here is a rough starting point, since different queries impose different amounts of load on the system. To size the connection pool more exactly for your cluster, you would need to know the execution times for your queries and ensure that the rate of incoming queries does not exceed your &quot;drain&quot; rate.</li>
</ul>
<h1 id="garbage-collection-settings">Garbage Collection Settings</h1>
<p>We recommend using the G1GC garbage collector:</p>
<p><code>-XX:+UseG1GC</code></p>
<p>Enabling process termination on out-of-memory errors is useful as well, since the process generally will not recover from such a state, and it&#39;s better to restart the process:</p>
<p><code>-XX:+ExitOnOutOfMemoryError</code></p>
<h1 id="per-segment-direct-memory-buffers">Per-Segment Direct Memory Buffers</h1>
<h2 id="segment-decompression">Segment Decompression</h2>
<p>When opening a segment for reading during segment merging or query processing, Druid allocates a 64KB off-heap decompression buffer for each column being read.</p>
<p>Thus, there is additional direct memory overhead of (64KB * number of columns read per segment * number of segments read) when reading segments.</p>
<h2 id="segment-merging">Segment Merging</h2>
<p>In addition to the segment decompression overhead described above, when a set of segments are merged during ingestion, a direct buffer is allocated for every String typed column, for every segment in the set to be merged. </p>
<p>The size of these buffers are equal to the cardinality of the String column within its segment, times 4 bytes (the buffers store integers).</p>
<p>For example, if two segments are being merged, the first segment having a single String column with cardinality 1000, and the second segment having a String column with cardinality 500, the merge step would allocate (1000 + 500) * 4 = 6000 bytes of direct memory. </p>
<p>These buffers are used for merging the value dictionaries of the String column across segments. These &quot;dictionary merging buffers&quot; are independent of the &quot;merge buffers&quot; configured by <code>druid.processing.numMergeBuffers</code>.</p>
</div>
<div class="col-md-3">
<div class="searchbox">
<gcse:searchbox-only></gcse:searchbox-only>
</div>
<div id="toc" class="nav toc hidden-print">
</div>
</div>
</div>
</div>
<!-- Start page_footer include -->
<footer class="druid-footer">
<div class="container">
<div class="text-center">
<p>
<a href="/technology">Technology</a>&ensp;·&ensp;
<a href="/use-cases">Use Cases</a>&ensp;·&ensp;
<a href="/druid-powered">Powered by Druid</a>&ensp;·&ensp;
<a href="/docs/latest">Docs</a>&ensp;·&ensp;
<a href="/community/">Community</a>&ensp;·&ensp;
<a href="/downloads.html">Download</a>&ensp;·&ensp;
<a href="/faq">FAQ</a>
</p>
</div>
<div class="text-center">
<a title="Join the user group" href="https://groups.google.com/forum/#!forum/druid-user" target="_blank"><span class="fa fa-comments"></span></a>&ensp;·&ensp;
<a title="Follow Druid" href="https://twitter.com/druidio" target="_blank"><span class="fab fa-twitter"></span></a>&ensp;·&ensp;
<a title="GitHub" href="https://github.com/apache/druid" target="_blank"><span class="fab fa-github"></span></a>
</div>
<div class="text-center license">
Copyright © 2020 <a href="https://www.apache.org/" target="_blank">Apache Software Foundation</a>.<br>
Except where otherwise noted, licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.<br>
Apache Druid, Druid, and the Druid logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
</div>
</div>
</footer>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-131010415-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-131010415-1');
</script>
<script>
function trackDownload(type, url) {
ga('send', 'event', 'download', type, url);
}
</script>
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="/assets/js/druid.js"></script>
<!-- stop page_footer include -->
<script>
$(function() {
$(".toc").load("/docs/0.15.0-incubating/toc.html");
// There is no way to tell when .gsc-input will be async loaded into the page so just try to set a placeholder until it works
var tries = 0;
var timer = setInterval(function() {
tries++;
if (tries > 300) clearInterval(timer);
var searchInput = $('input.gsc-input');
if (searchInput.length) {
searchInput.attr('placeholder', 'Search');
clearInterval(timer);
}
}, 100);
});
</script>
</body>
</html>