<?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 Vinoth Chandar on Medium]]></title>
        <description><![CDATA[Stories by Vinoth Chandar on Medium]]></description>
        <link>https://medium.com/@bytearray?source=rss-7976a8959a9c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hfjsvA1O0EZbuuuR6cC0qw.jpeg</url>
            <title>Stories by Vinoth Chandar on Medium</title>
            <link>https://medium.com/@bytearray?source=rss-7976a8959a9c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 14:32:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bytearray/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[Doing range gets on cloud storage for fun and profit]]></title>
            <link>https://bytearray.io/doing-range-gets-on-cloud-storage-for-fun-and-profit-cfe5a4a4e2e3?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfe5a4a4e2e3</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-storage]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Tue, 28 Nov 2023 18:20:12 GMT</pubDate>
            <atom:updated>2023-11-28T18:20:12.714Z</atom:updated>
            <content:encoded><![CDATA[<h3>The thing that stands between good and great cloud read performance</h3><p>Much of the world uses at-least one <a href="https://www.techtarget.com/searchstorage/definition/cloud-storage">cloud storage</a> system, for storing objects that represent anything from metadata, database backups to massive data lakes. A lot has been written about cloud storage and they are different from traditional distributed file systems (DFS), in terms of metadata operations and such.</p><p>In this blog, I will share another common thing that trips users up IRL — the actual reading/writing of data. Understanding that actual read/write path involves RPC calls made to a remote micro-service, than an optimized streaming binary protocol (like typical DFS) is key to designing systems on top. Specifically, we will shed light on the underutilized power of range-gets, which allows smart, efficient reading of cloud objects, while also saving a ton of $$.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*tZz6r20NW3BIY341.jpeg" /></figure><h3>Understanding the request path</h3><p>Most cloud storage clients (I traced the java clients on the largest cloud storage systems) talk to a http 1.1 endpoint, by first checking out a cached connection from a connection pool and issues a blocking GET call to retrieve the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MsAreoTbl0wndKCL.png" /><figcaption>GET execution against cloud storage</figcaption></figure><p>This was surprising and disappointing for a few reasons:</p><ul><li>connection pools have limits; If there are no free connections in the pool and the limit is maxed-out, threads need to just block. This is commonly referred to as <a href="https://en.wikipedia.org/wiki/Head-of-line_blocking">head of line blocking</a></li><li>Since connections are mapped to requests 1:1, clients need to spawn more threads to increase throughput.</li><li>Clients need to strike a fine balance of having enough connections/threads to increase parallelism, but not so high that you hitting cloud storage <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/optimizing-performance.html">throttling limits</a>, where requests are slowed down by cloud storage beyond certain limits (for e.g 5500 GET/sec on Amazon S3).</li></ul><p>A way to put a positive spin on the networking stack would be to look at them as <a href="https://medium.com/@jayphelps/backpressure-explained-the-flow-of-data-through-software-2350b3e77ce7">backpressure</a> so the client application does not end up hitting cloud storage too hard and suffer from throttling issues. But, if we were honest, these design choices are simply pretty dated.</p><h3>Why range-gets are important</h3><p>So, what can we do as a user? We have one powerful tool in our hands : the range get request, which allows the client application to request only a portion of the object instead of the whole object content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t5ADilNKFO8Lg9ZW.png" /><figcaption>Figure showing how range gets are executed against an object in cloud storage</figcaption></figure><p>This has the following advantages:</p><ol><li>The obvious benefit of much reduced network transfer from cloud storage to the client application, along with reduced resource requirements (e.g: smaller network buffers)</li><li>The requests and the responses are much shorter, which means way more requests can be satisfied given the same connection pool and thread pool sizes.</li><li>All of this in turn, ultimately reduces the total compute time needed for the task performed by each thread and saves significantly on your cloud compute bills.</li></ol><p>For e.g: columnar file formats like parquet/orc store data by columns such that a query processing only a few columns can use range reads to selectively read out only those columns, instead of downloading the entire file. This is a fundamental operation done on data lakes across hundreds of thousands of companies out there.</p><h3>But…</h3><p>There are still the same caveats around striking balances even with using range-gets.</p><ol><li>Most cloud storage systems have costs associated with RPC calls made to read/write objects. So, even though range gets read way less, and shrink compute time, making too many range gets can offset your compute/network cost savings if you are not careful.</li><li>By employing range-gets, we split a single full GET call into several range-get calls, eating up the per-second cloud storage throttling limits faster. Admittedly, this is workload dependent (e.g N range GETs against N objects is vastly better than N range-gets against N objects)</li></ol><p>So, where does this balance lie? Let’s explore that. Below we assume the GET call has few ms of latency (typically ~17ms or so on s3) and we can make multiple of them in parallel. Then we try to understand how to decide between <em>doing a full read, that could take up to 1 second of compute</em> <strong>(OR)</strong> <em>issuing multiple range-get calls to get the processing done sooner</em>. We compute the per-second compute cost and per-call RPC costs across the major public cloud storage providers.</p><h3>Cost of Range Gets vs Bulk Gets on S3</h3><p>Per second cost of idle compute (<a href="https://aws.amazon.com/ec2/pricing/on-demand/">m6g.medium</a>) : $0.0385/hr ➝ $0.000011/second</p><p>Per second cost of 1 GET call to S3 (<a href="https://aws.amazon.com/s3/pricing/">s3.standard</a>) : $0.0004/1000 calls = $0.0000004/call</p><p>Making a GET call is <strong>27.5x</strong> cheaper than waiting for 1 second!</p><h3>Cost of Range Gets vs Bulk Gets on GCS</h3><p>Per second cost of idle compute (<a href="https://cloud.google.com/compute/vm-instance-pricing#general-purpose_machine_type_family">c3-standard-4</a>) : $0.235144/4 VCPUs/16GB RAM/hr ➝ $0.0588/hr ➝ $0.000016/second</p><p>Per second cost of 1 GET call to GCS (<a href="https://cloud.google.com/storage/pricing#operations-pricing">gcs </a>standard storage) : $0.0004/1000 calls = $0.0000004/call</p><p>Making a GET call is <strong>40x</strong> cheaper than waiting for 1 second!</p><h3>Cost of Range Gets vs Bulk Gets on Azure</h3><p>Per second cost of idle compute (<a href="https://azure.microsoft.com/en-us/pricing/details/virtual-machines/linux/#pricing">b2ms</a>) : $60.7360/2 cores/8 GB RAM/month ➝ $0.0421/hr ➝ $0.000011/core/second</p><p>Per second cost of 1 Extra GET call to ADLSV2 (<a href="https://azure.microsoft.com/en-us/pricing/details/storage/data-lake/">adlsv2</a> <a href="https://azure.microsoft.com/en-us/pricing/details/storage/data-lake/">hot</a>) : $0.0052/4MB or 10000 calls = $0.00000052/call</p><p>Making a GET call is <strong>21.1x</strong> cheaper than waiting for 1 second!</p><p>The general theme is: if you accomplish the task, by doing ~20 range gets instead of a full GET, you could employ them save a good amount of compute costs.</p><h3>How can this be better?</h3><p>This is all still too complex!! Thankfully, there are some simple and well-understood upgrades that can be made to cloud storage endpoints, that fix all of this and probably unlock completely new use-cases (e.g <a href="https://www.onehouse.ai/blog/introducing-multi-modal-index-for-the-lakehouse-in-apache-hudi">indexing on data lakes</a>) for all of us.</p><p>These have been on my holiday gift wish list for over 3 years now.</p><ol><li><strong>http/2 support</strong> : The microservices world has long moved over to <a href="https://en.wikipedia.org/wiki/HTTP/2">http/2</a> (we even dabbled with <a href="https://www.uber.com/blog/employing-quic-protocol/">http/3</a>, before it became http/3), which has request-multiplexing that can eliminate the head-of-line blocking issues. It also comes with great support for request prioritization that can be useful to prioritize some queries over others.</li><li><strong>multiple byte ranges per GET call</strong>: The HTTP RFC already supports <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests">returning multiple byte ranges</a> back from the server. Cloud storage systems implementing support for this will greatly reduce latency as the protocol is now truly streaming. Also, fewer number of calls needed to fetch same amount of data (reducing costs as well) and also keeps even high throughput GETs safe from hitting throttling limits.</li><li><strong>Hide throttling limits or fixes from users</strong>: Most cloud storage systems have implemented some kind of elastic scaling internally, to handle a lot of requests to the same object paths or prefixes. However, users still employ techniques like randomly hashing paths etc at the client application to “spread” their objects more uniformly across cloud storage. IMHO, these sort of fixes should be internally handled by cloud storage systems, if its deemed acceptable for the users to employ them.</li></ol><p>The resulting state would look something like below, where we can treat cloud storage more or less like a remote block storage device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RHfOtrAs6ozcLdKP.png" /><figcaption>http/2 enabled cloud storage communication with multiple byte ranges, request multiplexing</figcaption></figure><p>My educated guess is this is also fantastic for cloud storage providers themselves, in terms of reducing the egress traffic, fewer load balancers, fewer connections, fewer intermediate buffers … — ultimately lower cost-to-serve the same workloads. Let’s hope this happens at-least in 2024!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfe5a4a4e2e3" width="1" height="1" alt=""><hr><p><a href="https://bytearray.io/doing-range-gets-on-cloud-storage-for-fun-and-profit-cfe5a4a4e2e3">Doing range gets on cloud storage for fun and profit</a> was originally published in <a href="https://bytearray.io/">bytearray</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Corrections in data lakehouse table format comparisons]]></title>
            <link>https://bytearray.io/corrections-in-data-lakehouse-table-format-comparisons-b72eb63ece32?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b72eb63ece32</guid>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-lakehouse]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Wed, 20 Apr 2022 04:19:26 GMT</pubDate>
            <atom:updated>2022-06-29T15:20:57.970Z</atom:updated>
            <content:encoded><![CDATA[<p>A live document to serve as a point of reference for corrections for inaccuracies for different comparative studies of Hudi, Delta Lake, or Iceberg.</p><p>System comparisons are hard to write. I have put out a <a href="https://www.confluent.io/blog/kafka-fastest-messaging-system/#:~:text=Throughput%3A%20Kafka%20provides%20the%20highest,and%202x%20faster%20than%20Pulsar.">bakeoff or two</a> myself and get how deep/complex/nuanced they can get. So, it&#39;s quite understandable that when folks put out comparisons some inaccuracies can creep in by mistake. We are not going to delve into the important aspects, that some of these comparisons miss and change their essence. But, simply make a best effort to keep the stories straight and remove subjectivity, much like old school newspaper <a href="https://en.wikipedia.org/wiki/Correction_(newspaper)">corrections</a>, and keep things factual.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*UmfrtaPEEU8rKVDb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/1*ZCjyVToQO65waFy1cflLiQ.png" /><figcaption>Food for thought: When people say “Eventually, one of these table formats will become the industry standard.” — Remember that all three projects have co-existed for 4–5 years now. Think of the <a href="https://en.wikipedia.org/wiki/Lindy_effect">Lindy effect</a> — the “phenomenon by which the future <a href="https://en.wikipedia.org/wiki/Mediocrity_principle#Longevity_Estimation">life expectancy</a> of some non-perishable things, like a technology or an idea, is proportional to their current age”</figcaption></figure><h3>Subsurface blog from Dremio</h3><p>Link: <a href="https://www.dremio.com/subsurface/comparison-of-data-lake-table-formats-iceberg-hudi-and-delta-lake/">https://www.dremio.com/subsurface/comparison-of-data-lake-table-formats-iceberg-hudi-and-delta-lake/</a></p><ol><li>Blog does not even mention Hudi or Databricks Delta (paid version)’s change capture/incremental query capabilities. “I” in Hudi stands for “incrementals” and its a <a href="https://www.datacouncil.ai/talks/powering-ubers-global-network-analytics-pipelines-in-near-real-time-with-hudi-delta-streamer-ethan-guo-yihua">game-changer</a> for batch data pipelines</li><li><strong>Engine read compatibility for Hudi</strong>: Misses <a href="https://aws.amazon.com/about-aws/whats-new/2020/09/amazon-redshift-spectrum-adds-support-for-querying-open-source-apache-hudi-and-delta-lake/">Redshift Spectrum</a>. For Hudi, it misses good’ol <a href="https://impala.apache.org/docs/build/html/topics/impala_hudi.html">Impala</a>. Hudi 0.11 release has support for <a href="https://github.com/apache/hudi/pull/4503">BigQuery external tables</a> with built-in syncing support.</li><li><strong>Engine read compatibility for Delta:</strong> Misses Redshift Spectrum</li><li><strong>Engine read compatibility for Iceberg (+Hudi):</strong> While Databricks SQL syntax is tied to Delta Lake, Databricks Spark does work on both Iceberg &amp; Hudi.</li><li><strong>Engine Write Compatibility for Iceberg (+Hudi):</strong> Both Iceberg + Hudi support a Java writer interface. In Hudi’s case, this is used to build the Kafka Connect support. Databricks Spark should be able to write Hudi and Iceberg as well.</li><li><strong>File Format Support for Hudi </strong>: Hudi has <a href="https://hudi.apache.org/docs/0.10.0/configurations/#hoodieorcstripesize">ORC support</a> (Hive/Spark as of 0.10.1) and also supports Avro data format (not .avro files) through the Merge-on-read storage type</li><li><strong>Delete Support in Hudi via SQL :</strong> “But for <a href="https://cwiki.apache.org/confluence/display/HUDI/2020/01/15/Delete+support+in+Hudi">Deletes</a> you’ll have to rely on the engine’s (Spark/Flink) API” — right out of <a href="https://hudi.apache.org/docs/quick-start-guide#deletes">Hudi Quickstart for 0.10.1</a> you can use SQL to delete in Hudi.</li><li><strong>Hidden Partitioning/Partition Evolution in Hudi/Delta Lake</strong>: The article uses very iceberg-specific terminology. But Databricks Delta (non-OSS version) supports <a href="https://docs.databricks.com/delta/delta-batch.html#deltausegeneratedcolumns">generated columns</a>, that can achieve similar effects as hidden partitioning. Hudi 0.11, has data skipping via a column_stats index, that can do similar support for select built-in spark udfs.</li><li><strong>Hidden Partitioning/Partition Evolution in Hudi/Delta Lake</strong>: As of 0.11, Hudi added support for full (or backward-incompatible) schema evolution for <a href="https://github.com/apache/hudi/pull/4910">Spark</a>.</li><li><strong>Read/Write section under Tale of Two Sparks:</strong> For Snowflake &amp; Iceberg Read &amp; Write? External tables are <a href="https://twitter.com/rahulj51/status/1485063568416333824?s=20&amp;t=ERKepdoMaybJzTwq0UhUJQ">read-only</a>.</li></ol><p><strong>History:</strong></p><ul><li>[April 19, 2022] Initial corrections.</li><li>[June 28, 2022] Some corrections from here has been applied to the original blog post.</li></ul><h3>Data Lake Formats Interests and Adoption Rate</h3><p>Link: <a href="https://garystafford.medium.com/data-lake-table-formats-interest-and-adoption-rate-40817b87be9e">https://garystafford.medium.com/data-lake-table-formats-interest-and-adoption-rate-40817b87be9e</a></p><ol><li>Missed Redshift Spectrum for both Hudi and Delta Lake.</li><li>Hudi’s issue statistics discount the ASF JIRA, where all developer issues are tracked. Github is merely used for community support (flip side: shows how much OSS Community support Hudi contributors are doing)</li></ol><p><strong>History:</strong></p><ul><li>[Feb 12, 2022] Initial corrections suggested to author.</li><li>[Feb 12, 2022] Corrections have been made on the blog.</li></ul><h3>Oracle’s DeltaLake vs Hudi on OCI Comparison</h3><p>Link: <a href="https://blogs.oracle.com/developers/post/deltalake-vs-hudi-on-oracle-cloud-infrastructure-part-1">https://blogs.oracle.com/developers/post/deltalake-vs-hudi-on-oracle-cloud-infrastructure-part-1</a></p><p><a href="https://blogs.oracle.com/developers/post/deltalake-vs-hudi-on-oracle-cloud-infrastructure-part-2">https://blogs.oracle.com/developers/post/deltalake-vs-hudi-on-oracle-cloud-infrastructure-part-2</a></p><ol><li>Hudi writes were done with GZip (higher CPU cost for higher compression), while Delta Lake uses Snappy (speed of compression). Test also does not attribute/turn-off extra file size to meta fields written out by Hudi.</li><li>Hudi writes use the defaultupsert operation, which incurs additional costs of memory caching, and index lookups, probably explaining why the writes OOM at the higher end. bulk_insert is the documented, recommended way for loading data.</li><li>Blog claims the insert operation in Hudi leads to duplicates, while completely ignoring Delta Lake does not provide any such guarantees (as of June 29,2022) to begin with.</li><li>The blog claims Hudi has “true streaming”, while Delta Lake does “micro batching”. This is a characteristic of the engine (Spark) and both do the same micro-batching, in fact.</li><li>For append-only workloads, even Hudi’s MOR table type writes out parquet files, which explains the performance being the same as COW in the test.</li><li>Benchmark size is 100MB-1GB, which brings into question how the results apply broadly.</li></ol><p><strong>History:</strong></p><ul><li>[May 21, 2022] Initial corrections suggested to <a href="https://twitter.com/byte_array/status/1392872906997198850?s=20&amp;t=5jZHkSJuKuUQKLtdd1PATQ">author</a>, benchmarks have not been re-run since.</li></ul><h3>A thorough comparison of delta lake, iceberg, and hudi</h3><p>Link: <a href="https://databricks.com/session_na20/a-thorough-comparison-of-delta-lake-iceberg-and-hudi">https://databricks.com/session_na20/a-thorough-comparison-of-delta-lake-iceberg-and-hudi</a></p><ol><li>Hudi fully supports deletes, it’s even in the name “hu<strong>D</strong>i”, examples are in the quickstart. Similar basic misses on pySpark support.</li><li>Hudi has Flink support already, at the time of writing. Engine pluggability should be YES</li><li>Hudi log format is fully open and documented. so “Yes (data) + No (log)” is untrue.</li><li>Hudi and Delta Lake both support filter push downs, just not through separate metadata at the time of writing. for e.g Spark queries would read parquet metadata (if not delta/hudi table metadata like today) to perform this.</li><li>Due to author’s association with Iceberg, unsupported featured are marked “Ongoing” for iceberg, while its marked “no” for Hudi/Delta</li></ol><p><strong>History:</strong></p><ul><li>[Dec 2, 2020] Corrections posted on <a href="https://twitter.com/byte_array/status/1334183245068398592">twitter</a> due to a report from Hudi user.</li><li>[Sep 8 2021] Author responded to the <a href="https://twitter.com/huzijin1/status/1435570333889622016?s=20&amp;t=5jZHkSJuKuUQKLtdd1PATQ">thread</a>, offering to correct. But it’s an already delivered conference talk.</li></ul><h3>Up Next</h3><ul><li><a href="https://lakefs.io/hudi-iceberg-and-delta-lake-data-lake-table-formats-compared/">https://lakefs.io/hudi-iceberg-and-delta-lake-data-lake-table-formats-compared/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b72eb63ece32" width="1" height="1" alt=""><hr><p><a href="https://bytearray.io/corrections-in-data-lakehouse-table-format-comparisons-b72eb63ece32">Corrections in data lakehouse table format comparisons</a> was originally published in <a href="https://bytearray.io/">bytearray</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reliable ingestion from AWS S3 using Hudi]]></title>
            <link>https://medium.com/apache-hudi-blogs/reliable-ingestion-from-aws-s3-using-hudi-b7d5590c78a9?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b7d5590c78a9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[apache-hudi]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Thu, 02 Sep 2021 15:10:08 GMT</pubDate>
            <atom:updated>2021-09-02T15:10:08.783Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post we will talk about a new deltastreamer source which reliably and efficiently processes new data files as they arrive in AWS S3</p><blockquote>This is a repost of the original Hudi blog <a href="https://hudi.apache.org/blog/2021/08/23/s3-events-source/">here</a>.</blockquote><p>As of today, to ingest data from S3 into Hudi, users leverage DFS source whose <a href="https://github.com/apache/hudi/blob/178767948e906f673d6d4a357c65c11bc574f619/hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/helpers/DFSPathSelector.java">path selector</a> would identify the source files modified since the last checkpoint based on max modification time. The problem with this approach is that modification time precision is upto seconds in S3. It maybe possible that there were many files (beyond what the configurable source limit allows) modifed in that second and some files might be skipped. For more details, please refer to <a href="https://issues.apache.org/jira/browse/HUDI-1723">HUDI-1723</a>. While the workaround is to ignore the source limit and keep reading, the problem motivated us to redesign so that users can reliably ingest from S3.</p><h3>Design</h3><p>For use-cases where seconds granularity does not suffice, we have a new source in deltastreamer using log-based approach. The new <a href="https://github.com/apache/hudi/blob/178767948e906f673d6d4a357c65c11bc574f619/hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/S3EventsSource.java">S3 events source</a> relies on change notification and incremental processing to ingest from S3. The architecture is as shown in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/0*kEYB2o6CuKx2tcWj.png" /></figure><p>In this approach, users need to <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html">enable S3 event notifications</a>. There will be two types of deltastreamers as detailed below.</p><ol><li><a href="https://github.com/apache/hudi/blob/178767948e906f673d6d4a357c65c11bc574f619/hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/S3EventsSource.java">S3EventsSource</a>: Create Hudi S3 metadata table. This source leverages AWS <a href="https://aws.amazon.com/sns">SNS</a> and <a href="https://aws.amazon.com/sqs/">SQS</a> services that subscribe to file events from the source bucket.</li></ol><ul><li>Events from SQS will be written to this table, which serves as a changelog for the subsequent incremental puller.</li><li>When the events are committed to the S3 metadata table they will be deleted from SQS.</li></ul><p><a href="https://github.com/apache/hudi/blob/178767948e906f673d6d4a357c65c11bc574f619/hudi-utilities/src/main/java/org/apache/hudi/utilities/sources/S3EventsHoodieIncrSource.java">2. S3EventsHoodieIncrSource</a> and uses the metadata table written by S3EventsSource.</p><ul><li>Read the S3 metadata table and get the objects that were added or modified. These objects contain the S3 path for the source files that were added or modified.</li><li>Write to Hudi table with source data corresponding to the source files in the S3 bucket.</li></ul><h3>Advantages</h3><ul><li><strong>Decoupling</strong>: Every step in the pipeline is decoupled. The two sources can be started independent of each other. We imagine most users run a single deltastreamer to get all changes for a given bucket and can fan-out multiple tables off that.</li><li><strong>Performance and Scale</strong>: The previous approach used to list all files, sort by modification time and then filter based on checkpoint. While it did prune partition paths, the directory listing could still become a bottleneck. By relying on change notification and native cloud APIs, the new approach avoids directory listing and scales with the number of files being ingested.</li><li><strong>Reliability</strong>: Since there is no longer any dependency on the max modification time and the fact that S3 events are being recorded in the metadata table, users can rest assured that all the events will be processed eventually.</li><li><strong>Fault Tolerance:</strong> There are two levels of fault toerance in this design. Firstly, if some of the messages are not committed to the S3 metadata table, then those messages will remain in the queue so that they can be reprocessed in the next round. Secondly, if the incremental puller fails, then users can query the S3 metadata table for the last commit point and resume the incremental puller from that point onwards (kinda like how Kafka consumers can reset offset).</li><li><strong>Asynchronous backfills:</strong> With the log-based approach, it becomes much easier to trigger backfills. See the “Conclusion and Future Work” section for more details.</li></ul><h3>Configuration and Setup</h3><p>Users only need to specify the SQS queue url and region name to start the S3EventsSource (metadata source).</p><pre>hoodie.deltastreamer.s3.source.queue.url=https://sqs.us-west-2.amazonaws.com/queue/url<br>hoodie.deltastreamer.s3.source.queue.region=us-west-2</pre><p>There are a few other configurations for the metadata source which can be tuned to suit specific requirements:</p><ul><li><em>hoodie.deltastreamer.s3.source.queue.long.poll.wait</em>: Value can range in [0, 20] seconds. If set to 0 then metadata source will consume messages from SQS using short polling. It is recommended to use long polling because it will reduce false empty responses and reduce the cost of using SQS. By default, this value is set to 20 seconds.</li><li><em>hoodie.deltastreamer.s3.source.queue.visibility.timeout</em>: Value can range in [0, 43200] seconds (i.e. max 12 hours). SQS does not automatically delete the messages once consumed. It is the responsibility of metadata source to delete the message after committing. SQS will move the consumed message to in-flight state during which it becomes invisible for the configured timeout period. By default, this value is set to 30 seconds.</li><li><em>hoodie.deltastreamer.s3.source.queue.max.messages.per.batch</em>: Maximum number of messages in a batch of one round of metadata source run. By default, this value is set to 5.</li></ul><p>To setup the pipeline, first <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/NotificationHowTo.html">enable S3 event notifications</a>. Download the <a href="https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-sqs">aws-java-sdk-sqs</a> jar. Then start the S3EventsSource and S3EventsHoodieIncrSource using the HoodieDeltaStreamer utility as shown in sample commands below.</p><pre># To start S3EventsSource<br>spark-submit \<br>--jars &quot;/home/hadoop/hudi-utilities-bundle_2.11-0.9.0.jar,/usr/lib/spark/external/lib/spark-avro.jar,/home/hadoop/aws-java-sdk-sqs-1.12.22.jar&quot; \<br>--master yarn --deploy-mode client \<br>--class org.apache.hudi.utilities.deltastreamer.HoodieDeltaStreamer /home/hadoop/hudi-packages/hudi-utilities-bundle_2.11-0.9.0-SNAPSHOT.jar \<br>--table-type COPY_ON_WRITE --source-ordering-field eventTime \<br>--target-base-path s3://bucket_name/path/for/s3_meta_table \<br>--target-table s3_meta_table  --continuous \<br>--min-sync-interval-seconds 10 \<br>--hoodie-conf hoodie.datasource.write.recordkey.field=&quot;s3.object.key,eventName&quot; \<br>--hoodie-conf hoodie.datasource.write.keygenerator.class=org.apache.hudi.keygen.ComplexKeyGenerator \<br>--hoodie-conf hoodie.datasource.write.partitionpath.field=s3.bucket.name --enable-hive-sync \<br>--hoodie-conf hoodie.datasource.hive_sync.partition_extractor_class=org.apache.hudi.hive.MultiPartKeysValueExtractor \<br>--hoodie-conf hoodie.datasource.write.hive_style_partitioning=true \<br>--hoodie-conf hoodie.datasource.hive_sync.database=default \<br>--hoodie-conf hoodie.datasource.hive_sync.table=s3_meta_table \<br>--hoodie-conf hoodie.datasource.hive_sync.partition_fields=bucket \<br>--source-class org.apache.hudi.utilities.sources.S3EventsSource \<br>--hoodie-conf hoodie.deltastreamer.source.queue.url=<a href="https://sqs.us-west-2.amazonaws.com/queue/url">https://sqs.us-west-2.amazonaws.com/queue/url</a><br>--hoodie-conf hoodie.deltastreamer.s3.source.queue.region=us-west-2</pre><pre># To start S3EventsHoodieIncrSource<br>spark-submit \<br>--jars &quot;/home/hadoop/hudi-utilities-bundle_2.11-0.9.0.jar,/usr/lib/spark/external/lib/spark-avro.jar,/home/hadoop/aws-java-sdk-sqs-1.12.22.jar&quot; \<br>--master yarn --deploy-mode client \<br>--class org.apache.hudi.utilities.deltastreamer.HoodieDeltaStreamer /home/hadoop/hudi-packages/hudi-utilities-bundle_2.11-0.9.0-SNAPSHOT.jar \<br>--table-type COPY_ON_WRITE \<br>--source-ordering-field eventTime --target-base-path s3://bucket_name/path/for/s3_hudi_table \<br>--target-table s3_hudi_table  --continuous --min-sync-interval-seconds 10 \<br>--hoodie-conf hoodie.datasource.write.recordkey.field=&quot;pull_request_id&quot; \<br>--hoodie-conf hoodie.datasource.write.keygenerator.class=org.apache.hudi.keygen.SimpleKeyGenerator \<br>--hoodie-conf hoodie.datasource.write.partitionpath.field=s3.bucket.name --enable-hive-sync \<br>--hoodie-conf hoodie.datasource.hive_sync.partition_extractor_class=org.apache.hudi.hive.MultiPartKeysValueExtractor \<br>--hoodie-conf hoodie.datasource.write.hive_style_partitioning=true \<br>--hoodie-conf hoodie.datasource.hive_sync.database=default \<br>--hoodie-conf hoodie.datasource.hive_sync.table=s3_hudi_v6 \<br>--hoodie-conf hoodie.datasource.hive_sync.partition_fields=bucket \<br>--source-class org.apache.hudi.utilities.sources.S3EventsHoodieIncrSource \<br>--hoodie-conf hoodie.deltastreamer.source.hoodieincr.path=s3://bucket_name/path/for/s3_meta_table \<br>--hoodie-conf hoodie.deltastreamer.source.hoodieincr.read_latest_on_missing_ckpt=true</pre><h3>Conclusion and Future Work</h3><ul><li>One stream of work is to add support for other cloud-based object storage like Google Cloud Storage, Azure Blob Storage, etc. with this revamped design.</li><li>Another stream of work is to add resource manager that allows users to setup notifications and delete resources when no longer needed.</li><li>Another interesting piece of work is to support asynchronous backfills. Notification systems are evntually consistent and typically do not guarantee perfect delivery of all files right away. The log-based approach provides enough flexibility to trigger automatic backfills at a configurable interval e.g. once a day or once a week.</li></ul><p>Please follow this <a href="https://issues.apache.org/jira/browse/HUDI-1896">JIRA</a> to learn more about active development on this issue. We look forward to contributions from the community. Hope you enjoyed this post.</p><p>Put your Hudi on and keep streaming!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b7d5590c78a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-hudi-blogs/reliable-ingestion-from-aws-s3-using-hudi-b7d5590c78a9">Reliable ingestion from AWS S3 using Hudi</a> was originally published in <a href="https://medium.com/apache-hudi-blogs">apache-hudi-blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hudi — The Streaming Data Lake Platform]]></title>
            <link>https://medium.com/apache-hudi-blogs/apache-hudi-the-streaming-data-lake-platform-5964468678a4?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5964468678a4</guid>
            <category><![CDATA[apache-hudi]]></category>
            <category><![CDATA[stream-processing]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 15:41:17 GMT</pubDate>
            <atom:updated>2021-08-06T14:38:18.560Z</atom:updated>
            <content:encoded><![CDATA[<h3>Apache Hudi — The Streaming Data Lake Platform</h3><blockquote>This blog is a repost of the original blog <a href="https://hudi.apache.org/blog/2021/07/21/streaming-data-lake-platform">here</a></blockquote><p>As early as 2016, we set out a <a href="https://www.oreilly.com/content/ubers-case-for-incremental-processing-on-hadoop/">bold, new vision</a> reimagining batch data processing through a new “<strong>incremental</strong>” data processing stack — alongside the existing batch and streaming stacks. While a stream processing pipeline does row-oriented processing, delivering a few seconds of processing latency, an incremental pipeline would apply the same principles to <em>columnar</em> data in the data lake, delivering orders of magnitude improvements in processing efficiency within few minutes, on extremely scalable batch storage/compute infrastructure. This new stack would be able to effortlessly support regular batch processing for bulk reprocessing/backfilling as well. Hudi was built as the manifestation of this vision, rooted in real, hard problems faced at <a href="https://eng.uber.com/uber-big-data-platform/">Uber</a> and later took a life of its own in the open source community. Together, we have been able to usher in fully incremental data ingestion and moderately complex ETLs on data lakes already.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jhooS2MCbjBZ09H7.png" /></figure><p>Today, this grand vision of being able to express almost any batch pipeline incrementally is more attainable than it ever was. Stream processing is <a href="https://flink.apache.org/blog/">maturing rapidly</a> and gaining <a href="https://www.confluent.io/blog/every-company-is-becoming-software/">tremendous momentum</a>, with <a href="https://flink.apache.org/2021/03/11/batch-execution-mode.html">generalization</a> of stream processing APIs to work over a batch execution model. Hudi completes the missing pieces of the puzzle by providing streaming optimized lake storage, much like how Kafka/Pulsar enable efficient storage for event streaming. <a href="https://hudi.apache.org/docs/powered_by.html">Many organizations</a> have already reaped real benefits of adopting a streaming model for their data lakes, in terms of fresh data, simplified architecture and great cost reductions.</p><p>But first, we needed to tackle the basics — transactions and mutability — on the data lake. In many ways, Apache Hudi pioneered the transactional data lake movement as we know it today. Specifically, during a time when more special-purpose systems were being born, Hudi introduced a server-less, transaction layer, which worked over the general-purpose Hadoop FileSystem abstraction on Cloud Stores/HDFS. This model helped Hudi to scale writers/readers to 1000s of cores on day one, compared to warehouses which offer a richer set of transactional guarantees but are often bottlenecked by the 10s of servers that need to handle them. We also experience a lot of joy to see similar systems (Delta Lake for e.g) later adopt the same server-less transaction layer model that we originally shared way back in <a href="https://eng.uber.com/hoodie/">early </a>’17. We consciously introduced two table types Copy On Write (with simpler operability) and Merge On Read (for greater flexibility) and now these terms are used in <a href="https://github.com/apache/iceberg/pull/1862">projects</a> outside Hudi, to refer to similar ideas being borrowed from Hudi. Through open sourcing and <a href="https://blogs.apache.org/foundation/entry/the-apache-software-foundation-announces64">graduating</a> from the Apache Incubator, we have made some great progress elevating these ideas <a href="http://hudi.apache.org/docs/powered_by.html">across the industry</a>, as well as bringing them to life with a cohesive software stack. Given the exciting developments in the past year or so that have propelled data lakes further mainstream, we thought some perspective can help users see Hudi with the right lens, appreciate what it stands for, and be a part of where it’s headed. At this time, we also wanted to shine some light on all the great work done by <a href="https://github.com/apache/hudi/graphs/contributors">180+ contributors</a> on the project, working with more than 2000 unique users over slack/github/jira, contributing all the different capabilities Hudi has gained over the past years, from its humble beginnings.</p><p>This is going to be a rather long post, but we will do our best to make it worth your time. Let’s roll.</p><h3>Data Lake Platform</h3><p>We have noticed that, Hudi is sometimes positioned as a “<a href="https://cloud.google.com/blog/products/data-analytics/getting-started-with-new-table-formats-on-dataproc">table format</a>” or “transactional layer”. While this is not incorrect, this does not do full justice to all that Hudi has to offer.</p><h3>Is Hudi a “format”?</h3><p>Hudi was not designed as a general purpose table format, tracking files/folders for batch processing. Rather, the functionality provided by a table format is merely one layer in the Hudi software stack. Hudi was designed to play well with the Hive format (if you will), given how popular and widespread it is. Over time, to solve scaling challenges or bring in additional functionality, we have invested in our own native table format with an eye for incremental processing vision. for e.g, we need to support shorter transactions that commit every few seconds. We believe these requirements would fully subsume challenges solved by general purpose table formats over time. But, we are also open to plugging in or syncing to other open table formats, so their users can also benefit from the rest of the Hudi stack. Unlike the file formats, a table format is merely a representation of table metadata and it’s actually quite possible to translate from Hudi to other formats/vice versa if users are willing to accept the trade-offs.</p><h3>Is Hudi a transactional layer?</h3><p>Of course, Hudi had to provide transactions for implementing deletes/updates, but Hudi’s transactional layer is designed around an <a href="https://engineering.linkedin.com/distributed-systems/log-what-every-software-engineer-should-know-about-real-time-datas-unifying">event log</a> that is also well-integrated with an entire set of built-in table/data services. For e.g compaction is aware of clustering actions already scheduled and optimizes by skipping over the files being clustered — while the user is blissfully unaware of all this. Hudi also provides out-of-box tools for ingesting, ETLing data, and much more. We have always been thinking of Hudi as solving a database problem around stream processing — areas that are actually <a href="https://www.infoq.com/presentations/streaming-databases/">very related to each other</a>. In fact, Stream processing is enabled by logs (capture/emit event streams, rewind/reprocess) and databases (state stores, updatable sinks). With Hudi, the idea was that if we build a database supporting efficient updates and extracting data streams while remaining optimized for large batch queries, incremental pipelines can be built using Hudi tables as state store &amp; update-able sinks.</p><p>Thus, the best way to describe Apache Hudi is as a <strong>Streaming Data Lake Platform</strong> built around a <em>database kernel</em>. The words carry significant meaning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s1jqs8XrpaAU2fRI.png" /></figure><p><strong>Streaming</strong>: At its core, by optimizing for fast upserts &amp; change streams, Hudi provides the primitives to data lake workloads that are comparable to what <a href="https://kafka.apache.org/">Apache Kafka</a> does for event-streaming (namely, incremental produce/consume of events and a state-store for interactive querying).</p><p><strong>Data Lake</strong>: Nonetheless, Hudi provides an optimized, self-managing data plane for large scale data processing on the lake (adhoc queries, ML pipelines, batch pipelines), powering arguably the <a href="https://eng.uber.com/apache-hudi-graduation/">largest transactional lake</a> in the world. While Hudi can be used to build a <a href="https://databricks.com/blog/2020/01/30/what-is-a-data-lakehouse.html">lakehouse</a>, given its transactional capabilities, Hudi goes beyond and unlocks an end-to-end streaming architecture. In contrast, the word “streaming” appears just 3 times in the lakehouse <a href="http://cidrdb.org/cidr2021/papers/cidr2021_paper17.pdf">paper</a>, and one of them is talking about Hudi.</p><p><strong>Platform</strong>: Oftentimes in open source, there is great tech, but there is just too many of them — all differing ever so slightly in their opinionated ways, ultimately making the integration task onerous on the end user. Lake users deserve the same great usability that cloud warehouses provide, with the additional freedom and transparency of a true open source community. Hudi’s data and table services, tightly integrated with the Hudi “kernel”, gives us the ability to deliver cross layer optimizations with reliability and ease of use.</p><h3>Hudi Stack</h3><p>The following stack captures layers of software components that make up Hudi, with each layer depending on and drawing strength from the layer below. Typically, data lake users write data out once using an open file format like Apache <a href="http://parquet.apache.org/">Parquet</a>/<a href="https://orc.apache.org/">ORC</a> stored on top of extremely scalable cloud storage or distributed file systems. Hudi provides a self-managing data plane to ingest, transform and manage this data, in a way that unlocks incremental data processing on them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cED2arxdaU9s8bIC.png" /></figure><p>Furthermore, Hudi either already provides or plans to add components that make this data universally accessible to all the different query engines out there. The features annotated with * represent work in progress and dotted boxes represent planned future work, to complete our vision for the project. While we have strawman designs outlined for the newer components in the blog, we welcome with open arms fresh perspectives from the community. Rest of the blog will delve into each layer in our stack - explaining what it does, how it’s designed for incremental processing and how it will evolve in the future.</p><h3>Lake Storage</h3><p>Hudi interacts with lake storage using the <a href="https://hadoop.apache.org/docs/stable/api/org/apache/hadoop/fs/FileSystem.html">Hadoop FileSystem API</a>, which makes it compatible with all of its implementations ranging from HDFS to Cloud Stores to even in-memory filesystems like <a href="https://www.alluxio.io/blog/building-high-performance-data-lake-using-apache-hudi-and-alluxio-at-t3go/">Alluxio</a>/Ignite. Hudi internally implements its own <a href="https://github.com/apache/hudi/blob/9d2a65a6a6ff9add81411147f1cddd03f7c08e6c/hudi-common/src/main/java/org/apache/hudi/common/fs/HoodieWrapperFileSystem.java">wrapper filesystem</a> on top to provide additional storage optimizations (e.g: file sizing), performance optimizations (e.g: buffering), and metrics. Uniquely, Hudi takes full advantage of append support, for storage schemes that support it, like HDFS. This helps Hudi deliver streaming writes without causing an explosion in file counts/table metadata. Unfortunately, most cloud/object storages do not offer append capability today (except maybe <a href="https://azure.microsoft.com/en-us/updates/append-blob-support-in-azure-data-lake-storage-is-now-generally-available/">Azure</a>). In the future, we plan to leverage the lower-level APIs of major cloud object stores, to provide similar controls over file counts at streaming ingest latencies.</p><h3>File Format</h3><p>Hudi is designed around the notion of base file and delta log files that store updates/deltas to a given base file (called a file slice). Their formats are pluggable, with Parquet (columnar access) and HFile (indexed access) being the supported base file formats today. The delta logs encode data in <a href="http://avro.apache.org/">Avro</a> (row oriented) format for speedier logging (just like Kafka topics for e.g). Going forward, we plan to <a href="https://github.com/apache/hudi/pull/3228">inline any base file format</a> into log blocks in the coming releases, providing columnar access to delta logs depending on block sizes. Future plans also include Orc base/log file formats, unstructured data formats (free form json, images), and even tiered storage layers in event-streaming systems/OLAP engines/warehouses, work with their native file formats.</p><p>Zooming one level up, Hudi’s unique file layout scheme encodes all changes to a given base file, as a sequence of blocks (data blocks, delete blocks, rollback blocks) that are merged in order to derive newer base files. In essence, this makes up a self contained redo log that the lets us implement interesting features on top. For e.g, most of today’s data privacy enforcement happens by masking data read off the lake storage on-the-fly, invoking hashing/encryption algorithms over and over on the same set of records and incurring significant compute overhead/cost. Users would be able to keep multiple pre-masked/encrypted copies of the same key in the logs and hand out the correct one based on a policy, avoiding all the overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p8F5BUnc8jVuQtTr.png" /></figure><h3>Table Format</h3><p>The term “table format” is new and still means many things to many people. Drawing an analogy to file formats, a table format simply consists of : the file layout of the table, table’s schema and metadata tracking changes to the table. Hudi is not a table format, it implements one internally. Hudi uses Avro schemas to store, manage and evolve a table’s schema. Currently, Hudi enforces schema-on-write, which although stricter than schema-on-read, is adopted <a href="https://docs.confluent.io/platform/current/schema-registry/avro.html">widely</a> in the stream processing world to ensure pipelines don’t break from non backwards compatible changes.</p><p>Hudi consciously lays out files within a table/partition into groups and maintains a mapping between an incoming record’s key to an existing file group. All updates are recorded into delta log files specific to a given file group and this design ensures low merge overhead compared to approaches like Hive ACID, which have to merge all delta records against all base files to satisfy queries. For e.g, with uuid keys (used very widely) all base files are very likely to overlap with all delta logs, rendering any range based pruning useless. Much like state stores, Hudi’s design anticipates fast key based upserts/deletes and only requires merging delta logs within each file group. This design choice also lets Hudi provide more capabilities for writing/querying as we will explain below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tHCOunFUL6zj60AE.png" /></figure><p>The <em>timeline</em> is the source-of-truth event log for all Hudi’s table metadata, stored under the .hoodie folder, that provides an ordered log of all actions performed on the table. Events are retained on the timeline up to a configured interval of time/activity. Each file group is also designed as it’s own self-contained log, which means that even if an action that affected a file group is archived from the timeline, the right state of the records in each file group can be reconstructed by simply locally applying the delta logs to the base file. This design bounds the metadata size, proportional to how often the table is being written to/operated on, independent of how large the entire table is. This is a critical design element needs for supporting frequent writes/commits to tables.</p><p>Lastly, new events on the timeline are then consumed and reflected onto an internal metadata table, implemented as another merge-on-read table offering low write amplification. Hudi is able to absorb quick/rapid changes to table’s metadata, unlike table formats designed for slow-moving data. Additionally, the metadata table uses the <a href="https://hbase.apache.org/2.0/devapidocs/org/apache/hadoop/hbase/io/hfile/HFile.html">HFile</a> base file format, which provides indexed lookups of keys avoiding the need for reading the entire metadata table to satisfy metadata reads. It currently stores all the physical file paths that are part of the table, to avoid expensive cloud file listings.</p><p>A key challenge faced by all the table formats out there today, is the need for expiring snapshots/controlling retention for time travel queries such that it does not interfere with query planning/performance. In the future, we plan to build an indexed timeline in Hudi, which can span the entire history of the table, supporting a time travel look back window of several months/years.</p><h3>Indexes</h3><p>Indexes help databases plan better queries, that reduce the overall amount of I/O and deliver faster response times. Table metadata about file listings and column statistics are often enough for lake query engines to generate optimized, engine specific query plans quickly. This is however not sufficient for Hudi to realize fast upserts. Hudi already supports different key based indexing schemes to quickly map incoming record keys into the file group they reside in. For this purpose, Hudi exposes a pluggable indexing layer to the writer implementations, with built-in support for range pruning (when keys are ordered and largely arrive in order) using interval trees and bloom filters (e.g: for uuid based keys where ordering is of very little help). Hudi also implements a HBase backed external index which is much more performant although more expensive to operate. Hudi also consciously exploits the partitioning scheme of the table to implement global and non-global indexing schemes. Users can choose to enforce key constraints only within a partition, in return for <em>O(num_affected_partitions)</em> upsert performance as opposed to <em>O(total_partitions)</em> in the global indexing scenarios. We refer you to this <a href="http://hudi.apache.org/blog/hudi-indexing-mechanisms/">blog</a>, that goes over indexing in detail. Ultimately, Hudi’s writer path ensures the index is always kept in sync with the timeline and data, which is cumbersome and error prone to implement on top of a table format by hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PCv-DBIG6LgDVzOE.png" /></figure><p>In the future, we intend to add additional forms of indexing as new partitions on the metadata table. Let’s discuss the role each one has to play briefly. Query engines typically rely on partitioning to cut down the number of files read for a given query. In database terms, a Hive partition is nothing but a coarse range index, that maps a set of columns to a list of files. Table formats born in the cloud like Iceberg/Delta Lake, have built-in tracking of column ranges per file in a single flat file (json/avro), that helps avoid planning costs for large/poorly sized tables. This need has been largely reduced for Hudi tables thus far, given Hudi automatically enforces file sizes which help bound time taken to read out stats from parquet footers for e.g. However, with the advent of features like clustering, there is a need for writing smaller files first and then reclustering in a query optimized way. We plan to add indexed column ranges, that can scale to lots of small files and support faster mutations . See <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC-27+Data+skipping+index+to+improve+query+performance">RFC-27</a> to track the design process and get involved.</p><p>While Hudi already supports external indexes for random write workloads, we would like to support <a href="https://github.com/apache/hudi/pull/2487">point-lookup-ish queries</a> right on top of lake storage, which helps avoid the overhead of an additional database for many classes of data applications. We also anticipate that uuid/key based joins will be sped up a lot, by leveraging record level indexing schemes, we build out for fast upsert performance. We also plan to move our tracking of bloom filters out of the file footers and into its <a href="https://issues.apache.org/jira/browse/HUDI-1295">own partition</a> on the metadata table. Ultimately, we look to exposing all of this to the queries as well in the coming releases.</p><h3>Concurrency Control</h3><p>Concurrency control defines how different writers/readers coordinate access to the table. Hudi ensures atomic writes, by way of publishing commits atomically to the timeline, stamped with an instant time that denotes the time at which the action is deemed to have occurred. Unlike general purpose file version control, Hudi draws clear distinction between writer processes (that issue user’s upserts/deletes), table services (that write data/metadata to optimize/perform bookkeeping) and readers (that execute queries and read data). Hudi provides snapshot isolation between all three types of processes, meaning they all operate on a consistent snapshot of the table. Hudi provides <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+22+%3A+Snapshot+Isolation+using+Optimistic+Concurrency+Control+for+multi-writers">optimistic concurrency control</a> (OCC) between writers, while providing lock-free, non-blocking MVCC based concurrency control between writers and table-services and between different table services.</p><p>Projects that solely rely on OCC deal with competing operations, by either implementing a lock or relying on atomic renames. Such approaches are optimistic that real contention never happens and resort to failing one of the writer operations if conflicts occur, which can cause significant resource wastage or operational overhead. Imagine a scenario of two writer processes : an ingest writer job producing new data every 30 minutes and a deletion writer job that is enforcing GDPR taking 2 hours to issue deletes. If there were to overlap on the same files (very likely to happen in real situations with random deletes), the deletion job is almost guaranteed to starve and fail to commit each time, wasting tons of cluster resources. Hudi takes a very different approach that we believe is more apt for lake transactions, which are typically long-running. For e.g async compaction that can keep deleting records in the background without blocking the ingest job. This is implemented via a file level, log based concurrency control protocol which orders actions based on their start instant times on the timeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gA4DaF-4anHMpYth.png" /></figure><p>We are hard at work, improving our OCC based implementation around early detection of conflicts for concurrent writers and terminate early without burning up CPU resources. We are also working on <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+22+%3A+Snapshot+Isolation+using+Optimistic+Concurrency+Control+for+multi-writers#RFC22:SnapshotIsolationusingOptimisticConcurrencyControlformultiwriters-FutureWork(LockFree-ishConcurrencyControl)">adding fully log based</a>, non-blocking concurrency control between writers, where writers proceed to write deltas and conflicts are resolved later in some deterministic timeline order — again much like how stream processing programs are written. This is possible only due to Hudi’s unique design that sequences actions into an ordered event log and the transaction handling code is aware of the relationship/interdependence of actions to each other.</p><h3>Writers</h3><p>Hudi tables can be used as sinks for Spark/Flink pipelines and the Hudi writing path provides several enhanced capabilities over file writing done by vanilla parquet/avro sinks. Hudi classifies write operations carefully into incremental (insert, upsert, delete) and batch/bulk operations (insert_overwrite, insert_overwrite_table, delete_partition, bulk_insert) and provides relevant functionality for each operation in a performant and cohesive way. Both upsert and delete operations automatically handle merging of records with the same key in the input stream (say, a CDC stream obtained from upstream table) and then lookup the index, finally invoke a bin packing algorithm to pack data into files, while <a href="http://hudi.apache.org/blog/hudi-file-sizing/">respecting a pre-configured target file size</a>. An insert operation on the other hand, is intelligent enough to avoid the precombining and index lookup, while retaining the benefits of the rest of the pipeline. Similarly, bulk_insert operation provides several sort modes for controlling initial file sizes and file counts, when importing data from an external table to Hudi. The other batch write operations provide MVCC based implementations of typical overwrite semantics used in batch data pipelines, while retaining all the transactional and incremental processing capabilities, making it seamless to switch between incremental pipelines for regular runs and batch pipelines for backfilling/dropping older partitions. The write pipeline also contains lower layers optimizations around handling large merges by spilling to <a href="https://rocksdb.org/">rocksDB</a> or an external spillable map, multi-threaded/concurrent I/O to improve write performance.</p><p>Keys are first class citizens inside Hudi and the pre-combining/index lookups done before upsert/deletes ensure a key is unique across partitions or within partitions, as desired. In contrast with other approaches where this is left to data engineer to co-ordinate using MERGE INTO statements, this approach ensures quality data especially for critical use-cases. Hudi also ships with several <a href="http://hudi.apache.org/blog/hudi-key-generators/">built-in key generators</a> that can parse all common date/timestamps, handle malformed data with an extensible framework for defining custom key generators. Keys are also materialized with the records using the _hoodie_record_key meta column, which makes it possible to change the key fields and perform repairs on older data with incorrect keys for e.g. Finally, Hudi provides a HoodieRecordPayload interface is very similar to processor APIs in Flink or Kafka Streams, and allows for expressing arbitrary merge conditions, between the base and delta log records. This allows users to express partial merges (e.g log only updated columns to the delta log for efficiency) and avoid reading all the base records before every merge. Routinely, we find users leverage such custom merge logic during replaying/backfilling older data onto a table, while ensuring newer updates are not overwritten causing the table’s snapshot to go back in time. This is achieved by simply using the HoodieDefaultPayload where latest value for a given key is picked based a configured precombine field value in the data.</p><p>Hudi writers add metadata to each record, that codify the commit time and a sequence number for each record within that commit (comparable to a Kafka offset), which make it possible to derive record level change streams. Hudi also provides users the ability to specify event time fields in incoming data streams and track them in the timeline.Mapping these to stream processing concepts, Hudi contains both <a href="https://www.oreilly.com/radar/the-world-beyond-batch-streaming-101/">arrival and event time</a> for records for each commit, that can help us build good <a href="https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/datastream/event-time/generating_watermarks/">watermarks</a> that inform complex incremental processing pipelines. In the near future, we are looking to add new metadata columns, that encode the source operation (insert, update, delete) for each record, before we embark on this grand goal of full end-end incremental ETL pipelines. All said, we realized many users may simply want to use Hudi as an efficient write layer that supports transactions, fast updates/deletes. We are looking into adding support for <a href="https://github.com/apache/hudi/pull/3306">virtual keys</a> and making the <a href="https://github.com/apache/hudi/pull/3247">meta columns optional</a>, to lower storage overhead, while still making rest of Hudi’s capabilities (metadata table, table services, ..) available.</p><h3>Readers</h3><p>Hudi provides snapshot isolation between writers and readers and allows for any table snapshot to be queries consistently from all major lake query engines (Spark, Hive, Flink, Presto, Trino, Impala) and even cloud warehouses like Redshift. In fact, we would love to bring Hudi tables as external tables with BigQuery/Snowflake as well, once they also embrace the lake table formats more natively. Our design philosophy around query performance has been to make Hudi as lightweight as possible whenever only base columnar files are read (CoW snapshot, MOR read-optimized queries), employing the engine specific vectorized readers in Presto, Trino, Spark for e.g to be employed. This model is far more scalable than maintaining our own readers and users to benefit from engine specific optimizations. For e.g <a href="https://prestodb.io/blog/2021/02/04/raptorx">Presto</a>, <a href="https://trino.io/docs/current/connector/hive-caching.html">Trino</a> all have their own data/metadata caches. Whenever, Hudi has to merge base and log files for a query, Hudi takes control and employs several mechanisms (spillable maps, lazy reading) to improve merge performance, while also providing a read-optimized query on the data that trades off data freshness for query performance. In the near future, we are investing deeply into improving MoR snapshot query performance in many ways such as inlining parquet data, special handling of overwrite payloads/merges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PsrDxYCuhiupzZQB.png" /></figure><p>True to its design goals, Hudi provides some very powerful incremental querying capabilities that tied together the meta fields added during writing and the file group based storage layout. While table formats that merely track files, are only able to provide information about files that changed during each snapshot or commits, Hudi generates the exact set of records that changed given a point in the timeline, due to tracking of record level event and arrival times. Further more, this design allows large commits to be consumed in smaller chunks by an incremental query, fully decoupling the writing and incremental querying of data. Time travel is merely implemented as an incremental query that starts and stops at an older portion of the timeline. Since Hudi ensures that a key is atomically mapped to a single file group at any point in time, it makes it possible to support full CDC capabilities on Hudi tables, such as providing all possible values for a given record since time t, CDC streams with both before and after images. All of these functionalities can be built local to each file group, given each file group is a self-contained log. Much of our future work in this area will be around bringing such a powerful set of <a href="https://debezium.io/">debezium</a> like capabilities to life in the coming months.</p><h3>Table Services</h3><p>What defines and sustains a project’s value over years are its fundamental design principles and the subtle trade offs. Databases often consist of several internal components, working in tandem to deliver efficiency, performance and great operability to its users. True to intent to act as state store for incremental data pipelines, we designed Hudi with built-in table services and self-managing runtime that can orchestrate/trigger these services to optimize everything internally. In fact, if we compare rocksDB (a very popular stream processing state-store) and Hudi’s components, the similarities become obvious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y9Wqeq7vaR28Aa5r.png" /></figure><p>There are several built-in table services, all with the goal of ensuring performant table storage layout and metadata management, which are automatically invoked either synchronously after each write operation, or asynchronously as a separate background job. Furthermore, Spark (and Flink) streaming writers can run in continuous mode, and invoke table services asynchronously sharing the underlying executors intelligently with writers. Archival service ensures that the timeline holds sufficient history for inter service co-ordination (e.g compactions wait for other compactions to complete on the same file group), incremental queries. Once events expire from the timeline, the archival service cleans up any side-effects from lake storage (e.g. rolling back of failing concurrent transactions). Hudi’s transaction management implementation allows all of these services to be idempotent and thus resilient to failure via just simple retries. <a href="http://hudi.apache.org/blog/employing-right-configurations-for-hudi-cleaner/">Cleaner</a> service works off the timeline incrementally (eating our own incremental design dog food), removing file slices that are past the configured retention period for incremental queries, while also allowing sufficient time for long running batch jobs (e.g Hive ETLs) to finish running. Compaction service comes with built-in strategies (date partitioning based, I/O bounded), that merges a base file with a set of delta log files to produce new base file, all while allowing writes to happen concurrently to the file group. This is only possible due to Hudi’s grouping of files into groups and support for flexible log merging, and unlocks non-blocking execution of deletes while concurrent updates are being issues to the same set of records. <a href="http://hudi.apache.org/blog/hudi-clustering-intro/">Clustering</a> service functions similar to what users find in BigQuery or Snowflake, where users can group records that are often queried together by sort keys or control file sizes by coalescing smaller base files into larger ones. Clustering is fully aware of other actions on the timeline such as cleaning, compaction, and it helps Hudi implement intelligent optimizations like avoiding compaction on file groups that are already being clustered, to save on I/O. Hudi also performs rollback of partial writes and cleans up any uncommitted data from lake storage, by use of marker files that track any files created as a part of write operations. Finally, the bootstrap service performs one time zero copy migration of plain parquet tables to Hudi, while allowing both pipelines to operate in parallel, for data validation purposes. Cleaner service is once again aware of these bootstrapped base files and can optionally clean them up, to ensure use-cases like GDPR compliance are met.</p><p>We are always looking for ways to improve and enhance our table services in meaningful ways. In the coming releases, we are working towards a much more <a href="https://github.com/apache/hudi/pull/3233">scalable model</a> of cleaning up partial writes, by consolidating marker file creation using our timeline metaserver, which avoids expensive full table scans to seek out and remove uncommitted files. We also have <a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=181307144">various proposals</a> to add more clustering schemes, unlock clustering with concurrent updates using fully log based concurrency control.</p><h3>Data Services</h3><p>As noted at the start, we wanted to make Hudi immediately usable for common end-end use-cases and thus invested deeply into a set of data services, that provide functionality that is data/workload specific, sitting on top of the table services, writers/readers directly. Foremost in that list, is the Hudi DeltaStreamer utility, which has been an extremely popular choice for painlessly building a data lake out of Kafka streams and files landing in different formats on top of lake storage. Over time, we have also built out sources that cover all major systems like a JDBC source for RDBMS/other warehouses, Hive source and even incrementally pulling data from other Hudi tables. The utility supports automatic checkpoint management tracking source checkpoints as a part of target Hudi table metadata, with support for backfills/one-off runs. DeltaStreamer also integrates with major schema registries such as Confluent’s and also provides checkpoint translation from other popular mechanisms like Kafka connect. It also supports de-duplication of data, multi-level configuration management system, built in transformers that take arbitrary SQL or coerce <a href="http://hudi.apache.org/blog/hudi-meets-aws-emr-and-aws-dms/">CDC log changes</a> into writable forms, that combined with other aforementioned features can be used for deploying production grade incremental pipelines. Finally, just like the Spark/Flink streaming writers, DeltaStreamer is able to run in a continuous mode, with automatic management of table services. Hudi also provides several other tools for snapshotting and incrementally exporting Hudi tables, also importing/<a href="http://hudi.apache.org/blog/exporting-hudi-datasets/">exporting</a>/bootstrapping new tables into Hudi. Hudi also provides commit notifications into Http endpoints or Kafka topics, about table commit activity, which can be used for analytics or building data sensors in workflow managers like Airflow to trigger pipelines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nJxbFmLpDnoOcok8.png" /></figure><p>Going forward, we would love contributions to enhance our <a href="http://hudi.apache.org/blog/ingest-multiple-tables-using-hudi/">multi delta streamer utility</a>, which can ingest entire Kafka clusters in a single large Spark application, to be on par and hardened. To further our progress towards end-end complex incremental pipelines, we plan to work towards enhancing the delta streamer utility and its SQL transformers to be triggered by multiple source streams (as opposed to just the one today) and unlock materialized views at scale. We would like to bring an array of useful transformers that perform masking or data monitoring, and extend support for egress of data off Hudi tables into other external sinks as well. Finally, we would love to merge the FlinkStreamer and the DeltaStreamer utilities into one cohesive utility, that can be used across engines. We are constantly improving existing sources (e.g support for parallelized listings of DFS sources) and adding new ones (e.g S3 event based DFS source)</p><h3>Timeline Metaserver</h3><p>Storing and serving table metadata right on the lake storage is scalable, but can be much less performant compared to RPCs against a scalable meta server. Most cloud warehouses internally are built on a metadata layer that leverages an external database (e.g <a href="https://www.snowflake.com/blog/how-foundationdb-powers-snowflake-metadata-forward/">Snowflake uses foundationDB</a>). Hudi also provides a metadata server, called the “Timeline server”, which offers an alternative backing store for Hudi’s table metadata. Currently, the timeline server runs embedded in the Hudi writer processes, serving file listings out of a local rocksDB store/<a href="https://javalin.io/">Javalin</a> REST API during the write process, without needing to repeatedly list the cloud storage. Given we have hardened this as the default option since our 0.6.0 release, we are considering standalone timeline server installations, with support for horizontal scaling, database/table mappings, security and all the features necessary to turn it into a highly performant next generation lake metastore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MT_z-M0qz_nQFGPx.png" /></figure><h3>Lake Cache</h3><p>There is a fundamental tradeoff today in data lakes between faster writing and great query performance. Faster writing typically involves writing smaller files (and later clustering them) or logging deltas (and later merging on read). While this provides good performance already, the pursuit of great query performance often warrants opening fewer number of files/objects on lake storage and may be pre-materializing the merges between base and delta logs. After all, most databases employ a <a href="https://dev.mysql.com/doc/refman/8.0/en/innodb-buffer-pool.html">buffer pool</a> or <a href="https://github.com/facebook/rocksdb/wiki/Block-Cache">block cache</a>, to amortize the cost of accessing storage. Hudi already contains several design elements that are conducive for building a caching tier (write-through or even just populated by an incremental query), that will be multi-tenant and can cache pre-merged images of the latest file slices, consistent with the timeline. Hudi timeline can be used to simply communicate caching policies, just like how we perform inter table service co-ordination. Historically, caching has been done closer to the query engines or via intermediate in-memory file systems. By placing a caching tier closer and more tightly integrated with a transactional lake storage like Hudi, all query engines would be able to share and amortize the cost of the cache, while supporting updates/deletes as well. We look forward to building a buffer pool for the lake that works across all major engines, with the contributions from the rest of the community.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WYBe8lAki7yFf2qe.png" /></figure><h3>Onwards</h3><p>We hope that this blog painted a complete picture of Apache Hudi, staying true to its founding principles. Interested users and readers can expect blogs delving into each layer of the stack and an overhaul of our docs along these lines in the coming weeks/months. We view the current efforts around table formats as merely removing decade-old bottlenecks in data lake storage/query planes, problems which have been already solved very well in cloud warehouses like Big Query/Snowflake. We would like to underscore that our vision here is much greater, much more technically challenging. We as an industry are just wrapping our heads around many of these deep, open-ended problems, that need to be solved to marry stream processing and data lakes, with scale and simplicity. We hope to continue to put community first and build/solve these hard problems together. If these challenges excite you and you would like to build for that exciting future, please come join our <a href="http://hudi.apache.org/community.html">community</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5964468678a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-hudi-blogs/apache-hudi-the-streaming-data-lake-platform-5964468678a4">Apache Hudi — The Streaming Data Lake Platform</a> was originally published in <a href="https://medium.com/apache-hudi-blogs">apache-hudi-blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streaming Responsibly Into the Data Lake]]></title>
            <link>https://medium.com/apache-hudi-blogs/streaming-responsibly-into-the-data-lake-9a542b109eef?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a542b109eef</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-hudi]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Mon, 15 Mar 2021 17:27:21 GMT</pubDate>
            <atom:updated>2021-03-15T17:27:21.032Z</atom:updated>
            <content:encoded><![CDATA[<h4>How Apache Hudi maintains optimum sized files</h4><blockquote>This blog is a repost of the original blog <a href="https://hudi.apache.org/blog/hudi-file-sizing/">here</a></blockquote><p>Apache Hudi is a data lake platform technology that provides several functionalities needed to build and manage data lakes. One such key feature that hudi provides is self-managing file sizing so that users don’t need to worry about manual table maintenance. Having a lot of small files will make it harder to achieve good query performance, due to query engines having to open/read/close files way too many times, to plan and execute queries. But for streaming data lake use-cases, inherently ingests are going to end up having smaller volume of writes, which might result in lot of small files if no special handling is done.</p><h3>During Write vs After Write</h3><p>Common approaches to writing very small files and then later stitching them together solve for system scalability issues posed by small files but might violate query SLA’s by exposing small files to them. In fact, you can easily do so on a Hudi table, by running a clustering operation, as detailed in a <a href="https://hudi.apache.org/blog/hudi-clustering-intro/">previous blog</a>.</p><p>In this blog, we discuss file sizing optimizations in Hudi, during the initial write time, so we don’t have to effectively re-write all data again, just for file sizing. If you want to have both (a) self managed file sizing and (b) Avoid exposing small files to queries, automatic file sizing feature saves the day.</p><p>Hudi has the ability to maintain a configured target file size, when performing inserts/upsert operations. (Note: bulk_insert operation does not provide this functionality and is designed as a simpler replacement for normal spark.write.parquet).</p><h3>Configs</h3><p>For illustration purposes, we are going to consider only COPY_ON_WRITE table.</p><p>Configs of interest before we dive into the algorithm:</p><ul><li><a href="https://hudi.apache.org/docs/configurations.html#limitFileSize">Max file size</a>: Max size for a given data file. Hudi will try to maintain file sizes to this configured value</li><li><a href="https://hudi.apache.org/docs/configurations.html#compactionSmallFileSize">Soft file limit</a>: Max file size below which a given data file is considered to a small file</li><li><a href="https://hudi.apache.org/docs/configurations.html#insertSplitSize">Insert split size</a>: Number of inserts grouped for a single partition. This value should match the number of records in a single file (you can determine based on max file size and per record size)</li></ul><p>For instance, if your first config value is 120MB and 2nd config value is set to 100MB, any file whose size is &lt; 100MB would be considered a small file.</p><p>If you wish to turn off this feature, set the config value for soft file limit to 0.</p><h3>Example</h3><p>Let’s say this is the layout of data files for a given partition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/0*RN_tUYavq5bSZ6vM.png" /><figcaption><em>Figure: Initial data file sizes for a given partition of interest</em></figcaption></figure><p>Let’s assume the configured values for max file size and small file size limit are 120MB and 100MB. File_1’s current size is 40MB, File_2’s size is 80MB, File_3’s size is 90MB, File_4’s size is 130MB and File_5’s size is 105MB. Let’s see what happens when a new write happens.</p><p><strong>Step 1:</strong> Assigning updates to files. In this step, We look up the index to find the tagged location and records are assigned to respective files. Note that we assume updates are only going to increase the file size and that would simply result in a much bigger file. When updates lower the file size (by say, nulling out lot of fields), then a subsequent write will deem it a small file.</p><p><strong>Step 2:</strong> Determine small files for each partition path. The soft file limit config value will be leveraged here to determine eligible small files. In our example, given the config value is set to 100MB, the small files are File_1(40MB) and File_2(80MB) and file_3’s (90MB).</p><p><strong>Step 3:</strong> Once small files are determined, incoming inserts are assigned to them so that they reach their max capacity of 120MB. File_1 will be ingested with 80MB worth of inserts, file_2 will be ingested with 40MB worth of inserts and File_3 will be ingested with 30MB worth of inserts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C4SNuDwZREKg-yGk.png" /><figcaption><em>Figure: Incoming records are bin packed to existing small files</em></figcaption></figure><p><strong>Step 4:</strong> Once all small files are bin packed to its max capacity and if there are pending inserts unassigned, new file groups/data files are created and inserts are assigned to them. Number of records per new data file is determined from insert split size config. Assuming the insert split size is configured to 120k records, if there are 300k remaining records, 3 new files will be created in which 2 of them (File_6 and File_7) will be filled with 120k records and the last one (File_8) will be filled with 60k records (assuming each record is 1000 bytes). In future ingestions, 3rd new file will be considered as a small file to be packed with more data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4GwKFUJvtdP5ltYk.png" /><figcaption><em>Figure: Remaining records are assigned to new files</em></figcaption></figure><p>Hudi leverages mechanisms such as custom partitioning for optimized record distribution to different files, executing the algorithm above. After this round of ingestion is complete, all files except File_8 are nicely sized to the optimum size. This process is followed during every ingestion to ensure there are no small files in your Hudi tables.</p><p>Hopefully the blog gave you an overview into how hudi manages small files and assists in boosting your query performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a542b109eef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-hudi-blogs/streaming-responsibly-into-the-data-lake-9a542b109eef">Streaming Responsibly Into the Data Lake</a> was originally published in <a href="https://medium.com/apache-hudi-blogs">apache-hudi-blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimize Data Lake layout using Clustering in Apache Hudi]]></title>
            <link>https://medium.com/apache-hudi-blogs/optimize-data-lake-layout-using-clustering-in-apache-hudi-9fe151999c69?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fe151999c69</guid>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 06:17:58 GMT</pubDate>
            <atom:updated>2021-01-28T06:17:58.375Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>This blog is a repost of this </em></strong><a href="https://hudi.apache.org/blog/hudi-clustering-intro/"><strong><em>Hudi blog</em></strong></a><strong><em> on medium.</em></strong></blockquote><p>Apache Hudi brings stream processing to big data, providing fresh data while being an order of magnitude efficient over traditional batch processing. In a data lake/warehouse, one of the key trade-offs is between ingestion speed and query performance. Data ingestion typically prefers small files to improve parallelism and make data available to queries as soon as possible. However, query performance degrades poorly with a lot of small files. Also, during ingestion, data is typically co-located based on arrival time. However, the query engines perform better when the data frequently queried is co-located together. This kind of features are already found in Cloud data warehouses like <a href="https://medium.com/@jtaras/bigquery-table-clustering-f1a60c8d3122">Big Query</a>, <a href="https://docs.snowflake.com/en/user-guide/tables-auto-reclustering.html">Snowflake</a>.</p><p>In most data lake architectures each of these systems tend to add optimizations independently to improve performance which hits limitations due to un-optimized data layouts. This blog introduces a new kind of table service called clustering <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+19+Clustering+data+for+freshness+and+query+performance">[RFC-19]</a> to reorganize data for improved query performance without compromising on ingestion speed.</p><h3>Clustering Architecture</h3><p>At a high level, Hudi provides different operations such as insert/upsert/bulk_insert through it’s write client API to be able to write data to a Hudi table. To be able to choose a trade-off between file size and ingestion speed, Hudi provides a knob hoodie.parquet.small.file.limit to be able to configure the smallest allowable file size. Users are able to configure the small file <a href="https://hudi.apache.org/docs/configurations.html#compactionSmallFileSize">soft limit</a> to 0 to force new data to go into a new set of filegroups or set it to a higher value to ensure new data gets “padded” to existing files until it meets that limit that adds to ingestion latencies.</p><p>To be able to support an architecture that allows for fast ingestion without compromising query performance, we have introduced a ‘clustering’ service to rewrite the data to optimize Hudi data lake file layout.</p><p>Clustering table service can run asynchronously or synchronously adding a new action type called “REPLACE”, that will mark the clustering action in the Hudi metadata timeline.</p><h3>Overall, there are 2 parts to clustering</h3><ol><li>Scheduling clustering: Create a clustering plan using a pluggable clustering strategy.</li><li>Execute clustering: Process the plan using an execution strategy to create new files and replace old files.</li></ol><h3>Scheduling clustering</h3><p>Following steps are followed to schedule clustering.</p><ol><li>Identify files that are eligible for clustering: Depending on the clustering strategy chosen, the scheduling logic will identify the files eligible for clustering.</li><li>Group files that are eligible for clustering based on specific criteria. Each group is expected to have data size in multiples of ‘targetFileSize’. Grouping is done as part of ‘strategy’ defined in the plan. Additionally, there is an option to put a cap on group size to improve parallelism and avoid shuffling large amounts of data.</li><li>Finally, the clustering plan is saved to the timeline in an avro <a href="https://github.com/apache/hudi/blob/master/hudi-common/src/main/avro/HoodieClusteringPlan.avsc">metadata format</a>.</li></ol><h3>Running clustering</h3><ol><li>Read the clustering plan and get the ‘clusteringGroups’ that mark the file groups that need to be clustered.</li><li>For each group, we instantiate appropriate strategy class with strategyParams (example: sortColumns) and apply that strategy to rewrite the data.</li><li>Create a “REPLACE” commit and update the metadata in <a href="https://github.com/apache/hudi/blob/master/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieReplaceCommitMetadata.java">HoodieReplaceCommitMetadata</a>.</li></ol><p>Clustering Service builds on Hudi’s MVCC based design to allow for writers to continue to insert new data while clustering action runs in the background to reformat data layout, ensuring snapshot isolation between concurrent readers and writers.</p><p>NOTE: Clustering can only be scheduled for tables / partitions not receiving any concurrent updates. In the future, concurrent updates use-case will be supported as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A4Bv6a6XRXRkVe46.png" /><figcaption><em>Figure: Illustrating query performance improvements by clustering</em></figcaption></figure><h3>Setting up clustering</h3><p>Inline clustering can be setup easily using spark dataframe options. See sample below</p><pre>import org.apache.hudi.QuickstartUtils._<br>import scala.collection.JavaConversions._<br>import org.apache.spark.sql.SaveMode._<br>import org.apache.hudi.DataSourceReadOptions._<br>import org.apache.hudi.DataSourceWriteOptions._<br>import org.apache.hudi.config.HoodieWriteConfig._<br><br><br>val df =  //generate data frame<br>df.write.format(&quot;org.apache.hudi&quot;).<br>        options(getQuickstartWriteConfigs).<br>        option(PRECOMBINE_FIELD_OPT_KEY, &quot;ts&quot;).<br>        option(RECORDKEY_FIELD_OPT_KEY, &quot;uuid&quot;).<br>        option(PARTITIONPATH_FIELD_OPT_KEY, &quot;partitionpath&quot;).<br>        option(TABLE_NAME, &quot;tableName&quot;).<br>        option(&quot;hoodie.parquet.small.file.limit&quot;, &quot;0&quot;).<br>        option(&quot;hoodie.clustering.inline&quot;, &quot;true&quot;).<br>        option(&quot;hoodie.clustering.inline.max.commits&quot;, &quot;4&quot;).<br>        option(&quot;hoodie.clustering.plan.strategy.target.file.max.bytes&quot;, &quot;1073741824&quot;).<br>        option(&quot;hoodie.clustering.plan.strategy.small.file.limit&quot;, &quot;629145600&quot;).<br>        option(&quot;hoodie.clustering.plan.strategy.sort.columns&quot;, &quot;column1,column2&quot;). //optional, if sorting is needed as part of rewriting data<br>        mode(Append).<br>        save(&quot;dfs://location&quot;);</pre><p>For more advanced usecases, async clustering pipeline can also be setup. See an example <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+19+Clustering+data+for+freshness+and+query+performance#RFC19Clusteringdataforfreshnessandqueryperformance-SetupforAsyncclusteringJob">here</a>.</p><h3>Table Query Performance</h3><p>We created a dataset from one partition of a known production style table with ~20M records and on-disk size of ~200GB. The dataset has rows for multiple “sessions”. Users always query this data using a predicate on session. Data for a single session is spread across multiple data files because ingestion groups data based on arrival time. The below experiment shows that by clustering on session, we are able to improve the data locality and reduce query execution time by more than 50%.</p><p>Query:</p><pre>spark.sql(&quot;select  *  from table where session_id=123&quot;)</pre><h3>Before Clustering</h3><p>Query took 2.2 minutes to complete. Note that the number of output rows in the “scan parquet” part of the query plan includes all 20M rows in the table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7T-9nU3fjKQvTH2R.png" /></figure><h3>After Clustering</h3><p>The query plan is similar to above. But, because of improved data locality and predicate push down, spark is able to prune a lot of rows. After clustering, the same query only outputs 110K rows (out of 20M rows) while scanning parquet files. This cuts query time to less than a minute from 2.2 minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xza2tNEb2VXjvVB2.png" /><figcaption><em>Figure: Spark SQL query details after clustering</em></figcaption></figure><p>The table below summarizes query performance improvements from experiments run using Spark3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w2toTtgp_auqUwGiHr2v0Q.png" /></figure><p>Query runtime is reduced by 60% after clustering. Similar results were observed on other sample datasets. See example query plans and more details at the <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+19+Clustering+data+for+freshness+and+query+performance#RFC19Clusteringdataforfreshnessandqueryperformance-PerformanceEvaluation">RFC-19 performance evaluation</a>.</p><p>We expect dramatic speedup for large tables, where the query runtime is almost entirely dominated by actual I/O and not query planning, unlike the example above.</p><h3>Summary</h3><p>Using clustering, we can improve query performance by</p><ol><li>Leveraging concepts such as <a href="https://en.wikipedia.org/wiki/Z-order_curve">space filling curves</a> to adapt data lake layout and reduce the amount of data read during queries.</li><li>Stitch small files into larger ones and reduce the total number of files that need to be scanned by the query engine.</li></ol><p>Clustering also enables stream processing over big data. Ingestion can write small files to satisfy latency requirements of stream processing. Clustering can be used in the background to stitch these small files into larger files and reduce file count.</p><p>Besides this, the clustering framework also provides the flexibility to asynchronously rewrite data based on specific requirements. We foresee many other use-cases adopting clustering framework with custom pluggable strategies to satisfy on-demand data lake management activities. Some such notable use-cases that are actively being solved using clustering:</p><ol><li>Rewrite data and encrypt data at rest.</li><li>Prune unused columns from tables and reduce storage footprint.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fe151999c69" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-hudi-blogs/optimize-data-lake-layout-using-clustering-in-apache-hudi-9fe151999c69">Optimize Data Lake layout using Clustering in Apache Hudi</a> was originally published in <a href="https://medium.com/apache-hudi-blogs">apache-hudi-blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Employing the right indexes for fast updates, deletes in Apache Hudi]]></title>
            <link>https://medium.com/apache-hudi-blogs/employing-the-right-indexes-for-fast-updates-deletes-in-apache-hudi-814d863635f6?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/814d863635f6</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[apache-hudi]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Sat, 19 Dec 2020 09:50:00 GMT</pubDate>
            <atom:updated>2020-12-19T09:50:00.653Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>This blog is a repost of this </strong><a href="https://hudi.apache.org/blog/hudi-indexing-mechanisms/"><strong>Hudi blog</strong></a><strong> on medium.</strong></blockquote><p>Apache Hudi employs an index to locate the file group, that an update/delete belongs to. For Copy-On-Write tables, this enables fast upsert/delete operations, by avoiding the need to join against the entire dataset to determine which files to rewrite. For Merge-On-Read tables, this design allows Hudi to bound the amount of records any given base file needs to be merged against. Specifically, a given base file needs to merged only against updates for records that are part of that base file. In contrast, designs without an indexing component (e.g: <a href="https://cwiki.apache.org/confluence/display/Hive/Hive+Transactions">Apache Hive ACID</a>), could end up having to merge all the base files against all incoming updates/delete records.</p><p>At a high level, an index maps a record key + an optional partition path to a file group ID on storage (explained more in detail <a href="https://hudi.apache.org/docs/concepts.html">here</a>) and during write operations, we lookup this mapping to route an incoming update/delete to a log file attached to the base file (MOR) or to the latest base file that now needs to be merged against (COW). The index also enables Hudi to enforce unique constraints based on the record keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kx74VmnTqs0ZdnZnYbJ_Lw.png" /></figure><p><em>Figure: Comparison of merge cost for updates (yellow blocks) against base files (white blocks)</em></p><p>Given that Hudi already supports few different indexing techniques and is also continuously improving/adding more to its toolkit, the rest of the blog attempts to explain different categories of workloads, from our experience and suggests what index types to use for each. We will also interlace commentary on existing limitations, upcoming work and optimizations/tradeoffs along the way.</p><h3>Index Types in Hudi</h3><p>Currently, Hudi supports the following indexing options.</p><ul><li><strong>Bloom Index (default):</strong> Employs bloom filters built out of the record keys, optionally also pruning candidate files using record key ranges.</li><li><strong>Simple Index:</strong> Performs a lean join of the incoming update/delete records against keys extracted from the table on storage.</li><li><strong>HBase Index:</strong> Manages the index mapping in an external Apache HBase table.</li></ul><p>Writers can pick one of these options using hoodie.index.type config option. Additionally, a custom index implementation can also be employed using hoodie.index.class and supplying a subclass of SparkHoodieIndex (for Apache Spark writers)</p><p>Another key aspect worth understanding is the difference between global and non-global indexes. Both bloom and simple index have global options — hoodie.index.type=GLOBAL_BLOOM and hoodie.index.type=GLOBAL_SIMPLE - respectively. HBase index is by nature a global index.</p><ul><li><strong>Global index:</strong> Global indexes enforce uniqueness of keys across all partitions of a table i.e guarantees that exactly one record exists in the table for a given record key. Global indexes offer stronger guarantees, but the update/delete cost grows with size of the table O(size of table), which might still be acceptable for smaller tables.</li><li><strong>Non Global index:</strong> On the other hand, the default index implementations enforce this constraint only within a specific partition. As one might imagine, non global indexes depends on the writer to provide the same consistent partition path for a given record key during update/delete, but can deliver much better performance since the index lookup operation becomes O(number of records updated/deleted) and scales well with write volume.</li></ul><p>Since data comes in at different volumes, velocity and has different access patterns, different indices could be used for different workloads. Next, let’s walk through some typical workloads and see how to leverage the right Hudi index for such use-cases.</p><h3>Workload: Late arriving updates to fact tables</h3><p>Many companies store large volumes of transactional data in NoSQL data stores. For eg, trip tables in case of ride-sharing, buying and selling of shares, orders in an e-commerce site. These tables are usually ever growing with random updates on most recent data with long tail updates going to older data, either due to transactions settling at a later date/data corrections. In other words, most updates go into the latest partitions with few updates going to older ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3N0Aiwvv3VSaMSkHGzxlg.gif" /></figure><p><em>Figure: Typical update pattern for Fact tables</em></p><p>For such workloads, the BLOOM index performs well, since index look-up will prune a lot of data files based on a well-sized bloom filter. Additionally, if the keys can be constructed such that they have a certain ordering, the number of files to be compared is further reduced by range pruning. Hudi constructs an interval tree with all the file key ranges and efficiently filters out the files that don’t match any key ranges in the updates/deleted records.</p><p>In order to efficiently compare incoming record keys against bloom filters i.e with minimal number of bloom filter reads and uniform distribution of work across the executors, Hudi leverages caching of input records and employs a custom partitioner that can iron out data skews using statistics. At times, if the bloom filter false positive ratio is high, it could increase the amount of data shuffled to perform the lookup. Hudi supports dynamic bloom filters (enabled using hoodie.bloom.index.filter.type=DYNAMIC_V0), which adjusts its size based on the number of records stored in a given file to deliver the configured false positive ratio.</p><p>In the near future, we plan to introduce a much speedier version of the BLOOM index that tracks bloom filters/ranges in an internal Hudi metadata table, indexed for fast point lookups. This would avoid any current limitations around reading bloom filters/ranges from the base files themselves, to perform the lookup. (see <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+15%3A+HUDI+File+Listing+and+Query+Planning+Improvements?src=contextnavpagetreemode">RFC-15</a> for the general design)</p><h3>Workload: De-Duplication in event tables</h3><p>Event Streaming is everywhere. Events coming from Apache Kafka or similar message bus are typically 10–100x the size of fact tables and often treat “time” (event’s arrival time/processing time) as a first class citizen. For eg, IoT event stream, click stream data, ad impressions etc. Inserts and updates only span the last few partitions as these are mostly append only data. Given duplicate events can be introduced anywhere in the end-end pipeline, de-duplication before storing on the data lake is a common requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUT_Rf6XUqBzi2h8-r0D1A.gif" /></figure><p><em>Figure showing the spread of updates for Event table.</em></p><p>In general, this is a very challenging problem to solve at lower cost. Although, we could even employ a key value store to perform this de-duplication ala HBASE index, the index storage costs would grow linear with number of events and thus can be prohibitively expensive. In fact, BLOOM index with range pruning is the optimal solution here. One can leverage the fact that time is often a first class citizen and construct a key such as event_ts + event_id such that the inserted records have monotonically increasing keys. This yields great returns by pruning large amounts of files even within the latest table partitions.</p><h3>Workload: Random updates/deletes to a dimension table</h3><p>These types of tables usually contain high dimensional data and hold reference data e.g user profile, merchant information. These are high fidelity tables where the updates are often small but also spread across a lot of partitions and data files ranging across the dataset from old to new. Often times, these tables are also un-partitioned, since there is also not a good way to partition these tables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyCxfHj6k7ZF9pkaPE-egA.gif" /></figure><p><em>Figure showing the spread of updates for Dimensions table.</em></p><p>As discussed before, the BLOOM index may not yield benefits if a good number of files cannot be pruned out by comparing ranges/filters. In such a random write workload, updates end up touching most files within in the table and thus bloom filters will typically indicate a true positive for all files based on some incoming update. Consequently, we would end up comparing ranges/filter, only to finally check the incoming updates against all files. The SIMPLE Index will be a better fit as it does not do any upfront pruning based, but directly joins with interested fields from every data file. HBASE index can be employed, if the operational overhead is acceptable and would provide much better lookup times for these tables.</p><p>When using a global index, users should also consider setting hoodie.bloom.index.update.partition.path=true or hoodie.simple.index.update.partition.path=true to deal with cases where the partition path value could change due to an update e.g users table partitioned by home city; user relocates to a different city. These tables are also excellent candidates for the Merge-On-Read table type.</p><p>Going forward, we plan to build <a href="https://cwiki.apache.org/confluence/display/HUDI/RFC+-+08+%3A+Record+level+indexing+mechanisms+for+Hudi+datasets?src=contextnavpagetreemode">record level indexing</a> right within Hudi, which will improve the index look-up time and will also avoid additional overhead of maintaining an external system like hbase.</p><h3>Summary</h3><p>Without the indexing capabilities in Hudi, it would not been possible to make upserts/deletes happen at <a href="https://eng.uber.com/apache-hudi-graduation/">very large scales</a>. Hopefully this post gave you good enough context on the indexing mechanisms today and how different tradeoffs play out.</p><p>Some interesting work underway in this area:</p><ul><li>Apache Flink based writing with a RocksDB state store backed indexing mechanism, unlocking true streaming upserts on data lakes.</li><li>A brand new MetadataIndex, which reimagines the bloom index today on top of the metadata table in Hudi.</li><li>Record level index implementation, as a secondary index using another Hudi table.</li></ul><p>Going forward, this will remain an area of active investment for the project. we are always looking for contributors who can drive these roadmap items forward. Please <a href="https://hudi.apache.org/community.html">engage</a> with our community if you want to get involved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=814d863635f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-hudi-blogs/employing-the-right-indexes-for-fast-updates-deletes-in-apache-hudi-814d863635f6">Employing the right indexes for fast updates, deletes in Apache Hudi</a> was originally published in <a href="https://medium.com/apache-hudi-blogs">apache-hudi-blogs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hudi (Incubating) Support on Apache Zeppelin]]></title>
            <link>https://bytearray.io/apache-hudi-incubating-support-on-apache-zeppelin-defc6fe5f4c6?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/defc6fe5f4c6</guid>
            <category><![CDATA[data-lake]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Mon, 27 Apr 2020 16:14:44 GMT</pubDate>
            <atom:updated>2020-04-27T16:14:44.199Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Reposted translation of the original article : <a href="https://mp.weixin.qq.com/s/_mNwL5uXSDYyqtLDPx0iDA">https://mp.weixin.qq.com/s/_mNwL5uXSDYyqtLDPx0iDA</a></blockquote><h3>1 Introduction</h3><p>Apache Zeppelin is a web-based notebook that provides interactive data analysis. It is convenient for you to make beautiful documents that can be data-driven, interactive, and collaborative, and supports multiple languages, including Scala (using Apache Spark), Python (Apache Spark), SparkSQL, Hive, Markdown, Shell, and so on. Hive and SparkSQL currently support querying Hudi’s read-optimized view and real-time view. So in theory, Zeppelin’s notebook should also have such query capabilities.</p><h3>2. Achieve the effect</h3><h3>2.1 Hive</h3><h4>2.1.1 Read optimized view</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LxFGWtahcBeKdDPj" /></figure><h4>2.1.2 Real-time view</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u4zKWa0bNTRYbnWZ" /></figure><h3>2.2 Spark SQL</h3><h4>2.2.1 Read optimized view</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*u94KQxCmSwCV9ED8" /></figure><h4>2.2.2 Real-time view</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k3cI42T9TcJRijm2" /></figure><h3>3. Common problems</h3><h3>3.1 Hudi package adaptation</h3><p>Zeppelin will load the packages under lib by default when starting. For external dependencies such as Hudi, it is suitable to be placed directly under zeppelin / lib to avoid Hive or Spark SQL not finding the corresponding Hudi dependency on the cluster.</p><h3>3.2 Parquet jar package adaptation</h3><p>The parquet version of the Hudi package is 1.10, and the current parquet version of the CDH cluster is 1.9, so when executing the Hudi table query, many jar package conflict errors will be reported.</p><p><strong>Solution:</strong>upgrade the parquet package to 1.10 in the spark / jars directory of the node where zepeelin is located.</p><p><strong>Side effects:</strong>The tasks of saprk jobs other than zeppelin assigned to the cluster nodes of parquet 1.10 may fail.</p><p><strong>Suggestions:</strong>Clients other than zeppelin will also have jar conflicts. Therefore, it is recommended to fully upgrade the spark jar, parquet jar and related dependent jars of the cluster to better adapt to Hudi’s capabilities.</p><h3>3.3 Spark Interpreter adaptation</h3><p>The same SQL using Spark SQL query on Zeppelin will have more records than the hive query.</p><p><strong>Cause of the problem:</strong>When reading and writing Parquet tables to the Hive metastore, Spark SQL will use the Parquet SerDe (SerDe: Serialize / Deserilize for short) for Spark serialization and deserialization, not the Hive’s SerDe, because Spark SQL’s own SerDe has better performance.</p><p>This causes Spark SQL to only query Hudi’s pipeline records, not the final merge result.</p><p><strong>Solution:</strong>setspark.sql.hive.convertMetastoreParquet=false</p><p><strong>Method 1: Edit properties directly on the page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*b31hiO4ynbDLRrXWEFF4aQ.png" /></figure><p><strong>Method 2: Edit zeppelin / conf / interpreter.json and add</strong></p><p><strong>interpreter</strong></p><h3>4. Hudi incremental view</h3><p>For Hudi incremental view, currently only supports pulling by writing Spark code. Considering that Zeppelin has the ability to execute code and shell commands directly on the notebook, later consider packaging these notebooks to query Hudi incremental views in a way that supports SQL.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=defc6fe5f4c6" width="1" height="1" alt=""><hr><p><a href="https://bytearray.io/apache-hudi-incubating-support-on-apache-zeppelin-defc6fe5f4c6">Apache Hudi (Incubating) Support on Apache Zeppelin</a> was originally published in <a href="https://bytearray.io/">bytearray</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embrace the Data Lake Architecture]]></title>
            <link>https://medium.com/97-things/embrace-the-data-lake-architecture-9b0f1ad905e0?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b0f1ad905e0</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[data-engineer]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Sat, 08 Jun 2019 01:58:18 GMT</pubDate>
            <atom:updated>2019-07-23T22:25:50.979Z</atom:updated>
            <content:encoded><![CDATA[<h4>Often times, data engineers build data pipelines to extract data from external sources, transform them and enable other parts of the organization to query the resulting datasets. While it’s easier in the short term to just build all of this as a single stage pipeline, a more thoughtful data architecture is needed to scale this model to thousands of datasets spanning multiple tera/peta bytes.</h4><h3>Common Pitfalls</h3><p>Let’s understand some common pitfalls with the single-stage approach. First of all, it limits scalability since the input data to such a pipeline is obtained by scanning upstream databases (RDBMS-es or NoSQL stores) which would ultimately stress these systems and even result in outages. Further, accessing such data directly allows for very little standardization across pipelines (e.g: standard timestamp, key fields) as well increase risk of data brekages due to lack of schemas/data contracts. Finally, not all data or columns are available in a single place, to freely cross-correlate them for insights or design machine learning models.</p><h3>Data Lakes</h3><p>In recent years, the Data Lake architecture has grown in popularity. In this model, source data is first extracted with little-to-no transformation into a first set of raw datasets. The goal of these raw datasets is to effectively model an upstream source system and its data, but in a way that can scale for OLAP workloads (for e.g using columnar file formats). All data pipelines which express business specific transformation are then executed on top of these raw datasets instead.</p><h3>Advantages</h3><p>This approach has several advantages over the single-stage approach, avoiding all the pitfalls we listed before.</p><ul><li><strong>Scalable Design</strong> : Since the data is extracted once from each source system, the additional load on the source system is drastically reduced. Further extracted data is stored in optimized file formats on petabyte scale storage systems (e.g HDFS, Cloud stores), which are all specifically optimized for OLAP workloads.</li><li><strong>Standardized &amp; Schematized</strong> : During the ingestion of the raw datasets, a number of standardization steps can be performed and a schema can be enforced on the data, which validates both structural integrity and semantics. This prevents bad data from ever making its way into the data lake.</li><li><strong>Nimble</strong> : Data engineers can develop, test and deploy changes to transformation business logic independently with access to large scale parallel processing using 1000s of compute cores.</li><li><strong>Unlock data</strong> : Such a data lake houses all source data next to each other, with rich access to SQL and other tools to explore and derive business insights by joining them &amp; producing even derived datasets. Machine learning models have unfettered access to all of the data.</li></ul><h3>Implementation</h3><p>In this section, we will share a few tips for implementing the data lake architecture, based on lessons learnt from actually building <a href="https://eng.uber.com/uber-big-data-platform/">large data lake</a>(s).</p><ul><li>Consider ingesting databases in an incremental fashion using change-capture systems or even JDBC based approaches (e.g: Apache Sqoop) to improve data freshness as well as further reduce load on databases.</li><li>Standardize both event streams from applications and such database change streams into a single event bus (e.g Apache Kafka, Apache Pulsar)</li><li>Ingest the raw datasets off the event bus using technologies that can support upserts to compact database changes into a snapshot (e.g Apache Kudu, Apache Hudi, Apache Hive ACID)</li><li>Design the raw datasets to support efficient retrieval of new records (similar to change capture) by either partitioning your data (e.g using Apache Hive metastore) or using a system that support change streams (e.g Apache Hudi)</li></ul><blockquote>Disclaimer : I am part of PPMC of Apache Hudi, as well as its co-creator.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b0f1ad905e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/97-things/embrace-the-data-lake-architecture-9b0f1ad905e0">Embrace the Data Lake Architecture</a> was originally published in <a href="https://medium.com/97-things">97 Things</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up Hadoop/YARN/Spark/Hive on Mac OSX]]></title>
            <link>https://bytearray.io/setting-up-hadoop-yarn-spark-hive-on-mac-osx-deb0ee2c1b67?source=rss-7976a8959a9c------2</link>
            <guid isPermaLink="false">https://medium.com/p/deb0ee2c1b67</guid>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[yarn]]></category>
            <category><![CDATA[mac-os-x]]></category>
            <category><![CDATA[spark]]></category>
            <category><![CDATA[hadoop]]></category>
            <dc:creator><![CDATA[Vinoth Chandar]]></dc:creator>
            <pubDate>Sun, 16 Sep 2018 12:51:47 GMT</pubDate>
            <atom:updated>2018-09-16T12:51:47.534Z</atom:updated>
            <content:encoded><![CDATA[<p>[Reposted from my blogger]</p><p>If you are like me, who loves to have everything you are developing against working locally in a mini-integration environment, read on</p><p>Here, we attempt to get some pretty heavy-weight stuff working locally on your mac, namely</p><ol><li>Hadoop (Hadoop2/HDFS)</li><li>YARN (So you can submit MR jobs)</li><li>Spark (We will illustrate with Spark Shell, but should work on YARN mode as well)</li><li>Hive (So we can create some tables and play with it)</li></ol><p>We will use the latest stable Cloudera distribution, and work off the jars. Most of the methodology is borrowed from <a href="http://blog.cloudera.com/blog/2014/09/how-to-install-cdh-on-mac-osx-10-9-mavericks/">here</a>, we just link the four pieces together nicely in this blog.</p><h3>Download Stuff</h3><p>First off all, make sure you have Java 7/8 installed, with JAVA_HOME variable setup to point to the correct location. You have to download the CDH tarballs for Hadoop, Zookeeper, Hive from the tarball page (CDH 5.4.x <a href="http://www.cloudera.com/documentation/enterprise/release-notes/topics/cdh_vd_cdh_package_tarball_54.html#topic_3">page</a>) and untar them under a folder (refered to as CDH_HOME going forward) as hadoop, zookeeper</p><pre>$ ls $HOME/bin/cdh/5.4.7<br>hadoop                          hadoop-2.6.0-cdh5.4.7.tar.gz    hive-1.1.0-cdh5.4.7             hive-1.1.0-cdh5.4.7.tar.gz      zookeeper                       zookeeper-3.4.5-cdh5.4.7.tar.gz</pre><p>While you are at it, also grab what version of Spark (pre-built for Hadoop 2.6x) from <a href="http://spark.apache.org/downloads.html">here</a>, and untar to a directory like below, which we will call $SPARK_INSTALL</p><pre>$ ls $HOME/bin/spark-1.5.0-bin-hadoop2.6/<br>CHANGES.txt LICENSE     NOTICE      R           README.md   RELEASE     bin         conf        data        ec2         examples    lib         python      sbin</pre><p>You may also want to setup a bunch of variables early on, to be of use later</p><pre>CDH=&quot;5.4.7&quot;<br>export HADOOP_HOME=&quot;$HOME/bin/cdh/${CDH}/hadoop&quot;<br>export ZK_HOME=&quot;$HOME/bin/cdh/${CDH}/zookeeper&quot;<br>export SPARK_INSTALL=&quot;$HOME/bin/spark-1.5.0-bin-hadoop2.6&quot;<br>export PATH=${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:${ZK_HOME}/bin:${SPARK_INSTALL}/bin:${PATH}</pre><p>Tip 1: If you are using jenv to manage your versions, then you might need the following additional lines in your .bashrc/.bash_profile.</p><pre>eval &quot;$(jenv init -)&quot;<br>export JAVA_HOME=&quot;$HOME/.jenv/versions/`jenv version-name`&quot;<br>alias jenv_set_java_home=&#39;export JAVA_HOME=&quot;$HOME/.jenv/versions/`jenv version-name`&quot;&#39;</pre><p>Tip 2: Don’t accidentally, name your Spark install dir, SPARK_HOME, Hive does things with it, which you may not like.</p><h3>Setup Hadoop/YARN</h3><p>The <a href="http://blog.cloudera.com/blog/2014/09/how-to-install-cdh-on-mac-osx-10-9-mavericks/">page</a> we pointed to before, is an excellent resource for doing this already, I will just point out some additional configs I had to add, as I brought in Hive, to make things easier to debug</p><p>To etc/hadoop/core-site.xml (to let Hive queries impersonate)</p><pre>&lt;property&gt;<br>      &lt;name&gt;hadoop.proxyuser.root.hosts&lt;/name&gt;<br>      &lt;value&gt;*&lt;/value&gt;<br> &lt;/property&gt;<br> &lt;property&gt;<br>      &lt;name&gt;hadoop.proxyuser.root.groups&lt;/name&gt;<br>      &lt;value&gt;*&lt;/value&gt;<br>&lt;/property&gt;</pre><p>To etc/hadoop/yarn-site.xml (to let Hive queries leave a debuggable log)</p><pre>&lt;property&gt;<br>  &lt;name&gt;yarn.nodemanager.remote-app-log-dir&lt;/name&gt;<br>  &lt;value&gt;hdfs://localhost:8020/tmp/yarn-logs&lt;/value&gt;<br>  &lt;description&gt;Where to aggregate logs to.&lt;/description&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>  &lt;name&gt;yarn.log-aggregation.retain-seconds&lt;/name&gt;<br>  &lt;value&gt;3600&lt;/value&gt;<br>  &lt;description&gt;Number of seconds to retain logs for&lt;/description&gt;<br>&lt;/property&gt;</pre><p>Make sure, you can start HDFS &amp; YARN locally</p><h3>Setup Hive</h3><p>Go into the CDH_HOME/hive-1.1.0-cdh5.4.7 folder and follow the quickstart to build Hive. Basically a command like below</p><pre>mvn clean package -Phadoop-2,dist</pre><p>Once you are past the basic steps of quickstart, make a hive-site.xml like below and copy to your hadoop install</p><pre>$ cat $HADOOP_HOME/etc/hadoop/hive-site.xml<br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;configuration&gt;<br>  &lt;property&gt;<br>    &lt;name&gt;hive.metastore.uris&lt;/name&gt;<br>    &lt;value&gt;thrift://localhost:10000&lt;/value&gt;<br>  &lt;/property&gt;<br>&lt;/configuration&gt;</pre><p>Once this is done, you should be able to start a metastore server</p><pre>[apache-hive-1.1.0-cdh5.4.7-bin]$ bin/hive --service metastore -p 10000</pre><p>Open up a cli (create table &amp; do a small query)</p><pre>[apache-hive-1.1.0-cdh5.4.7-bin]$ bin/hive --hiveconf hive.metastore.uris=thrift://localhost:10000<br>readlink: illegal option -- f<br>usage: readlink [-n] [file ...]<br></pre><pre>WARNING: Hive CLI is deprecated and migration to Beeline is recommended.<br>hive&gt; CREATE TABLE pokes (foo INT, bar STRING);<br>OK<br>Time taken: 0.651 seconds</pre><pre>hive&gt; select count(*) from pokes;<br>Query ID = vinoth_20160523115454_527e550c-7318-4ffc-a49f-248ca119c5a8<br>Total jobs = 1<br>Launching Job 1 out of 1<br>Number of reduce tasks determined at compile time: 1<br>In order to change the average load for a reducer (in bytes):<br>  set hive.exec.reducers.bytes.per.reducer=&lt;number&gt;<br>In order to limit the maximum number of reducers:<br>  set hive.exec.reducers.max=&lt;number&gt;<br>In order to set a constant number of reducers:<br>  set mapreduce.job.reduces=&lt;number&gt;<br>Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 1<br>2016-05-23 11:54:28,958 Stage-1 map = 0%,  reduce = 0%<br>2016-05-23 11:54:34,119 Stage-1 map = 100%,  reduce = 0%<br>2016-05-23 11:54:39,249 Stage-1 map = 100%,  reduce = 100%<br>Ended Job = job_1464029642280_0001<br>MapReduce Jobs Launched:<br>Stage-Stage-1: Map: 1  Reduce: 1   HDFS Read: 6476 HDFS Write: 2 SUCCESS<br>Total MapReduce CPU Time Spent: 0 msec<br>OK<br>0<br>Time taken: 18.299 seconds, Fetched: 1 row(s)<br>hive&gt;</pre><h3>Setup Spark</h3><p>Spark is super simple, just need to point Spark to the Hadoop installation, that has not only the Hadoop configs, but also the Hive config (this is why we cp-ed hive-site.xml before)</p><pre>$ cd $SPARK_INSTALL<br>$ export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop<br>$ spark-shell --driver-class-path $HADOOP_CONF_DIR </pre><pre>scala&gt; sqlContext.sql(&quot;show tables&quot;).show()<br>scala&gt; sqlContext.sql(&quot;describe pokes&quot;).show()<br>scala&gt; sqlContext.sql(&quot;select count(*) from pokes&quot;).show()</pre><p>Voila!! (not really a quick thing to do, but once you have done it once, then you can setup debugger etc and its all golden)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb0ee2c1b67" width="1" height="1" alt=""><hr><p><a href="https://bytearray.io/setting-up-hadoop-yarn-spark-hive-on-mac-osx-deb0ee2c1b67">Setting up Hadoop/YARN/Spark/Hive on Mac OSX</a> was originally published in <a href="https://bytearray.io/">bytearray</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>