<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andrea Zanotti on Medium]]></title>
        <description><![CDATA[Stories by Andrea Zanotti on Medium]]></description>
        <link>https://medium.com/@andrea.zanotti15?source=rss-3e452c84f723------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*k9PGe7YS-BSR_DVu682tmA.jpeg</url>
            <title>Stories by Andrea Zanotti on Medium</title>
            <link>https://medium.com/@andrea.zanotti15?source=rss-3e452c84f723------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:28:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andrea.zanotti15/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What is Apache Druid?]]></title>
            <link>https://medium.com/data-reply-it-datatech/what-is-apache-druid-ad67bb8cd7f7?source=rss-3e452c84f723------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad67bb8cd7f7</guid>
            <category><![CDATA[apache-druid]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[timeseries]]></category>
            <dc:creator><![CDATA[Andrea Zanotti]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 09:16:45 GMT</pubDate>
            <atom:updated>2021-02-22T09:16:45.213Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article we will have a complete overview of the <strong>Apache Druid</strong> framework, starting from what a timeseries is, how we could handle this kind of data, and a description of its architecture. In the end, we will see how data is ingested and queried inside the platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ycVKlfLTH_cTd-jE" /></figure><h4>Timeseries: a definition</h4><blockquote>A <strong>time series</strong> is a sequence of data points ordered over time.</blockquote><p>These <em>discretized</em> points are usually stored and analyzed in order to make predictions or find behavioural patterns. In the common <strong>Big Data architectures</strong>, the standard approach is to gather data coming from all kinds of sources (user data, application data, web analytics, bi metrics, etc.), send all of them to an ETL stream processor and visualize the information in live dashboards.</p><p>In order to tailor the flow for a more analytic approach and to be able to respond <strong>quicker </strong>to timeseries queries, our architecture can be divided in two distinct pipelines:</p><ul><li>one dedicated only to <strong>user </strong>and <strong>application </strong>data, with the standard structure as described above;</li><li>another one that, for the rest of the gathered data, and after the ETL step, stores data into an <strong>analytic </strong>database before connecting it to the live dashboards.</li></ul><p>As our analytic database, we will need something that can ingest data in real-time, has low latency queries and has high uptime… could Apache Druid be a perfect fit?</p><h3>An introduction to Apache Druid</h3><p>Druid is a high performance analytics data store for event-driven data, written in Java, born in 2011 and moved to an Apache License in February 2015. It has a lot of features, the most remarkable being:</p><ul><li><strong>Scalability</strong>, thanks to a self-healing architecure</li><li>Typical &lt;1s to 4–5s query <strong>latency</strong></li><li><strong>Flexible </strong>table schemas over a columnar dataset</li><li>Time-based <strong>partitioning </strong>and <strong>querying</strong></li><li>Native <strong>JSON </strong>+ standard SQL querying</li><li>Fast data <strong>pre-aggregations</strong></li></ul><p>Data can be stored in Druid via two kinds of datasources: <strong>Batch </strong>(<em>Native, Hadoop, etc.</em>) and <strong>Streaming </strong>(<em>Kafka, Kinesis, Tranquility, etc.</em>). In both cases, data is stored in a way that is pretty equivalent to a table in a relational DB, using <strong>time partitioning </strong>during the ingestion, building chunks into <strong>partition segments</strong>.</p><p>After the ingestion, a segment becomes an immutable <strong>columnar compressed</strong> <strong>file</strong>. This immutable file is persisted in a <strong>deep storage</strong> (<em>e.g. S3 or HDFS</em>) and can be recovered even after failure of all Druid servers. Storage exploits maps and compressed bitmaps in order to reach high compression rates.</p><p>In Apache Druid, there are three types of columns:</p><ul><li><strong>Timestamp </strong>→ used for partitioning and sorting</li><li><strong>Dimension </strong>→ a field that can be queried via filters</li><li><strong>Metric </strong>→ an optional field, representing data aggregated from other fields (e.g the sum of characters in another field)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*fsNQIh1YKe5Lmf61YDLf4w.png" /><figcaption>Druid column types example</figcaption></figure><p>Queries can be sent to Druid in two different ways, without incurring in performance penalties: <strong>Native Druid JSON</strong> or <strong>DruidSQL</strong>. Druid is optimized for queries on a single fact data source and joins on a <strong>single</strong>, simple query-time lookup table <strong>only</strong>.</p><p>Further joins are not fully supported, and not optimal anyway in terms of query response time.</p><p>Let’s take a deeper look under the hood.</p><h3>Framework architecture</h3><p>The <strong>Druid </strong>architecture can be divided in three different layers:</p><ul><li><strong>Data servers</strong></li><li><strong>Master servers</strong></li><li><strong>Query servers</strong></li></ul><p>Each Druid layer is devoted to a very specific task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3TOC39qwyVtSVuefvU0Cw.png" /><figcaption>Apache Druid architecture</figcaption></figure><h4><strong>Data Server Layer</strong></h4><p>In this layer, data is <strong>ingested</strong>, <strong>stored </strong>and <strong>retrieved</strong>.</p><p>Data enter the framework through <strong>MiddleManagers</strong>, the component that handles ingestions by processing tasks and creating new <strong>Segments</strong>. They are responsible of how data is indexed, pre-aggregated, split into segments and published into <strong>Deep Storage</strong>.</p><p><strong>Deep Storage</strong> is responsible of persisting all data ingested and handling storage backups and availability between processes. This component is pluggable, so it’s the user who can choose the most suitable storage.</p><p>Other components that are part of this sub-category are <strong>Zookeeper</strong> (another Apache project used for internal service discovery, coordination, and leader election) and <strong>Metadata Storage</strong> (backed by relational DBs, like MySQL or PostgreSQL), containing all available metadata previously collected by all the components.</p><p>The last entities of this layer are <strong>Historicals: </strong>they are responsible for handling query processing by fetching segments from <strong>Deep Storage</strong> to the local disk and serving them when requested by queries. If no info is found in <strong>cache</strong>, metadata (location and compression) of new segment is retrieved from Zookeeper and the data is processed at that location. Historicals are <strong>triggered </strong>at every new segment entry in the ingestion data queue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*foAMaVE29O4K0OGd" /><figcaption>The capability to adapt to different scenarios is the very reason this tool has been named Druid</figcaption></figure><h4>Master Server Layer</h4><p>This layer manages data availability and ingestion using <strong>Overlords</strong>, components that balance data over MiddleManager processes, assigning ingestion tasks and coordinating segment availability.</p><p><strong>Coordinators</strong>, on the other hand, are components that balance data among Historical processes, notifying them when segments need to be loaded, dropping outdated segments and managing segment replication.</p><h4>Query Server Layer</h4><p>This layer is responsible for handling queries from external clients and providing the results. It uses components called <strong>Brokers</strong> that receive queries from clients, identify which Historical and MiddleManager nodes are serving those segments, split and rewrite the main query into subqueries and send everything to each one of these processes. At the very end, <strong>Brokers</strong> <strong>collect </strong>and <strong>merge the results</strong> to be provided to the <strong>client</strong>.</p><p>After introducing the architecture, we will see how the actual <strong>Druid tasks </strong>are performed.</p><h3>Ingestion flow</h3><p>The main phases that define the ingestion of data from our sources are two:</p><ul><li><strong>Indexing</strong></li><li><strong>Fetching</strong></li></ul><p>In the <strong>indexing </strong>phase, at first data are gathered from the sources (<strong><em>1</em></strong>), then they are indexed and pre-aggregated (<strong><em>2</em></strong>) in order to create new segments and published (<strong><em>3</em></strong>) into the Deep Storage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*4isVUMsiO52HhMqI8XymgQ.png" /><figcaption>Indexing phase (components and relations used in this phase are highlighted)</figcaption></figure><p>In the <strong>fetching </strong>phase, since <strong>Coordinators</strong> are listening to Metadata Storage periodically for newly published segments (<strong><em>4</em></strong>), when one of them finds a segment that is published and used but unavailable, it chooses a <strong>Historical </strong>process to load that segment in memory and instructs that Historical to do so (<strong><em>5</em></strong>). At the end, the Historical performs its task and begins serving the data(<em>6</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cwj-zlhJf3eDxI7SVGQ4vw.png" /><figcaption>Fetching phase (components and relations used in this phase are highlighted)</figcaption></figure><h3>Query flow</h3><p>What happens when a user submits a query to Druid?</p><p>The process is described below, in a single phase called <strong>querying phase</strong>.</p><p>It all starts when the client makes a request that is managed by <strong>Brokers </strong>(<em>7</em>), who will identify processes serving those corresponding segments (<em>8</em>). The query will be then splitted, rewritten and sent (<em>9</em>) to <strong>Historicals </strong>and <strong>MiddleManagers </strong>to be executed over the whole cluster(<em>10</em>).</p><p><strong>Historicals</strong> fetch the data from the deep storage. However, for real-time data, the query may be sent to the <strong>MiddleManagers </strong>as well<strong>: </strong>some data may not be available in <strong>DeepStorage</strong> yet, but existing only as segments still waiting to be written in the underlying file system.</p><p>At the end, results of the query are collected and merged together by <strong>Brokers </strong>and showed to the <strong>Client</strong> (<em>11</em>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCjnSRfTMW9TczznvLdnnw.png" /><figcaption>Querying phase (components and relations used in this phase are highlighted)</figcaption></figure><p>The key point is that the cost, in terms of time spent, at the ingestion phase in order to pre-aggregate and index data, <strong>is recovered back at query time.</strong> This lets users reach high speed results with average <strong>sub-second query response times</strong>.</p><h3>Conclusions</h3><p>In this article, we have analyzed:</p><ul><li>the main <strong>features </strong>of the Apache Druid framework</li><li>which <strong>components </strong>define its architecture, and their purpose</li><li>the main <strong>steps </strong>that define ingestion and query phases</li></ul><p>Apache Druid’s <strong>structure </strong>is not really lightweight, because of the amount of components involved. Still, this allows for a proper <strong>horizontal scaling</strong> of the architecture, simply by incrementing the number of the nodes (MiddleManagers, Historicals, etc.) Furthermore, it delivers <strong>high perfomances</strong> in terms of processing data, both in batch and real-time fashion.</p><p>Thanks to the <strong>open source</strong> code, the community that uses or develops on Druid is growing and it is possible, for example, to find or define connectors in order to include the framework in needing architectures.</p><p>The <strong>project </strong>has currently been used in production <a href="https://druid.apache.org/druid-powered">by many successful companies</a>, due to its good performance and the great variety of the use-cases it fits into.</p><h4>Do you want to test Apache Druid?</h4><p>Thanks to quickstart guides written directly by the developers, you can easily try it out <a href="https://druid.apache.org/docs/latest/tutorials/docker.html">on your laptop with Docker</a>, <a href="https://druid.apache.org/docs/latest/operations/single-server.html">on an actual machine</a>, or <a href="https://druid.apache.org/docs/latest/tutorials/cluster.html">on a cluster</a> (both on-premise and in the cloud!).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad67bb8cd7f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-reply-it-datatech/what-is-apache-druid-ad67bb8cd7f7">What is Apache Druid?</a> was originally published in <a href="https://medium.com/data-reply-it-datatech">Data Reply IT | DataTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>