blob: bf72580751f09762381094cae52f0ace32b3657d [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 | Coordinator Process</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.19.0/">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="coordinator-process">Coordinator Process</h1>
<h3 id="configuration">Configuration</h3>
<p>For Apache Druid (incubating) Coordinator Process Configuration, see <a href="../configuration/index.html#coordinator">Coordinator Configuration</a>.</p>
<h3 id="http-endpoints">HTTP endpoints</h3>
<p>For a list of API endpoints supported by the Coordinator, see <a href="../operations/api-reference.html#coordinator">Coordinator API</a>.</p>
<h3 id="overview">Overview</h3>
<p>The Druid Coordinator process is primarily responsible for segment management and distribution. More specifically, the Druid Coordinator process communicates to Historical processes to load or drop segments based on configurations. The Druid Coordinator is responsible for loading new segments, dropping outdated segments, managing segment replication, and balancing segment load.</p>
<p>The Druid Coordinator runs periodically and the time between each run is a configurable parameter. Each time the Druid Coordinator runs, it assesses the current state of the cluster before deciding on the appropriate actions to take. Similar to the Broker and Historical processses, the Druid Coordinator maintains a connection to a Zookeeper cluster for current cluster information. The Coordinator also maintains a connection to a database containing information about available segments and rules. Available segments are stored in a segment table and list all segments that should be loaded in the cluster. Rules are stored in a rule table and indicate how segments should be handled.</p>
<p>Before any unassigned segments are serviced by Historical processes, the available Historical processes for each tier are first sorted in terms of capacity, with least capacity servers having the highest priority. Unassigned segments are always assigned to the processes with least capacity to maintain a level of balance between processes. The Coordinator does not directly communicate with a historical process when assigning it a new segment; instead the Coordinator creates some temporary information about the new segment under load queue path of the historical process. Once this request is seen, the historical process will load the segment and begin servicing it.</p>
<h3 id="running">Running</h3>
<div class="highlight"><pre><code class="language-text" data-lang="text"><span></span>org.apache.druid.cli.Main server coordinator
</code></pre></div>
<h3 id="rules">Rules</h3>
<p>Segments can be automatically loaded and dropped from the cluster based on a set of rules. For more information on rules, see <a href="../operations/rule-configuration.html">Rule Configuration</a>.</p>
<h3 id="cleaning-up-segments">Cleaning Up Segments</h3>
<p>Each run, the Druid Coordinator compares the list of available database segments in the database with the current segments in the cluster. Segments that are not in the database but are still being served in the cluster are flagged and appended to a removal list. Segments that are overshadowed (their versions are too old and their data has been replaced by newer segments) are also dropped.
Note that if all segments in database are deleted(or marked unused), then Coordinator will not drop anything from the Historicals. This is done to prevent a race condition in which the Coordinator would drop all segments if it started running cleanup before it finished polling the database for available segments for the first time and believed that there were no segments.</p>
<h3 id="segment-availability">Segment Availability</h3>
<p>If a Historical process restarts or becomes unavailable for any reason, the Druid Coordinator will notice a process has gone missing and treat all segments served by that process as being dropped. Given a sufficient period of time, the segments may be reassigned to other Historical processes in the cluster. However, each segment that is dropped is not immediately forgotten. Instead, there is a transitional data structure that stores all dropped segments with an associated lifetime. The lifetime represents a period of time in which the Coordinator will not reassign a dropped segment. Hence, if a historical process becomes unavailable and available again within a short period of time, the historical process will start up and serve segments from its cache without any those segments being reassigned across the cluster.</p>
<h3 id="balancing-segment-load">Balancing Segment Load</h3>
<p>To ensure an even distribution of segments across Historical processes in the cluster, the Coordinator process will find the total size of all segments being served by every Historical process each time the Coordinator runs. For every Historical process tier in the cluster, the Coordinator process will determine the Historical process with the highest utilization and the Historical process with the lowest utilization. The percent difference in utilization between the two processes is computed, and if the result exceeds a certain threshold, a number of segments will be moved from the highest utilized process to the lowest utilized process. There is a configurable limit on the number of segments that can be moved from one process to another each time the Coordinator runs. Segments to be moved are selected at random and only moved if the resulting utilization calculation indicates the percentage difference between the highest and lowest servers has decreased.</p>
<h3 id="compacting-segments">Compacting Segments</h3>
<p>Each run, the Druid Coordinator compacts small segments abutting each other. This is useful when you have a lot of small
segments which may degrade query performance as well as increase disk space usage. See <a href="../operations/segment-optimization.html">Segment Size Optimization</a> for details.</p>
<p>The Coordinator first finds the segments to compact together based on the <a href="#segment-search-policy">segment search policy</a>.
Once some segments are found, it launches a <a href="../ingestion/tasks.html#compaction-task">compaction task</a> to compact those segments.
The maximum number of running compaction tasks is <code>min(sum of worker capacity * slotRatio, maxSlots)</code>.
Note that even though <code>min(sum of worker capacity * slotRatio, maxSlots)</code> = 0, at least one compaction task is always submitted
if the compaction is enabled for a dataSource.
See <a href="../operations/api-reference.html#compaction-configuration">Compaction Configuration API</a> and <a href="../configuration/index.html#compaction-dynamic-configuration">Compaction Configuration</a> to enable the compaction.</p>
<p>Compaction tasks might fail due to the following reasons.</p>
<ul>
<li>If the input segments of a compaction task are removed or overshadowed before it starts, that compaction task fails immediately.</li>
<li>If a task of a higher priority acquires a lock for an interval overlapping with the interval of a compaction task, the compaction task fails.</li>
</ul>
<p>Once a compaction task fails, the Coordinator simply finds the segments for the interval of the failed task again, and launches a new compaction task in the next run.</p>
<h3 id="segment-search-policy">Segment Search Policy</h3>
<h4 id="newest-segment-first-policy">Newest Segment First Policy</h4>
<p>At every coordinator run, this policy searches for segments to compact by iterating segments from the latest to the oldest.
Once it finds the latest segment among all dataSources, it checks if the segment is <em>compactible</em> with other segments of the same dataSource which have the same or abutting intervals.
Note that segments are compactible if their total size is smaller than or equal to the configured <code>inputSegmentSizeBytes</code>.</p>
<p>Here are some details with an example. Let us assume we have two dataSources (<code>foo</code>, <code>bar</code>)
and 5 segments (<code>foo_2017-10-01T00:00:00.000Z_2017-11-01T00:00:00.000Z_VERSION</code>, <code>foo_2017-11-01T00:00:00.000Z_2017-12-01T00:00:00.000Z_VERSION</code>, <code>bar_2017-08-01T00:00:00.000Z_2017-09-01T00:00:00.000Z_VERSION</code>, <code>bar_2017-09-01T00:00:00.000Z_2017-10-01T00:00:00.000Z_VERSION</code>, <code>bar_2017-10-01T00:00:00.000Z_2017-11-01T00:00:00.000Z_VERSION</code>).
When each segment has the same size of 10 MB and <code>inputSegmentSizeBytes</code> is 20 MB, this policy first returns two segments (<code>foo_2017-10-01T00:00:00.000Z_2017-11-01T00:00:00.000Z_VERSION</code> and <code>foo_2017-11-01T00:00:00.000Z_2017-12-01T00:00:00.000Z_VERSION</code>) to compact together because
<code>foo_2017-11-01T00:00:00.000Z_2017-12-01T00:00:00.000Z_VERSION</code> is the latest segment and <code>foo_2017-10-01T00:00:00.000Z_2017-11-01T00:00:00.000Z_VERSION</code> abuts to it.</p>
<p>If the coordinator has enough task slots for compaction, this policy would continue searching for the next segments and return
<code>bar_2017-10-01T00:00:00.000Z_2017-11-01T00:00:00.000Z_VERSION</code> and <code>bar_2017-09-01T00:00:00.000Z_2017-10-01T00:00:00.000Z_VERSION</code>.
Note that <code>bar_2017-08-01T00:00:00.000Z_2017-09-01T00:00:00.000Z_VERSION</code> is not compacted together even though it abuts to <code>bar_2017-09-01T00:00:00.000Z_2017-10-01T00:00:00.000Z_VERSION</code>.
This is because the total segment size to compact would be greater than <code>inputSegmentSizeBytes</code> if it&#39;s included.</p>
<p>The search start point can be changed by setting <a href="../configuration/index.html#compaction-dynamic-configuration">skipOffsetFromLatest</a>.
If this is set, this policy will ignore the segments falling into the interval of (the end time of the very latest segment - <code>skipOffsetFromLatest</code>).
This is to avoid conflicts between compaction tasks and realtime tasks.
Note that realtime tasks have a higher priority than compaction tasks by default. Realtime tasks will revoke the locks of compaction tasks if their intervals overlap, resulting in the termination of the compaction task.</p>
<div class="note caution">
This policy currently cannot handle the situation when there are a lot of small segments which have the same interval,
and their total size exceeds <a href="../configuration/index.html#compaction-dynamic-configuration">inputSegmentSizeBytes</a>.
If it finds such segments, it simply skips them.
</div>
<h3 id="the-coordinator-console">The Coordinator Console</h3>
<p>The Druid Coordinator exposes a web GUI for displaying cluster information and rule configuration. For more details, please see <a href="../operations/management-uis.html#coordinator-consoles">coordinator console</a>.</p>
<h3 id="faq">FAQ</h3>
<ol>
<li><p><strong>Do clients ever contact the Coordinator process?</strong></p>
<p>The Coordinator is not involved in a query.</p>
<p>Historical processes never directly contact the Coordinator process. The Druid Coordinator tells the Historical processes to load/drop data via Zookeeper, but the Historical processes are completely unaware of the Coordinator.</p>
<p>Brokers also never contact the Coordinator. Brokers base their understanding of the data topology on metadata exposed by the Historical processes via ZK and are completely unaware of the Coordinator.</p></li>
<li><p><strong>Does it matter if the Coordinator process starts up before or after other processes?</strong></p>
<p>No. If the Druid Coordinator is not started up, no new segments will be loaded in the cluster and outdated segments will not be dropped. However, the Coordinator process can be started up at any time, and after a configurable delay, will start running Coordinator tasks.</p>
<p>This also means that if you have a working cluster and all of your Coordinators die, the cluster will continue to function, it just won’t experience any changes to its data topology.</p></li>
</ol>
</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.14.1-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>