<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ big data - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ big data - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 14 Jun 2026 05:25:29 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/big-data/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Read and Write Deeply Partitioned Files Using Apache Spark ]]>
                </title>
                <description>
                    <![CDATA[ If you use Apache Spark to write your data pipeline, you might need to export or copy data from a source to destination while preserving the partition folders between the source and destination. When I researched online on how to do this in Spark, I ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-read-and-write-deeply-partitioned-files-using-apache-spark/</link>
                <guid isPermaLink="false">68b4bd4bbcba09cb447c5a9f</guid>
                
                    <category>
                        <![CDATA[ #apache-spark ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Scala ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Arun Shanmugam Kumar ]]>
                </dc:creator>
                <pubDate>Sun, 31 Aug 2025 21:23:23 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1756671369152/1e620925-6fb6-47fa-8344-86b9d3c7cd02.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you use Apache Spark to write your data pipeline, you might need to export or copy data from a source to destination while preserving the partition folders between the source and destination.</p>
<p>When I researched online on how to do this in Spark, I found very few tutorials giving an end-to-end solution that worked – especially when the partitions are deeply nested and you don't know beforehand the values these folder names will take (for example <code>year=*/month=*/day=*/hour=*/*.csv</code>).</p>
<p>In this tutorial, I have provided one such implementation using Spark.</p>
<h3 id="heading-heres-what-well-cover">Here’s what we’ll cover:</h3>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisite">Prerequisite</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-setup">Setup</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-false-starts">False Starts</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-my-solution">My Solution</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisite">Prerequisite</h2>
<p>To follow along in this tutorial, you need to have basic understanding of distributed computing using frameworks like Hadoop and Spark, as well as code that’s programmed in Object Oriented languages like Scala/Java. The code is tested using the below dependencies:</p>
<ul>
<li><p>Scala 2.12+</p>
</li>
<li><p>Java 17 (earlier versions might work)</p>
</li>
<li><p>Sbt</p>
</li>
</ul>
<h2 id="heading-setup">Setup</h2>
<p>I’m assuming you have partition folders that are created at the source with the below pattern (which is a standard partition column involving date-time):</p>
<p><code>year/month/day/hour</code></p>
<p>Crucially, as I mentioned above, I’m assuming that you don’t know the full name of the folders – except that they have some constant prefix pattern in them.</p>
<h2 id="heading-false-starts">False Starts</h2>
<ol>
<li><p>If you think of using <code>recursiveFileLookup</code> and <code>pathGlobFilter</code> option while both reading and writing, it doesn’t quite work, as the above functions are only available on read API.</p>
</li>
<li><p>If you think of parameterizing the reading and writing based on all the possible year/month/day/hour combination and skip export if the corresponding partition folder is not found, then it might work but won’t be very efficient.</p>
</li>
</ol>
<h2 id="heading-my-solution">My Solution</h2>
<p>After a few trials and errors and searching in Stack Overflow and the Spark documentation, I hit upon an idea to use a combination of <code>input_file_name()</code>, <code>regexp_extract()</code>, and <code>partitionBy()</code> API's on the write side to achieve the end goal. You can find a Scala-based sample code below:</p>
<pre><code class="lang-scala"><span class="hljs-keyword">package</span> main.scala.blog

<span class="hljs-comment">/**
*  Spark stream example code to read and write from a partitioned folder
*  to a partitioned folder without explicitly known datetime.
*/</span>

<span class="hljs-keyword">import</span> org.apache.spark.sql.<span class="hljs-type">SparkSession</span>
<span class="hljs-keyword">import</span> org.apache.spark.sql.types.<span class="hljs-type">StringType</span>
<span class="hljs-keyword">import</span> org.apache.spark.sql.functions.{udf, input_file_name, col, lit, regexp_extract}

<span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-title">PartitionedReaderWriter</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span></span>(args: <span class="hljs-type">Array</span>[<span class="hljs-type">String</span>]) {
        <span class="hljs-comment">// 1.</span>
        <span class="hljs-keyword">val</span> spark = <span class="hljs-type">SparkSession</span>
                    .builder
                    .appName(<span class="hljs-string">"PartitionedReaderWriterApp"</span>)
                    .getOrCreate()

        <span class="hljs-keyword">val</span> sourceBasePath = <span class="hljs-string">"data/partitioned_files_source/user"</span>
        <span class="hljs-comment">// 2.</span>
        <span class="hljs-keyword">val</span> sourceDf = spark.read
                            .format(<span class="hljs-string">"csv"</span>)
                            .schema(<span class="hljs-string">"State STRING, Color STRING, Count INT"</span>)
                            .option(<span class="hljs-string">"header"</span>, <span class="hljs-string">"true"</span>)
                            .option(<span class="hljs-string">"pathGlobFilter"</span>, <span class="hljs-string">"*.csv"</span>)
                            .option(<span class="hljs-string">"recursiveFileLookup"</span>, <span class="hljs-string">"true"</span>)
                            .load(sourceBasePath)

        <span class="hljs-keyword">val</span> destinationBasePath = <span class="hljs-string">"data/partitioned_files_destination/user"</span>
        <span class="hljs-comment">// 3.</span>
        <span class="hljs-keyword">val</span> writeDf = sourceDf
                        .withColumn(<span class="hljs-string">"year"</span>, regexp_extract(input_file_name(), <span class="hljs-string">"year=(\\d{4})"</span>, <span class="hljs-number">1</span>))
                        .withColumn(<span class="hljs-string">"month"</span>, regexp_extract(input_file_name(), <span class="hljs-string">"month=(\\d{2})"</span>, <span class="hljs-number">1</span>))
                        .withColumn(<span class="hljs-string">"day"</span>, regexp_extract(input_file_name(), <span class="hljs-string">"day=(\\d{2})"</span>, <span class="hljs-number">1</span>))
                        .withColumn(<span class="hljs-string">"hour"</span>, regexp_extract(input_file_name(), <span class="hljs-string">"hour=(\\d{2})"</span>, <span class="hljs-number">1</span>))

        <span class="hljs-comment">// 4.</span>
        writeDf.write
                .format(<span class="hljs-string">"csv"</span>)
                .option(<span class="hljs-string">"header"</span>, <span class="hljs-string">"true"</span>)
                .mode(<span class="hljs-string">"overwrite"</span>)
                .partitionBy(<span class="hljs-string">"year"</span>, <span class="hljs-string">"month"</span>, <span class="hljs-string">"day"</span>, <span class="hljs-string">"hour"</span>)
                .save(destinationBasePath)

        <span class="hljs-comment">// 5.</span>
        spark.stop()        
    }
}
</code></pre>
<p>Here’s what’s going on in the above code:</p>
<ol>
<li><p>Inside main method, you begin by adding Spark initialization setup code to create a Spark session.</p>
</li>
<li><p>You read the data from <code>sourceBasePath</code> using spark <code>read()</code> API with the format as <code>csv</code> (you can also optionally provide the schema). Options <code>recursiveFileLookup</code> and <code>pathGlobFilter</code> are needed to recursively read through nested folders and to specify any <code>csv</code> file, respectively.</p>
</li>
<li><p>Th next section contains the core logic where you can use <code>input_file_name()</code> to return the full path of the file and <code>regexp_extract()</code> to extract <code>year</code> , <code>month</code>, <code>day</code>, and <code>hour</code> from the corresponding subfolders in the path and store them as auxiliary columns on the dataframe.</p>
</li>
<li><p>Finally, you write the dataframe using the <code>csv</code> format again and crucially use <code>partitionBy</code> to specify the previously created auxiliary columns as partition columns. Then save the dataframe in the <code>destinationBasePath</code>.</p>
</li>
<li><p>After the copy is done, you stop the Spark session by calling the <code>stop()</code> API.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article I have shown you how to export / copy a deeply nested data files from source to destination using Apache Spark in an efficient way. I hope you find it useful!</p>
<p>You can read my other articles at <a target="_blank" href="https://www.beyonddream.me/post-1/">https://www.beyonddream.me.</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Data-Driven Reality – Exploring the Power of AI, ML, Virtual and Augmented Reality ]]>
                </title>
                <description>
                    <![CDATA[ By now it's no secret that digital data is generated by the truckload and that it can be worth its weight in gold.  But that knowledge isn't half as important as understanding how you can tame the data beast and then wring out every drop of its value... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/data-driven-reality/</link>
                <guid isPermaLink="false">66b995d07bb37b73c3f3c4da</guid>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Augmented Reality ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Tue, 21 Feb 2023 22:57:20 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/pexels-pixabay-164686.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By now it's no secret that digital data is generated by the truckload and that it can be worth its weight in gold. </p>
<p>But that knowledge isn't half as important as understanding <em>how</em> you can tame the data beast and then wring out every drop of its value.</p>
<p>Naturally, creative and resourceful people in one place or another are always finding new processes and applications that'll make better use of their data. So we'll explore some of today's dominant data utilization trends and leave predicting tomorrow's technology for the pundits.</p>
<p>This chapter was taken from my book, <a target="_blank" href="https://amzn.to/3FXXAfb">Keeping Up: Backgrounders to All the Big Technology Trends You Can't Afford to Ignore</a>. If you'd prefer to watch this chapter as a video, feel free to follow along here:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/JvoguWXO-lg" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h1 id="heading-what-exactly-is-data">What Exactly Is Data?</h1>
<p>Before priming our understanding of what's available to help us work productively with data, it's a good idea to first define exactly what data is. </p>
<p>Sure, we saw plenty of great individual examples in my <a target="_blank" href="https://www.freecodecamp.org/news/how-to-manage-data-storage/">previous article on Managing Data Storage</a>, including the huge volumes of performance and status information produced by digital components of complex systems like cars. But that's not the same as a definition.</p>
<p>So then let's define it. Data, for our purposes, is any digital information that is generated by, or used for, your compute operations. That will include log messages produced by a compute device, weather information relayed through remote sensors to a server, digital imaging files (like CT, tomography and ultrasound scans), and the numbers you enter into a spreadsheet. And everything in between.</p>
<p>Which brings us to <em>big data</em> – another one of those buzz phrases that get thrown around a lot, often without accompanying context or clarity. </p>
<p>On a first glance, you'd probably figure that <em>big data</em> describes data sets that come in volumes higher than traditional data software and hardware solutions are capable of handling.</p>
<p>Indeed, your way of figuring it would be largely correct. Although we could add one or two secondary characteristics. The <em>complexity</em> of a data set, for instance, is also something that could force you to consider big data solutions. And sets of data that must be consumed and analyzed while in motion (<em>streaming data</em>) are also often better addressed using big data tools.</p>
<p>It's worth mentioning that big data workloads will often seek to solve large scale predictive analytics or behavior analytics problems. Such problems are common within domains like healthcare, Internet of Things (IoC), and information technology.</p>
<p>With that out of the way, we can now get to work understanding how – and why – all that data is being used.</p>
<h1 id="heading-virtual-reality-and-augmented-reality">Virtual Reality and Augmented Reality</h1>
<p>What? Plain old reality suddenly not good enough for you?</p>
<p>Well yes, in some cases, plain old reality really isn't good enough. At least if you have a strong interest in engaging in experiences that are difficult or impossible under normal conditions.</p>
<p>A virtual reality (VR) device lets you immerse yourself in a non-existent environment. </p>
<p>The most common examples of currently available VR technology feature some kind of headset that projects visual images in front of your eyes while tracking your head movements and, in some cases, the way you're moving other parts of your body. The visual images will adapt to your physical movements, giving you the sensation that you're actually within and manipulating the virtual projection.</p>
<p>VR has potential applications in educational, healthcare, research, and military fields. The ability to simulate distant, prohibitively expensive, or theoretical environments can make training more realistic and immediate than would be otherwise possible.</p>
<p>VR technologies have been arriving – and then disappearing – for decades already. For the most part, they've focused on providing immersive gaming and entertainment environments. But they've never really caught on in a big way beyond the niche product level. </p>
<p>This might be partly due to high prices, and because some people experienced forms of motion sickness and disorientation.</p>
<p>But maybe – just maybe – (insert the current year here) will finally be the year VR hits the big time.</p>
<p>But where VR can leverage data in a really meaningful way is when, rather than blocking out your physical surroundings, the virtual environment is overlaid <em>on top</em> of your actual field of vision. </p>
<p>Imagine you're a technician working on electrical switching hardware under a sidewalk. You're wearing goggles that let you see the equipment in front of you, but that also project text and icons clearly identifying labels for each part and that show you where a replacement part should go and how it's connected. This is <em>augmented reality.</em></p>
<p>I'm sure you can easily imagine how powerful this kind of dynamic display could be in the right conditions. </p>
<p>Surgeons are able to access a patient's history or even consult relevant medical literature without having to divert their eyes from the operation. Military pilots can similarly enjoy "heads up" displays that show them timely status reports describing their own aircraft and broader air traffic conditions without distraction.</p>
<h1 id="heading-artificial-intelligence-and-machine-learning">Artificial Intelligence and Machine Learning</h1>
<p>As a rule, computers are even better at performing dull, repetitive tasks over and over again than bored teenagers pretending to do homework. And they make less noise in the process.</p>
<p>The trick with computers is to cleverly string lots of dull, repetitive tasks together so that they can approximate intelligent and useful behavior. </p>
<p>The prize at the end of that road is called <em>automation.</em> Or, in other words, a state where computers can be confidently left alone to perform complex and useful tasks without supervision.</p>
<p>In many ways, we've been living in an age of sophisticated computer automation for decades. Domains as diverse as security monitoring, urban traffic control, book manufacturing, and heavy industry are already being handled with little or no human supervision. </p>
<p>But artificial intelligence (AI) seeks to go beyond relatively simple repetition to train computers to think for themselves – and thereby efficiently solve far more difficult problems.</p>
<p>Great idea. Somewhat harder to achieve in the real world.</p>
<h2 id="heading-what-can-ai-actually-do">What can AI actually do?</h2>
<p>Understanding how effective AI can be will depend on what you expect it to do. Can you design software to search for and flag a handful of suspicious financial transactions from among the millions of credit card transactions a large bank processes? Yes. (Although I'm not quite sure that's truly <em>AI</em> at work and not just automation.)</p>
<p>Can you deploy "intelligent" chatbots on your website to help customers solve their problems without needing actual (and expensive) human interaction? Yes. In fact, I just had a surprisingly effective conversation with my mobile phone carrier's chatbot that did quickly solve my problem.</p>
<p>Can the first stages of a rocket you've just used to launch a payload into space use AI to guide it to a safe landing on a moving platform in the middle of the ocean? If you'd ask me, I'd say it's impossible. But SpaceX went ahead anyway and did it multiple times. Good thing they didn't ask me.</p>
<p>But can AI reliably make strategic decisions that intelligently account for all the many moving parts and complexity that exist in your industry? Can an AI-powered machine pass the Turing test (where a human evaluator is unable to be sure whether the machine is also human)? Perhaps not just yet. And perhaps never.</p>
<p>One tool used in many AI processes is the neural network. The original neural network consists of the many neurons that carry information about the state of a biological environment to the brain. </p>
<p>Artificial and virtual neural networks are systems for assessing, processing, and responding to the large physical or virtual data sets that feed AI-controlled systems. </p>
<p>Such data can come from cameras or other physical sensors, or from multiple data sources. The processed data can sometimes be used for predictive modeling, where the likelihood of future outcomes are compared.</p>
<p>Exciting stuff, to be sure. But the tools used for some of the most significant accomplishments attributed to artificial intelligence aren't actually artificial. Nor did they necessarily require all that much intelligence.</p>
<p>For example, Amazon Mechanical Turk (MTurk) is a service that connects client companies with remote freelancing "human intelligence" workers. The workers will, for what usually amounts to dreadfully low pay, perform "mechanical" tasks like labelling the content of hundreds or thousands of images. The labelling will cover areas like "is the subject a male or female?" or "is the subject a car or a bus?"</p>
<p>It could be that, over time, services like Mechanical Turk will become less important as improving AI methodologies might one day completely replace the human element for this kind of work. But in the meantime, MTurk and its competitors are still steaming along at full speed, churning out millions of units of "artificial" artificial intelligence.</p>
<p>One methodology that can help reduce reliance on human intervention is machine learning (ML).</p>
<h2 id="heading-how-can-machine-learning-help">How can machine learning help?</h2>
<p>ML works by leveraging various kinds of manual assistance to help achieve greater task automation. An ML system can hopefully "learn" how to manage our tasks by being exposed to existing training data. Only once the system has demonstrated sufficient skill at solving the problems you have for it, will it be let loose on "real world" data.</p>
<p>These are some common approaches to training your ML system:</p>
<ul>
<li><strong>Supervised learning</strong> lets the ML software read data sets that include both "problems" (images, for example) and their "solutions" (full labels). By seeing enough of the provided examples, the system should be able to apply its experience to similar problems that arrive without solutions.</li>
<li><strong>Unsupervised learning</strong> simply throws raw data without any associated solutions at the system. The goal is for the software to recognize enough patterns in the data to allow it to solve the problems on its own.</li>
<li><strong>Reinforcement learning</strong> learns from interactions with its environment. Ideally, the software recognizes and understands positive results and evolves its methodology to reliably and consistently produce similar results.</li>
<li><strong>Deep learning</strong> algorithms apply multiple layers of analysis to transform the raw target data. The full, multi-layer process in deep learning is known as the <em>substantial credit assignment path</em> (CAP).</li>
</ul>
<p>AI in general, and ML in particular, are effective at building tools for tasks like autonomous driving, drug discovery, email filtering, and speech recognition, and for deriving sentiment analysis from massive data sets made up of human communications.</p>
<p>What AI and ML share in common with all the other technologies like virtual reality and augmented reality that we've discussed here – and in that <a target="_blank" href="https://www.freecodecamp.org/news/how-to-manage-data-storage/">other "How to Manage Data Storage" article</a> – is the need to control and make better sense of the endless streams of information our digital products keep generating. The better we get at this kind of control, the more value we'll get from our data.</p>
<p><em>YouTube videos of all ten chapters from this book <a target="_blank" href="https://www.youtube.com/playlist?list=PLSiZCpRYoTZ6UWl4xialvwLOKyHYYJUiC">are available here</a>. Lots more tech goodness - in the form of books, courses, and articles - <a target="_blank" href="https://bootstrap-it.com">can be had here</a>. And consider taking my <a target="_blank" href="https://www.udemy.com/user/david-clinton-12/">AWS, security, and container technology courses here</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ The Apache Kafka Handbook – How to Get Started Using Kafka ]]>
                </title>
                <description>
                    <![CDATA[ Apache Kafka is an open-source event streaming platform that can transport huge volumes of data at very low latency. Companies like LinkedIn, Uber, and Netflix use Kafka to process trillions of events and petabtyes of data each day. Kafka was origina... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/apache-kafka-handbook/</link>
                <guid isPermaLink="false">66d45edb787a2a3b05af43a0</guid>
                
                    <category>
                        <![CDATA[ Apache Kafka ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Gerard Hynes ]]>
                </dc:creator>
                <pubDate>Fri, 03 Feb 2023 23:48:22 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/apache-kafka-handbook.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Apache Kafka is an open-source event streaming platform that can transport huge volumes of data at very low latency.</p>
<p>Companies like LinkedIn, Uber, and Netflix use Kafka to process trillions of events and petabtyes of data each day.</p>
<p>Kafka was <a target="_blank" href="https://engineering.linkedin.com/27/project-kafka-distributed-publish-subscribe-messaging-system-reaches-v06">originally developed at LinkedIn</a>, to help handle their real-time data feeds. It's now maintained by the <a target="_blank" href="https://kafka.apache.org/">Apache Software Foundation</a>, and is widely adopted in industry (being used by 80% of Fortune 100 companies).</p>
<h2 id="heading-why-should-you-learn-apache-kafka">Why Should You Learn Apache Kafka?</h2>
<p>Kafka lets you:</p>
<ul>
<li><p>Publish and subscribe to streams of events</p>
</li>
<li><p>Store streams of events in the same order they happened</p>
</li>
<li><p>Process streams of events in real time</p>
</li>
</ul>
<p>The main thing Kafka does is help you efficiently connect diverse data sources with the many different systems that might need to use that data.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/before-and-after-kafka-1.PNG" alt="Messy data integrations without Kafka, more organized data integrations with Kafka." width="600" height="400" loading="lazy"></p>
<p><em>Kafka helps you connect data sources to the systems using that data</em></p>
<p>Some of the things you can use Kafka for include:</p>
<ul>
<li><p>Personalizing recommendations for customers</p>
</li>
<li><p>Notifying passengers of flight delays</p>
</li>
<li><p>Payment processing in banking</p>
</li>
<li><p>Online fraud detection</p>
</li>
<li><p>Managing inventory and supply chains</p>
</li>
<li><p>Tracking order shipments</p>
</li>
<li><p>Collecting telemetry data from Internet of Things (IoT) devices</p>
</li>
</ul>
<p>What all these uses have in common is that they need to take in and process data in real time, often at huge scales. This is something Kafka excels at. To give one example, <a target="_blank" href="https://www.confluent.io/blog/running-kafka-at-scale-at-pinterest/">Pinterest uses Kafka to handle up to 40 million events per second</a>.</p>
<p>Kafka is distributed, which means it runs as a cluster of nodes spread across multiple servers. It's also replicated, meaning that data is copied in multiple locations to protect it from a single point of failure. This makes Kafka both scalable and fault-tolerant.</p>
<p>Kafka is also fast. It's optimized for high throughput, making effective use of disk storage and batched network requests.</p>
<p>This article will:</p>
<ul>
<li><p>Introduce you to the core concepts behind Kafka</p>
</li>
<li><p>Show you how to install Kafka on your own computer</p>
</li>
<li><p>Get you started with the Kafka Command Line Interface (CLI)</p>
</li>
<li><p>Help you build a simple Java application that produces and consumes events via Kafka</p>
</li>
</ul>
<p>Things the article won't cover:</p>
<ul>
<li><p>More advanced Kafka topics, such as security, performance, and monitoring</p>
</li>
<li><p>Deploying a Kafka cluster to a server</p>
</li>
<li><p>Using managed Kafka services like Amazon MSK or Confluent Cloud</p>
</li>
</ul>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ol>
<li><p><a class="post-section-overview" href="#heading-event-streaming-and-event-driven-architectures">Event Streaming and Event-Driven Architectures</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-core-kafka-concepts">Core Kafka Concepts</a><br> a. <a class="post-section-overview" href="#heading-event-messages-in-kafka">Event Messages in Kafka</a><br> b. <a class="post-section-overview" href="#heading-topics-in-kafka">Topics in Kafka</a><br> c. <a class="post-section-overview" href="#heading-partitions-in-kafka">Partitions in Kafka</a><br> d. <a class="post-section-overview" href="#heading-offsets-in-kafka">Offsets in Kafka</a><br> e. <a class="post-section-overview" href="#heading-brokers-in-kafka">Brokers in Kafka</a><br> f. <a class="post-section-overview" href="#heading-replication-in-kafka">Replication in Kafka</a><br> g. <a class="post-section-overview" href="#heading-producers-in-kafka">Producers in Kafka</a><br> h. <a class="post-section-overview" href="#heading-consumers-in-kafka">Consumers in Kafka</a><br> i. <a class="post-section-overview" href="#heading-consumer-groups-in-kafka">Consumer Groups in Kafka</a><br> j. <a class="post-section-overview" href="#heading-kafka-zookeeper">Kafka Zookeeper</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-install-kafka-on-your-computer">How to Install Kafka on Your Computer</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-start-zookeeper-and-kafka">How to Start Zookeeper and Kafka</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-the-kafka-cli">The Kafka CLI</a><br> a. <a class="post-section-overview" href="#heading-how-to-list-topics">How to List Topics</a><br> b. <a class="post-section-overview" href="#heading-how-to-create-a-topic">How to Create a Topic</a><br> c. <a class="post-section-overview" href="#heading-how-to-describe-topics">How to Describe Topics</a><br> d. <a class="post-section-overview" href="#heading-how-to-partition-a-topic">How to Partition a Topic</a><br> e. <a class="post-section-overview" href="#heading-how-to-set-a-replication-factor">How to Set a Replication Factor</a><br> f. <a class="post-section-overview" href="#heading-how-to-delete-a-topic">How to Delete a Topic</a><br> g. <a class="post-section-overview" href="#heading-how-to-use-kafka-console-producer">How to use <code>kafka-console-producer</code></a><br> h. <a class="post-section-overview" href="#heading-how-to-use-kafka-console-consumer">How to use <code>kafka-console-consumer</code></a><br> i. <a class="post-section-overview" href="#heading-how-to-use-kafka-consumer-groups">How to use <code>kafka-consumer-groups</code></a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-build-a-kafka-client-app-with-java">How to Build a Kafka Client App with Java</a><br> a. <a class="post-section-overview" href="#heading-how-to-set-up-the-project">How to Set Up the Project</a><br> b. <a class="post-section-overview" href="#heading-how-to-install-the-dependencies">How to Install the Dependencies</a><br> c. <a class="post-section-overview" href="#heading-how-to-create-a-kafka-producer">How to Create a Kafka Producer</a><br> d. <a class="post-section-overview" href="#heading-how-to-send-multiple-messages-and-use-callbacks">How to Send Multiple Messages and Use Callbacks</a><br> e. <a class="post-section-overview" href="#heading-how-to-create-a-kafka-consumer">How to Create a Kafka Consumer</a><br> f. <a class="post-section-overview" href="#heading-how-to-shut-down-the-consumer">How to Shut Down the Consumer</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-where-to-take-it-from-here">Where to Take it From Here</a></p>
</li>
</ol>
<p>Before we dive into Kafka, we need some context on event streaming and event-driven architectures.</p>
<h2 id="heading-event-streaming-and-event-driven-architectures">Event Streaming and Event-Driven Architectures</h2>
<p>An event is a record that something happened, as well as information about what happened. For example: a customer placed an order, a bank approved a transaction, inventory management updated stock levels.</p>
<p>Events can triggers one or more processes to respond to them. For example: sending an email receipt, transmitting funds to an account, updating a real-time dashboard.</p>
<p>Event streaming is the process of capturing events in real-time from sources (such as web applications, databases, or sensors) to create streams of events. These streams are potentially unending sequences of records.</p>
<p>The event stream can be stored, processed, and sent to different destinations, also called sinks. The destinations that consume the streams could be other applications, databases, or data pipelines for further processing.</p>
<p>As applications have become more complex, often being broken up into different microservices distributed across multiple data centers, many organizations have adopted an event-driven architecture for their applications.</p>
<p>This means that instead of parts of your application directly asking each other for updates about what happened, they each publish events to event streams. Other parts of the application continuously subscribe to these streams and only act when they receive an event that they are interested in.</p>
<p>This architecture helps ensure that if part of your application goes down, other parts won't also fail. Additionally, you can add new features by adding new subscribers to the event stream, without having to rewrite the existing codebase.</p>
<h2 id="heading-core-kafka-concepts">Core Kafka Concepts</h2>
<p>Kafka has become one of the most popular ways to implement event streaming and event-driven architectures. But it does have a bit of a learning curve and you need to understand a couple of concepts before you can make effective use of it.</p>
<p>These core concepts are:</p>
<ul>
<li><p>event messages</p>
</li>
<li><p>topics</p>
</li>
<li><p>partitions</p>
</li>
<li><p>offsets</p>
</li>
<li><p>brokers</p>
</li>
<li><p>producers</p>
</li>
<li><p>consumers</p>
</li>
<li><p>consumer groups</p>
</li>
<li><p>Zookeeper</p>
</li>
</ul>
<h3 id="heading-event-messages-in-kafka">Event Messages in Kafka</h3>
<p>When you write data to Kafka, or read data from it, you do this in the form of messages. You'll also see them called events or records.</p>
<p>A message consists of:</p>
<ul>
<li><p>a key</p>
</li>
<li><p>a value</p>
</li>
<li><p>a timestamp</p>
</li>
<li><p>a compression type</p>
</li>
<li><p>headers for metadata (optional)</p>
</li>
<li><p>partition and offset id (once the message is written to a topic)</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-message-anatomy.PNG" alt="A Kafka message consisting of key, value, timestamp, compression type, and headers." width="600" height="400" loading="lazy"></p>
<p><em>A Kafka message consisting of key, value, timestamp, compression type, and headers</em></p>
<p>Every event in Kafka is, at its simplest, a key-value pair. These are serialized into binary, since Kafka itself handles arrays of bytes rather than complex language-specific objects.</p>
<p><strong>Keys</strong> are usually strings or integers and aren't unique for every message. Instead, they point to a particular entity in the system, such as a specific user, order, or device. Keys can be null, but when they are included they are used for dividing topics into partitions (more on partitions below).</p>
<p>The message <strong>value</strong> contains details about the event that happened. This could be as simple as a string or as complex as an object with many nested properties. Values can be null, but usually aren't.</p>
<p>By default, the <strong>timestamp</strong> records when the message was created. You can overwrite this if your event actually occurred earlier and you want to record that time instead.</p>
<p>Messages are usually small (less than 1 MB) and sent in a standard data format, such as JSON, Avro, or Protobuf. Even so, they can be compressed to save on data. The <strong>compression type</strong> can be set to <code>gzip</code>, <code>lz4</code>, <code>snappy</code>, <code>zstd</code>, or <code>none</code>.</p>
<p>Events can also optionally have <strong>headers</strong>, which are key-value pairs of strings containing metadata, such as where the event originated from or where you want it routed to.</p>
<p>Once a message is sent into a Kafka topic, it also receives a partition number and offset id (more about these later).</p>
<h3 id="heading-topics-in-kafka">Topics in Kafka</h3>
<p>Kafka stores messages in a <strong>topic</strong>, an ordered sequence of events, also called an event log.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/topic.PNG" alt="A Kafka topic containing messages, each with a unique offset." width="600" height="400" loading="lazy"></p>
<p><em>A Kafka topic containing messages, each with a unique offset</em></p>
<p>Different topics are identified by their names and will store different kinds of events. For example a social media application might have <code>posts</code>, <code>likes</code>, and <code>comments</code> topics to record every time a user creates a post, likes a post, or leaves a comment.</p>
<p>Multiple applications can write to and read from the same topic. An application might also read messages from one topic, filter or transform the data, and then write the result to another topic.</p>
<p>One important feature of topics is that they are append-only. When you write a message to a topic, it's added to the end of the log. Events in a topic are immutable. Once they're written to a topic, you can't change them.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/producer-to-topics-consumer-from-topics.PNG" alt="A Producer writing events to topics and a Consumer reading events from topics." width="600" height="400" loading="lazy"></p>
<p><em>A Producer writing events to topics and a Consumer reading events from topics</em></p>
<p>Unlike with messaging queues, reading an event from a topic doesn't delete it. Events can be read as often as needed, perhaps several times by multiple different applications.</p>
<p>Topics are also durable, holding onto messages for a specific period (by default 7 days) by saving them to physical storage on disk.</p>
<p>You can configure topics so that messages expire after a certain amount of time, or when a certain amount of storage is exceeded. You can even store messages indefinitely as long as you can pay for the storage costs.</p>
<h3 id="heading-partitions-in-kafka">Partitions in Kafka</h3>
<p>In order to help Kafka to scale, topics can be divided into <strong>partitions</strong>. This breaks up the event log into multiple logs, each of which lives on a separate node in the Kafka cluster. This means that the work of writing and storing messages can be spread across multiple machines.</p>
<p>When you create a topic, you specify the amount of partitions it has. The partitions are themselves numbered, starting at 0. When a new event is written to a topic, it's appended to one of the topic's partitions.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/partitioned-topic.PNG" alt="A topic divided into three partitions." width="600" height="400" loading="lazy"></p>
<p><em>A topic divided into three partitions</em></p>
<p>If messages have no key, they will be evenly distributed among partitions in a round robin manner: partition 0, then partition 1, then partition 2, and so on. This way, all partitions get an even share of the data but there's no guarantee about the ordering of messages.</p>
<p>Messages that have the same key will always be sent to the same partition, and in the same order. The key is run through a hashing function which turns it into an integer. This output is then used to select a partition.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/messages-with-without-keys.PNG" alt="Messages without keys being sent across partitions while messages with the same keys are sent to the same partition" width="600" height="400" loading="lazy"></p>
<p><em>Messages without keys are sent across partitions, while messages with the same keys are sent to the same partition</em></p>
<p>Messages within each partition are guaranteed to be ordered. For example, all messages with the same <code>customer_id</code> as their key will be sent to the same partition in the order in which Kafka received them.</p>
<h3 id="heading-offsets-in-kafka">Offsets in Kafka</h3>
<p>Each message in a partition gets an id that is an incrementing integer, called an <strong>offset</strong>. Offsets start at 0 and are incremented every time Kafka writes a message to a partition. This means that each message in a given partition has a unique offset.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/offsets.PNG" alt="Three partitions with offsets. Offsets are unique within a partition but not between partitions" width="600" height="400" loading="lazy"></p>
<p><em>Offsets are unique within a partition but not between partitions</em></p>
<p>Offsets are not reused, even when older messages get deleted. They continue to increment, giving each new message in the partition a unique id.</p>
<p>When data is read from a partition, it is read in order from the lowest existing offset upwards. We'll see more about offsets when we cover Kafka consumers.</p>
<h3 id="heading-brokers-in-kafka">Brokers in Kafka</h3>
<p>A single "server" running Kafka is called a <strong>broker</strong>. In reality, this might be a Docker container running in a virtual machine. But it can be a helpful mental image to think of brokers as individual servers.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/cluster-with-three-brokers.PNG" alt="A Kafka cluster made up of three brokers" width="600" height="400" loading="lazy"></p>
<p><em>A Kafka cluster made up of three brokers</em></p>
<p>Multiple brokers working together make up a Kafka cluster. There might be a handful of brokers in a cluster, or more than 100. When a client application connects to one broker, Kafka automatically connects it to every broker in the cluster.</p>
<p>By running as a cluster, Kafka becomes more scalable and fault-tolerant. If one broker fails, the others will take over its work to ensure there is no downtime or data loss.</p>
<p>Each broker manages a set of partitions and handles requests to write data to or read data from these partitions. Partitions for a given topic will be spread evenly across the brokers in a cluster to help with load balancing. Brokers also manage replicating partitions to keep their data backed up.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/brokers-with-partitions.PNG" alt="Partitions spread across brokers" width="600" height="400" loading="lazy"></p>
<p><em>Partitions spread across brokers</em></p>
<h3 id="heading-replication-in-kafka">Replication in Kafka</h3>
<p>To protect against data loss if a broker fails, Kafka writes the same data to copies of a partition on multiple brokers. This is called <strong>replication</strong>.</p>
<p>The main copy of a partition is called the leader, while the replicas are called followers.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/brokers-replication.PNG" alt="The data from the leader partition is copied to follower partitions on different brokers" width="600" height="400" loading="lazy"></p>
<p><em>The data from the leader partition is copied to follower partitions on different brokers</em></p>
<p>When a topic is created, you set a replication factor for it. This controls how many replicas get written to. A replication factor of three is common, meaning data gets written to one leader and replicated to two followers. So even if two brokers failed, your data would still be safe.</p>
<p>Whenever you write messages to a partition, you're writing to the leader partition. Kafka then automatically copies these messages to the followers. As such, the logs on the followers will have the same messages and offsets as on the leader.</p>
<p>Followers that are up to date with the leader are called <strong>In-Sync Replicas</strong> (ISRs). Kafka considers a message to be committed once a minimum number of replicas have saved it to their logs. You can configure this to get higher throughput at the expense of less certainty that a message has been backed up.</p>
<h3 id="heading-producers-in-kafka">Producers in Kafka</h3>
<p>Producers are client applications that write events to Kafka topics. These apps aren't themselves part of Kafka – you write them.</p>
<p>Usually you will use a library to help manage writing events to Kafka. There is an official client library for Java as well as dozens of community-supported libraries for languages such as Scala, JavaScript, Go, Rust, Python, C#, and C++.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/producer-writing-to-topics.PNG" alt="A Producer application writing to multiple topics" width="600" height="400" loading="lazy"></p>
<p><em>A Producer application writing to multiple topics</em></p>
<p>Producers are totally decoupled from consumers, which read from Kafka. They don't know about each other and their speed doesn't affect each other. Producers aren't affected if consumers fail, and the same is true for consumers.</p>
<p>If you need to, you could write an application that writes certain events to Kafka and reads other events from Kafka, making it both a producer and a consumer.</p>
<p>Producers take a key-value pair, generate a Kafka message, and then serialize it into binary for transmission across the network. You can adjust the configuration of producers to batch messages together based on their size or some fixed time limit to optimize writing messages to the Kafka brokers.</p>
<p>It's the producer that decides which partition of a topic to send each message to. Again, messages without keys will be distributed evenly among partitions, while messages with keys are all sent to the same partition.</p>
<h3 id="heading-consumers-in-kafka">Consumers in Kafka</h3>
<p>Consumers are client applications that read messages from topics in a Kafka cluster. Like with producers, you write these applications yourself and can make use of client libraries to support the programming language your application is built with.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/consumer-reading-from-topics.PNG" alt="A Consumer reading messages from multiple topics." width="600" height="400" loading="lazy"></p>
<p><em>A Consumer reading messages from multiple topics</em></p>
<p>Consumers can read from one or more partitions within a topic, and from one or more topics. Messages are read in order within a partition, from the lowest available offset to the highest. But if a consumer reads data from several partitions in the same topic, the message order <strong>between</strong> these partitions is not guaranteed.</p>
<p>For example, a consumer might read messages from partition 0, then partition 2, then partition 1, then back to partition 0. The messages from partition 0 will be read in order, but there might be messages from the other partitions mixed among them.</p>
<p>It's important to remember that reading a message does not delete it. The message is still available to be read by any other consumer that needs to access it. It's normal for multiple consumers to read from the same topic if they each have uses for the data in it.</p>
<p>By default, when a consumer starts up it will read from the current offset in a partition. But consumers can also be configured to go back and read from the oldest existing offset.</p>
<p>Consumers deserialize messages, converting them from binary into a collection of key-value pairs that your application can then work with. The format of a message should not change during a topic's lifetime or your producers and consumers won't be able to serialize and deserialize it correctly.</p>
<p>One thing to be aware of is that consumers request messages from Kafka, it doesn't push messages to them. This protects consumers from becoming overwhelmed if Kafka is handling a high volume of messages. If you want to scale consumers, you can run multiple instances of a consumer together in a <strong>consumer group</strong>.</p>
<h3 id="heading-consumer-groups-in-kafka">Consumer Groups in Kafka</h3>
<p>An application that reads from Kafka can create multiple instances of the same consumer to split up the work of reading from different partitions in a topic. These consumers work together as a <strong>consumer group</strong>.</p>
<p>When you create a consumer, you can assign it a group id. All consumers in a group will have the same group id.</p>
<p>You can create consumer instances in a group up to the number of partitions in a topic. So if you have a topic with 5 partitions, you can create up to 5 instances of the same consumer in a consumer group. If you ever have more consumers in a group than partitions, the extra consumer will remain idle.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/consumer-group.PNG" alt="Consumers in a consumer group reading messages from a topic's partitions" width="600" height="400" loading="lazy"></p>
<p><em>Consumers in a consumer group reading messages from a topic's partitions</em></p>
<p>If you add another consumer instance to a consumer group, Kafka will automatically redistribute the partitions among the consumers in a process called <strong>rebalancing</strong>.</p>
<p>Each partition is only assigned to one consumer in a group, but a consumer can read from multiple partitions. Also, multiple different consumer groups (meaning different applications) can read from the same topic at the same time.</p>
<p>Kafka brokers use an internal topic called <code>__consumer_offsets</code> to keep track of which messages a specific consumer group has successfully processed.</p>
<p>As a consumer reads from a partition, it regularly saves the offset it has read up to and sends this data to the broker it is reading from. This is called the <strong>consumer offset</strong> and is handled automatically by most client libraries.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/consumer-committing-offsets.PNG" alt="A Consumer committing the offsets it has read up to." width="600" height="400" loading="lazy"></p>
<p><em>A Consumer committing the offsets it has read up to</em></p>
<p>If a consumer crashes, the consumer offset helps the remaining consumers to know where to start from when they take over reading from the partition.</p>
<p>The same thing happens if a new consumer is added to the group. The consumer group rebalances, the new consumer is assigned a partition, and it picks up reading from the consumer offset of that partition.</p>
<h3 id="heading-kafka-zookeeper">Kafka Zookeeper</h3>
<p>One other topic that we briefly need to cover here is how Kafka clusters are managed. Currently this is usually done using <a target="_blank" href="https://zookeeper.apache.org/">Zookeeper</a>, a service for managing and synchronizing distributed systems. Like Kafka, it's maintained by the Apache Foundation.</p>
<p>Kafka uses Zookeeper to manage the brokers in a cluster, and requires Zookeeper even if you're running a Kafka cluster with only one broker.</p>
<p>Recently, a proposal has been accepted to remove Zookeeper and have Kafka manage itself (<a target="_blank" href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-500%3A+Replace+ZooKeeper+with+a+Self-Managed+Metadata+Quorum">KIP-500</a>), but this is not yet widely used in production.</p>
<p>Zookeeper keeps track of things like:</p>
<ul>
<li><p>Which brokers are part of a Kafka cluster</p>
</li>
<li><p>Which broker is the leader for a given partition</p>
</li>
<li><p>How topics are configured, such as the number of partitions and the location of replicas</p>
</li>
<li><p>Consumer groups and their members</p>
</li>
<li><p>Access Control Lists – who is allowed to write to and read from each topic</p>
</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/zookeeper-ensemble-1.PNG" alt="A Zookeeper ensemble managing the brokers in a Kafka cluster." width="600" height="400" loading="lazy"></p>
<p><em>A Zookeeper ensemble managing the brokers in a Kafka cluster</em></p>
<p>Zookeeper itself runs as a cluster called an ensemble. This means that Zookeeper can keep working even if one node in the cluster fails. New data gets written to the ensemble's leader and replicated to the followers. Your Kafka brokers can read this data from any of the Zookeeper nodes in the ensemble.</p>
<p>Now that you understand the main concepts behind Kafka, let's get some hands-on practice working with Kafka.</p>
<p>You're going to install Kafka on your own computer, practice interacting with Kafka brokers from the command line, and then build a simple producer and consumer application with Java.</p>
<h2 id="heading-how-to-install-kafka-on-your-computer">How to Install Kafka on Your Computer</h2>
<p>At the time of writing this guide, the latest stable version of Kafka is 3.3.1. Check <a target="_blank" href="https://kafka.apache.org/downloads">kafka.apache.org/downloads</a> to see if there is a more recent stable version. If there is, you can replace "3.3.1" with the latest stable version in all of the following instructions.</p>
<h3 id="heading-install-kafka-on-macos">Install Kafka on macOS</h3>
<p>If you're using macOS, I recommend using Homebrew to install Kafka. It will make sure you have Java installed before it installs Kafka.</p>
<p>If you don't already have Homebrew installed, install it by following the instructions at <a target="_blank" href="https://brew.sh/">brew.sh</a>.</p>
<p>Next, run <code>brew install kafka</code> in a terminal. This will install Kafka's binaries at <code>usr/local/bin</code>.</p>
<p>Finally, run <code>kafka-topics --version</code> in a terminal and you should see <code>3.3.1</code>. If you do, you're all set.</p>
<p>To make it easier to work with Kafka, you can add Kafka to the <code>PATH</code> environment variable. Open your <code>~/.bashrc</code> (if using Bash) or <code>~/.zshrc</code> (if using Zsh) and add the following line, replacing <code>USERNAME</code> with your username:</p>
<pre><code class="lang-python">PATH=<span class="hljs-string">"$PATH:/Users/USERNAME/kafka_2.13-3.3.1/bin"</span>
</code></pre>
<p>You'll need to close your terminal for this change to take effect.</p>
<p>Now, if you run <code>echo $PATH</code> you should see that the Kafka <code>bin</code> directory has been added to your path.</p>
<h3 id="heading-install-kafka-on-windows-wsl2-and-linux">Install Kafka on Windows (WSL2) and Linux</h3>
<p>Kafka isn't natively supported on Windows, so you will need to use either WSL2 or Docker. I'm going to show you WSL2 since it's the same steps as Linux.</p>
<p>To set up WSL2 on Widows, follow <a target="_blank" href="https://learn.microsoft.com/en-us/windows/wsl/install">the instructions in the official docs</a>.</p>
<p>From here on, the instructions are the same for both WSL2 and Linux.</p>
<p>First, install Java 11 by running the following commands:</p>
<pre><code class="lang-python">wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add - 

sudo add-apt-repository <span class="hljs-string">'deb https://apt.corretto.aws stable main'</span>

sudo apt-get update; sudo apt-get install -y java<span class="hljs-number">-11</span>-amazon-corretto-jdk
</code></pre>
<p>Once this has finished, run <code>java -version</code> and you should see something like:</p>
<pre><code class="lang-python">openjdk version <span class="hljs-string">"11.0.17"</span> <span class="hljs-number">2022</span><span class="hljs-number">-10</span><span class="hljs-number">-18</span> LTS
OpenJDK Runtime Environment Corretto<span class="hljs-number">-11.0</span><span class="hljs-number">.17</span><span class="hljs-number">.8</span><span class="hljs-number">.1</span> (build <span class="hljs-number">11.0</span><span class="hljs-number">.17</span>+<span class="hljs-number">8</span>-LTS)
OpenJDK <span class="hljs-number">64</span>-Bit Server VM Corretto<span class="hljs-number">-11.0</span><span class="hljs-number">.17</span><span class="hljs-number">.8</span><span class="hljs-number">.1</span> (build <span class="hljs-number">11.0</span><span class="hljs-number">.17</span>+<span class="hljs-number">8</span>-LTS, mixed mode)
</code></pre>
<p>From your root directory, download Kafka with the following command:</p>
<pre><code class="lang-bash">wget https://archive.apache.org/dist/kafka/3.3.1/kafka_2.13-3.3.1.tgz
</code></pre>
<p>The <code>2.13</code> means it is using version <code>2.13</code> of Scala, while <code>3.3.1</code> refers to the Kafka version.</p>
<p>Extract the contents of the download with:</p>
<pre><code class="lang-bash">tar xzf kafka_2.13-3.3.1.tgz
</code></pre>
<p>If you run <code>ls</code>, you'll now see <code>kafka_2.13-3.3.1</code> in your root directory.</p>
<p>To make it easier to work with Kafka, you can add Kafka to the <code>PATH</code> environment variable. Open your <code>~/.bashrc</code> (if using Bash) or <code>~/.zshrc</code> (if using Zsh) and add the following line, replacing <code>USERNAME</code> with your username:</p>
<pre><code class="lang-python">PATH=<span class="hljs-string">"$PATH:home/USERNAME/kafka_2.13-3.3.1/bin"</span>
</code></pre>
<p>You'll need to close your terminal for this change to take effect.</p>
<p>Now, if you run <code>echo $PATH</code> you should see that the Kafka <code>bin</code> directory has been added to your path.</p>
<p>Run <code>kafka-topics.sh --version</code> in a terminal and you should see <code>3.3.1</code>. If you do, you're all set.</p>
<h2 id="heading-how-to-start-zookeeper-and-kafka">How to Start Zookeeper and Kafka</h2>
<p>Since Kafka uses Zookeeper to manage clusters, you need to start Zookeeper before you start Kafka.</p>
<h3 id="heading-how-to-start-kafka-on-macos">How to Start Kafka on macOS</h3>
<p>In one terminal window, start Zookeeper with:</p>
<pre><code class="lang-bash">/usr/<span class="hljs-built_in">local</span>/bin/zookeeper-server-start /usr/<span class="hljs-built_in">local</span>/etc/zookeeper/zoo.cfg
</code></pre>
<p>In another terminal window, start Kafka with:</p>
<pre><code class="lang-bash">/usr/<span class="hljs-built_in">local</span>/bin/kafka-server-start /usr/<span class="hljs-built_in">local</span>/etc/kafka/server.properties
</code></pre>
<p>While using Kafka, you need to keep both these terminal windows open. Closing them will shut down Kafka.</p>
<h3 id="heading-how-to-start-kafka-on-windows-wsl2-and-linux">How to Start Kafka on Windows (WSL2) and Linux</h3>
<p>In one terminal window, start Zookeeper with:</p>
<pre><code class="lang-bash">~/kafka_2.13-3.3.1/bin/zookeeper-server-start.sh ~/kafka_2.13-3.3.1/config/zookeeper.properties
</code></pre>
<p>In another terminal window, start Kafka with:</p>
<pre><code class="lang-bash">~/kafka_2.13-3.3.1/bin/kafka-server-start.sh ~/kafka_2.13-3.3.1/config/server.properties
</code></pre>
<p>While using Kafka, you need to keep both these terminal windows open. Closing them will shut down Kafka.</p>
<p>Now that you have Kafka installed and running on your machine, it's time to get some hands-on practice.</p>
<h2 id="heading-the-kafka-cli">The Kafka CLI</h2>
<p>When you install Kafka, it comes with a Command Line Interface (CLI) that lets you create and manage topics, as well as produce and consume events.</p>
<p>First, make sure Zookeeper and Kafka are running in two terminal windows.</p>
<p>In a third terminal window, run <code>kafka-topics.sh</code> (on WSL2 or Linux) or <code>kafka-topics</code> (on macOS) to make sure the CLI is working. You'll see a list of all the options you can pass to the CLI.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-topics-sh.PNG" alt="A terminal displaying kafka-topics options." width="600" height="400" loading="lazy"></p>
<p><em>kafka-topics options</em></p>
<p><strong>Note:</strong> When working with the Kafka CLI, the command will be <code>kafka-topics.sh</code> on WSL2 and Linux. It will be <code>kafka-topics.sh</code> on macOS if you directly installed the Kafka binaries and <code>kafka-topics</code> if you used Homebrew. So if you're using Homebrew, remove the <code>.sh</code> extension from the example commands in this section.</p>
<h3 id="heading-how-to-list-topics">How to List Topics</h3>
<p>To see the topics available on the Kafka broker on your local machine, use:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --list
</code></pre>
<p>This means "Connect to the Kafka broker running on localhost:9092 and list all topics there". <code>--bootstrap-server</code> refers to the Kafka broker you are trying to connect to and <code>localhost:9092</code> is the IP address it's running at. You won't see any output since you haven't created any topics yet.</p>
<h3 id="heading-how-to-create-a-topic">How to Create a Topic</h3>
<p>To create a topic (with the default replication factor and number of partitions), use the <code>--create</code> and <code>--topic</code> options and pass them a topic name:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my_first_topic
</code></pre>
<p>If you use an <code>_</code> or <code>.</code> in your topic name, you will see the following warning:</p>
<pre><code class="lang-python">WARNING: Due to limitations <span class="hljs-keyword">in</span> metric names, topics <span class="hljs-keyword">with</span> a period (<span class="hljs-string">'.'</span>) <span class="hljs-keyword">or</span> underscore (<span class="hljs-string">'_'</span>) could collide. To avoid issues it <span class="hljs-keyword">is</span> best to use either, but <span class="hljs-keyword">not</span> both.
</code></pre>
<p>Since Kafka could confuse <code>my.first.topic</code> with <code>my_first_topic</code>, it's best to only use either underscores or periods when naming topics.</p>
<h3 id="heading-how-to-describe-topics">How to Describe Topics</h3>
<p>To describe the topics on a broker, use the <code>--describe</code> option:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --describe
</code></pre>
<p>This will print the details of all the topics on this broker, including the number of partitions and their replication factor. By default, these will both be set to <code>1</code>.</p>
<p>If you add the <code>--topic</code> option and the name of a topic, it will describe only that topic:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --describe --topic my_first_topic
</code></pre>
<h3 id="heading-how-to-partition-a-topic">How to Partition a Topic</h3>
<p>To create a topic with multiple partitions, use the <code>--partitions</code> option and pass it a number:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my_second_topic --partitions 3
</code></pre>
<h3 id="heading-how-to-set-a-replication-factor">How to Set a Replication Factor</h3>
<p>To create a topic with a replication factor higher than the default, use the <code>--replication-factor</code> option and pass it a number:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --create --topic my_third_topic --partitions 3 --replication-factor 3
</code></pre>
<p>You should get the following error:</p>
<pre><code class="lang-bash">ERROR org.apache.kafka.common.errors.InvalidReplicationFactorException: Replication factor: 2 larger than available brokers: 1.
</code></pre>
<p>Since you're only running one Kafka broker on your machine, you can't set a replication factor higher than one. If you were running a cluster with multiple brokers, you could set a replication factor as high as the total number of brokers.</p>
<h3 id="heading-how-to-delete-a-topic">How to Delete a Topic</h3>
<p>To delete a topic, use the <code>--delete</code> option and specify a topic with the <code>--topic</code> option:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic my_first_topic
</code></pre>
<p>You won't get any output to say the topic was deleted but you can check using <code>--list</code> or <code>--describe</code>.</p>
<h3 id="heading-how-to-use-kafka-console-producer">How to Use <code>kafka-console-producer</code></h3>
<p>You can produce messages to a topic from the command line using <code>kafka-console-producer</code>.</p>
<p>Run <code>kafka-console-producer.sh</code> to see the options you can pass to it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-console-producer.PNG" alt="Terminal showing kafka-console-producer options." width="600" height="400" loading="lazy"></p>
<p><em>kafka-console-producer options</em></p>
<p>To create a producer connected to a specific topic, run:</p>
<pre><code class="lang-bash">kafka-console-producer.sh --bootstrap-server localhost:9092 --topic TOPIC_NAME
</code></pre>
<p>Let's produce messages to the <code>my_first_topic</code> topic.</p>
<pre><code class="lang-bash">kafka-console-producer.sh --bootstrap-server localhost:9092 --topic my_first_topic
</code></pre>
<p>Your prompt will change and you will be able to type text. Press <code>enter</code> to send that message. You can keep sending messages until you press <code>ctrl</code> + <code>c</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-console-producer-sample-messages.PNG" alt="Sending messages using kafka-console-producer" width="600" height="400" loading="lazy"></p>
<p><em>Sending messages using kafka-console-producer</em></p>
<p>If you produce messages to a topic that doesn't exist, you'll get a warning, but the topic will be created and the messages will still get sent. It's better to create a topic in advance, however, so you can specify partitions and replication.</p>
<p>By default, the messages sent from <code>kafka-console-producer</code> have their keys set to <code>null</code>, and so they will be evenly distributed to all partitions.</p>
<p>You can set a key by using the <code>--property</code> option to set <code>parse.key</code> to be true and providing a key separator, such as <code>:</code></p>
<p>For example, we can create a <code>books</code> topic and use the books' genre as a key.</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --topic books --create

kafka-console-producer.sh --bootstrap-server localhost:9092 --topic books --property parse.key=<span class="hljs-literal">true</span> --property key.separator=:
</code></pre>
<p>Now you can enter keys and values in the format <code>key:value</code>. Anything to the left of the key separator will be interpreted as a message key, anything to the right as a message value.</p>
<pre><code class="lang-python">science_fiction:All Systems Red
fantasy:Uprooted
horror:Mexican Gothic
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/producing-messages-with-keys.PNG" alt="Producing messages with keys and values." width="600" height="400" loading="lazy"></p>
<p><em>Producing messages with keys and values</em></p>
<p>Now that you've produced messages to a topic from the command line, it's time to consume those messages from the command line.</p>
<h3 id="heading-how-to-use-kafka-console-consumer">How to Use <code>kafka-console-consumer</code></h3>
<p>You can consumer messages from a topic from the command line using <code>kafka-console-consumer</code>.</p>
<p>Run <code>kafka-console-consumer.sh</code> to see the options you can pass to it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-console-consumer.PNG" alt="Terminal showing kafka-console-consumer options" width="600" height="400" loading="lazy"></p>
<p><em>kafka-console-consumer options</em></p>
<p>To create a consumer, run:</p>
<pre><code class="lang-bash">kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic TOPIC_NAME
</code></pre>
<p>When you start a consumer, by default it will read messages as they are written to the end of the topic. It won't read messages that were previously sent to the topic.</p>
<p>If you want to read the messages you already sent to a topic, use the <code>--from-beginning</code> option to read from the beginning of the topic:</p>
<pre><code class="lang-bash">kafka-console-consumer --bootstrap-server localhost:9092 --topic my_first_topic --from-beginning
</code></pre>
<p>The messages might appear "out of order". Remember, messages are ordered <strong>within</strong> a partition but ordering can't be guaranteed <strong>between</strong> partitions. If you don't set a key, they will be sent round robin between partitions and ordering isn't guaranteed.</p>
<p>You can display additional information about messages, such as their key and timestamp, by using the <code>--property</code> option and setting the <code>print</code> property to true.</p>
<p>Use the <code>--formatter</code> option to set the message formatter and the <code>--property</code> option to select which message properties to print.</p>
<pre><code class="lang-bash">kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic my_first_topic --from-beginning --formatter kafka.tools.DefaultMessageFormatter --property print.timestamp=<span class="hljs-literal">true</span> --property print.key=<span class="hljs-literal">true</span> --property print.value=<span class="hljs-literal">true</span>
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/consuming-messages-from-a-topic-1.PNG" alt="Consuming messages from a topic" width="600" height="400" loading="lazy"></p>
<p><em>Consuming messages from a topic</em></p>
<p>We get the messages' timestamp, key, and value. Since we didn't assign any keys when we sent these messages to <code>my_first_topic</code>, their <code>key</code> is <code>null</code>.</p>
<h3 id="heading-how-to-use-kafka-consumer-groups">How to Use <code>kafka-consumer-groups</code></h3>
<p>You can run consumers in a consumer group using the Kafka CLI. To view the documentation for this, run:</p>
<pre><code class="lang-bash">kafka-consumer-groups.sh
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/kafka-consumer-groups.PNG" alt="kafka-consumer-groups options" width="600" height="400" loading="lazy"></p>
<p><em>kafka-consumer-groups options</em></p>
<p>First, create a topic with three partitions. Each consumer in a group will consume from one partition. If there are more consumers than partitions, any extra consumers will be idle.</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --topic fantasy_novels --create --partitions 3
</code></pre>
<p>You add a consumer to a group when you create it using the <code>--group</code> option. If you run the same command multiple times with the same group name, each new consumer will be added to the group.</p>
<p>To create the first consumer in your consumer group, run:</p>
<pre><code class="lang-bash">kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic fantasy_novels --group fantasy_consumer_group
</code></pre>
<p>Next, open two new terminal windows and run the same command again to add a second and third consumer to the consumer group.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/three-consumers-in-group.PNG" alt="Three consumers running in a consumer group." width="600" height="400" loading="lazy"></p>
<p><em>Three consumers running in a consumer group</em></p>
<p>In a different terminal window, create a producer and send a few messages with keys to the topic.</p>
<p><strong>Note:</strong> Since Kafka 2.4, Kafka will send messages in batches to one "sticky" partition for better performance. In order to demonstrate messages being sent round robin between partitions (without sending a large volume of messages), we can set the partitioner to <code>RoundRobinPartitioner</code>.</p>
<pre><code class="lang-bash">kafka-console-producer.sh --bootstrap-server localhost:9092 --topic fantasy_novels --property parse.key=<span class="hljs-literal">true</span> --property key.separator=: --property partitioner.class=org.apache.kafka.clients.producer.RoundRobinPartitioner

tolkien:The Lord of the Rings
le_guin:A Wizard of Earthsea
leckie:The Raven Tower
de_bodard:The House of Shattered Wings
okorafor:Who Fears Death
liu:The Grace of Kings
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/messages-spread-across-consumer-group.PNG" alt="Messages spread between consumers in a consumer group" width="600" height="400" loading="lazy"></p>
<p><em>Messages spread between consumers in a consumer group</em></p>
<p>If you stop one of the consumers, the consumer group will rebalance and future messages will be sent to the remaining consumers.</p>
<p>Now that you have some experience working with Kafka from the command line, the next step is to build a small application that connects to Kafka.</p>
<h2 id="heading-how-to-build-a-kafka-client-app-with-java">How to Build a Kafka Client App with Java</h2>
<p>We're going to build a simple Java app that both produces messages to and consumes messages from Kafka. For this we'll use the official Kafka Java client.</p>
<p>If at any point you get stuck, the full code for this project is <a target="_blank" href="https://github.com/gerhynes/kafka-java-app">available on GitHub</a>.</p>
<h3 id="heading-preliminaries">Preliminaries</h3>
<p>First of all, make sure you have Java (at least JDK 11) and Kafka installed.</p>
<p>We're going to send messages about characters from <em>The Lord of the Rings</em>. So let's create a topic for these messages with three partitions.</p>
<p>From the command line, run:</p>
<pre><code class="lang-bash">kafka-topics.sh --bootstrap-server localhost:9092 --create --topic lotr_characters --partitions 3
</code></pre>
<h3 id="heading-how-to-set-up-the-project">How to Set Up the Project</h3>
<p>I recommend using IntelliJ for Java projects, so go ahead and install the Community Edition if you don't already have it. You can download it from <a target="_blank" href="https://www.jetbrains.com/idea/">jetbrains.com/idea</a></p>
<p>In Intellij, select <code>File</code>, <code>New</code>, and <code>Project</code>.</p>
<p>Give your project a name and select a location for it on your computer. Make sure you have selected Java as the language, Maven as the build system, and that the JDK is at least Java 11. Then click <code>Create</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/new-maven-project.PNG" alt="Setting up a Maven project in IntelliJ" width="600" height="400" loading="lazy"></p>
<p><em>Setting up a Maven project in IntelliJ</em></p>
<p><strong>Note:</strong> If you're on Windows, IntelliJ can't use a JDK installed on WSL. To install Java on the Windows side of things, go to <a target="_blank" href="https://docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list.html">docs.aws.amazon.com/corretto/latest/corretto-11-ug/downloads-list</a> and download the Windows installer. Follow the installation steps, open a command prompt, and run <code>java -version</code>. You should see something like:</p>
<pre><code class="lang-python">openjdk version <span class="hljs-string">"11.0.18"</span> <span class="hljs-number">2023</span><span class="hljs-number">-01</span><span class="hljs-number">-17</span> LTS
OpenJDK Runtime Environment Corretto<span class="hljs-number">-11.0</span><span class="hljs-number">.18</span><span class="hljs-number">.10</span><span class="hljs-number">.1</span> (build <span class="hljs-number">11.0</span><span class="hljs-number">.18</span>+<span class="hljs-number">10</span>-LTS)
OpenJDK <span class="hljs-number">64</span>-Bit Server VM Corretto<span class="hljs-number">-11.0</span><span class="hljs-number">.18</span><span class="hljs-number">.10</span><span class="hljs-number">.1</span> (build <span class="hljs-number">11.0</span><span class="hljs-number">.18</span>+<span class="hljs-number">10</span>-LTS, mixed mode)
</code></pre>
<p>Once your Maven project finishes setting up, run the <code>Main</code> class to see "Hello world!" and make sure everything worked.</p>
<h3 id="heading-how-to-install-the-dependencies">How to Install the Dependencies</h3>
<p>Next, we're going to install our dependencies. Open up <code>pom.xml</code> and inside the <code>&lt;project&gt;</code> element, create a <code>&lt;dependencies&gt;</code> element.</p>
<p>We're going to use the Java Kafka client for interacting with Kafka and SLF4J for logging, so add the following inside your <code>&lt;dependencies&gt;</code> element:</p>
<pre><code class="lang-xml"><span class="hljs-comment">&lt;!-- https://mvnrepository.com/artifact/org.apache.kafka/kafka-clients --&gt;</span>  
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.kafka<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>kafka-clients<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.3.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>  
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>  
<span class="hljs-comment">&lt;!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --&gt;</span>  
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.slf4j<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>slf4j-api<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>2.0.6<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>  
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>  
<span class="hljs-comment">&lt;!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple --&gt;</span>  
<span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.slf4j<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>slf4j-simple<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span>  
    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>2.0.6<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span>  
<span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span>
</code></pre>
<p>The package names and version numbers might be red, meaning you haven't downloaded them yet. If this happens, click on <code>View</code>, <code>Tool Windows</code>, and <code>Maven</code> to open the Maven menu. Click on the <code>Reload All Maven Projects</code> icon and Maven will install these dependencies.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/reload-maven.png" alt="Reloading Maven dependencies in IntelliJ" width="600" height="400" loading="lazy"></p>
<p><em>Reloading Maven dependencies in IntelliJ</em></p>
<p>Create a <code>HelloKafka</code> class in the same directory as your <code>Main</code> class and give it the following contents:</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> org.example;

<span class="hljs-keyword">import</span> org.slf4j.Logger;  
<span class="hljs-keyword">import</span> org.slf4j.LoggerFactory;  

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HelloKafka</span> </span>{  
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Logger log = LoggerFactory.getLogger(HelloKafka.class);  

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{  
        log.info(<span class="hljs-string">"Hello Kafka"</span>);  
    }  
}
</code></pre>
<p>To make sure your dependencies are installed, run this class and you should see <code>[main] INFO org.example.HelloKafka - Hello Kafka</code> printed to the IntelliJ console.</p>
<h3 id="heading-how-to-create-a-kafka-producer">How to Create a Kafka Producer</h3>
<p>Next, we're going to create a <code>Producer</code> class. You can call this whatever you want as long as it doesn't clash with another class. So don't use <code>KafkaProducer</code> as you'll need that class in a minute.</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> org.example;  

<span class="hljs-keyword">import</span> org.slf4j.Logger;  
<span class="hljs-keyword">import</span> org.slf4j.LoggerFactory;  

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Producer</span> </span>{  
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Logger log = LoggerFactory.getLogger(KafkaProducer.class);  

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{  
        log.info(<span class="hljs-string">"This class will produce messages to Kafka"</span>);  
    }  
}
</code></pre>
<p>All of our Kafka-specific code is going to go inside this class's <code>main()</code> method.</p>
<p>The first thing we need to do is configure a few properties for the producer. Add the following inside the <code>main()</code> method:</p>
<pre><code class="lang-java">Properties properties = <span class="hljs-keyword">new</span> Properties(); 

properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, <span class="hljs-string">"localhost:9092"</span>);  
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());  
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
</code></pre>
<p><code>Properties</code> stores a set of properties as pairs of strings. The ones we're using are:</p>
<ul>
<li><p><code>ProducerConfig.BOOTSTRAP_SERVERS_CONFIG</code> which specifies the IP address to use to access the Kafka cluster</p>
</li>
<li><p><code>ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG</code> which specifies the serializer to use for message keys</p>
</li>
<li><p><code>ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG</code> which specifies the serializer to use for message values</p>
</li>
</ul>
<p>We're going to connect to our local Kafka cluster running on <code>localhost:9092</code>, and use the <code>StringSerializer</code> since both our keys and values will be strings.</p>
<p>Now we can create our producer and pass it the configuration properties.</p>
<pre><code class="lang-java">KafkaProducer&lt;String, String&gt; producer = <span class="hljs-keyword">new</span> KafkaProducer&lt;&gt;(properties);
</code></pre>
<p>To send a message, we need to create a <code>ProducerRecord</code> and pass it to our producer. <code>ProducerRecord</code> contains a topic name, and optionally a key, value, and partition number.</p>
<p>We're going to create the <code>ProducerRecord</code> with the topic to use, the message's key, and the message's value.</p>
<pre><code class="lang-java">ProducerRecord&lt;String, String&gt; producerRecord = <span class="hljs-keyword">new</span> ProducerRecord&lt;&gt;(<span class="hljs-string">"lotr_characters"</span>, <span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Bilbo"</span>);
</code></pre>
<p>We can now use the producer's <code>send()</code> method to send the message to Kafka.</p>
<pre><code class="lang-java">producer.send(producerRecord);
</code></pre>
<p>Finally, we need to call the <code>close()</code> method to stop the producer. This method handles any messages currently being processed by <code>send()</code> and then closes the producer.</p>
<pre><code class="lang-java">producer.close();
</code></pre>
<p>Now it's time to run our producer. <strong>Make sure you have Zookeeper and Kafka running.</strong> Then run the <code>main()</code> method of the <code>Producer</code> class.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/java-producer-single-message.PNG" alt="Sending a message from a producer in a Java Kafka client app." width="600" height="400" loading="lazy"></p>
<p><em>Sending a message from a producer in a Java Kafka client app</em></p>
<p><strong>Note:</strong> On Windows, your producer might not be able to connect to a Kafka broker running on WSL. To fix this, you're going to need to do the following:</p>
<ul>
<li><p>In a WSL terminal, navigate to Kafka's config folder: <code>cd ~/kafka_2.13-3.3.1/config/</code></p>
</li>
<li><p>Open <code>server.properties</code>, for example with Nano: <code>nano server.properties</code></p>
</li>
<li><p>Uncomment <code>#listeners=PLAINTEXT//:9092</code></p>
</li>
<li><p>Replace it with <code>listeners=PLAINTEXT//[::1]:9092</code></p>
</li>
<li><p>In your <code>Producer</code> class, replace <code>"localhost:9092"</code> with <code>"[::1]:9092"</code></p>
</li>
</ul>
<p><code>[::1]</code>, or <code>0:0:0:0:0:0:0:1</code>, refers to the loopback address (or localhost) in IPv6. This is equivalent to <code>127.0.0.1</code> in IPv4.</p>
<p>If you change <code>listeners</code>, when you try to access the Kafka broker from the command line you'll also have to use the new IP address, so use <code>--bootstrap-server ::1:9092</code> instead of <code>--bootstrap-server localhost:9092</code> and it should work.</p>
<p>We can now check that <code>Producer</code> worked by using <code>kafka-console-consumer</code> in another terminal window to read from the <code>lotr_characters</code> topic and see the message printed to the console.</p>
<pre><code class="lang-bash">kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic lotr_characters --from-beginning
</code></pre>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/consumer-reading-single-message.PNG" alt="kafka-console-consumer reading the message sent by the producer in our Java app" width="600" height="400" loading="lazy"></p>
<p><em>kafka-console-consumer reading the message sent by the producer in our Java app</em></p>
<h3 id="heading-how-to-send-multiple-messages-and-use-callbacks">How to Send Multiple Messages and Use Callbacks</h3>
<p>So far we're only sending one message. If we update <code>Producer</code> to send multiple messages, we'll be able to see how keys are used to divide messages between partitions. We can also take this opportunity to use a callback to view the sent message's metadata.</p>
<p>To do this, we're going to loop over a collection of characters to generate our messages.</p>
<p>So replace this:</p>
<pre><code class="lang-java">ProducerRecord&lt;String, String&gt; producerRecord = <span class="hljs-keyword">new</span> ProducerRecord&lt;&gt;(<span class="hljs-string">"lotr_characters"</span>, <span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Bilbo"</span>);  

producer.send(producerRecord);
</code></pre>
<p>with this:</p>
<pre><code class="lang-java">HashMap&lt;String, String&gt; characters = <span class="hljs-keyword">new</span> HashMap&lt;String, String&gt;();  
characters.put(<span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Frodo"</span>);  
characters.put(<span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Sam"</span>);  
characters.put(<span class="hljs-string">"elves"</span>, <span class="hljs-string">"Galadriel"</span>);  
characters.put(<span class="hljs-string">"elves"</span>, <span class="hljs-string">"Arwen"</span>);
characters.put(<span class="hljs-string">"humans"</span>, <span class="hljs-string">"Éowyn"</span>);  
characters.put(<span class="hljs-string">"humans"</span>, <span class="hljs-string">"Faramir"</span>);

<span class="hljs-keyword">for</span> (HashMap.Entry&lt;String, String&gt; character : characters.entrySet()) {  
    ProducerRecord&lt;String, String&gt; producerRecord = <span class="hljs-keyword">new</span> ProducerRecord&lt;&gt;(<span class="hljs-string">"lotr_characters"</span>, character.getKey(), character.getValue());  

    producer.send(producerRecord, (RecordMetadata recordMetadata, Exception err) -&gt; {  
        <span class="hljs-keyword">if</span> (err == <span class="hljs-keyword">null</span>) {  
            log.info(<span class="hljs-string">"Message received. \n"</span> +  
                    <span class="hljs-string">"topic ["</span> + recordMetadata.topic() + <span class="hljs-string">"]\n"</span> +  
                    <span class="hljs-string">"partition ["</span> + recordMetadata.partition() + <span class="hljs-string">"]\n"</span> +  
                    <span class="hljs-string">"offset ["</span> + recordMetadata.offset() + <span class="hljs-string">"]\n"</span> +  
                    <span class="hljs-string">"timestamp ["</span> + recordMetadata.timestamp() + <span class="hljs-string">"]"</span>);  
        } <span class="hljs-keyword">else</span> {  
            log.error(<span class="hljs-string">"An error occurred while producing messages"</span>, err);  
        }  
    });  
}
</code></pre>
<p>Here, we're iterating over the collection, creating a <code>ProducerRecord</code> for each entry, and passing the record to <code>send()</code>. Behind the scenes, Kafka will batch these messages together to make fewer network requests. <code>send()</code> can also take a callback as a second argument. We're going to pass it a lambda which will run code when the <code>send()</code> request completes.</p>
<p>If the request completed successfully, we get back a <code>RecordMetadata</code> object with metadata about the message, which we can use to see things such as the partition and offset the message ended up in.</p>
<p>If we get back an exception, we could handle it by retrying to send the message, or alerting our application. In this case, we're just going to log the exception.</p>
<p>Run the <code>main()</code> method of the <code>Producer</code> class and you should see the message metadata get logged.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/java-producer.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The full code for the <code>Producer</code> class should now be:</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> org.example;  

<span class="hljs-keyword">import</span> org.apache.kafka.clients.producer.KafkaProducer;  
<span class="hljs-keyword">import</span> org.apache.kafka.clients.producer.ProducerConfig;  
<span class="hljs-keyword">import</span> org.apache.kafka.clients.producer.ProducerRecord;  
<span class="hljs-keyword">import</span> org.apache.kafka.clients.producer.RecordMetadata;  
<span class="hljs-keyword">import</span> org.apache.kafka.common.serialization.StringSerializer;  
<span class="hljs-keyword">import</span> org.slf4j.Logger;  
<span class="hljs-keyword">import</span> org.slf4j.LoggerFactory;  

<span class="hljs-keyword">import</span> java.util.HashMap;  
<span class="hljs-keyword">import</span> java.util.Properties;  

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Producer</span> </span>{  
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Logger log = LoggerFactory.getLogger(Producer.class);  

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{  
        log.info(<span class="hljs-string">"This class produces messages to Kafka"</span>);  

        Properties properties = <span class="hljs-keyword">new</span> Properties();
        properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, <span class="hljs-string">"localhost:9092"</span>); 
        properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());  
        properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());  

        KafkaProducer&lt;String, String&gt; producer = <span class="hljs-keyword">new</span> KafkaProducer&lt;&gt;(properties);  

        HashMap&lt;String, String&gt; characters = <span class="hljs-keyword">new</span> HashMap&lt;String, String&gt;();  
        characters.put(<span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Frodo"</span>);  
        characters.put(<span class="hljs-string">"hobbits"</span>, <span class="hljs-string">"Sam"</span>);  
        characters.put(<span class="hljs-string">"elves"</span>, <span class="hljs-string">"Galadriel"</span>);  
        characters.put(<span class="hljs-string">"elves"</span>, <span class="hljs-string">"Arwen"</span>);
        characters.put(<span class="hljs-string">"humans"</span>, <span class="hljs-string">"Éowyn"</span>);  
        characters.put(<span class="hljs-string">"humans"</span>, <span class="hljs-string">"Faramir"</span>); 

        <span class="hljs-keyword">for</span> (HashMap.Entry&lt;String, String&gt; character : characters.entrySet()) {  
            ProducerRecord&lt;String, String&gt; producerRecord = <span class="hljs-keyword">new</span> ProducerRecord&lt;&gt;(<span class="hljs-string">"lotr_characters"</span>, character.getKey(), character.getValue());  

            producer.send(producerRecord, (RecordMetadata recordMetadata, Exception err) -&gt; {  
                <span class="hljs-keyword">if</span> (err == <span class="hljs-keyword">null</span>) {  
                    log.info(<span class="hljs-string">"Message received. \n"</span> +  
                            <span class="hljs-string">"topic ["</span> + recordMetadata.topic() + <span class="hljs-string">"]\n"</span> +  
                            <span class="hljs-string">"partition ["</span> + recordMetadata.partition() + <span class="hljs-string">"]\n"</span> +  
                            <span class="hljs-string">"offset ["</span> + recordMetadata.offset() + <span class="hljs-string">"]\n"</span> +  
                            <span class="hljs-string">"timestamp ["</span> + recordMetadata.timestamp() + <span class="hljs-string">"]"</span>);  
                } <span class="hljs-keyword">else</span> {  
                    log.error(<span class="hljs-string">"An error occurred while producing messages"</span>, err);  
                }  
            });  
        }
        producer.close();  
    }  
}
</code></pre>
<p>Next, we're going to create a consumer to read these messages from Kafka.</p>
<h3 id="heading-how-to-create-a-kafka-consumer">How to Create a Kafka Consumer</h3>
<p>First, create a <code>Consumer</code> class. Again, you can call it whatever you want, but don't call it <code>KafkaConsumer</code> as you will need that class in a moment.</p>
<p>All the Kafka-specific code will go in <code>Consumer</code>'s <code>main()</code> method.</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> org.example;  

<span class="hljs-keyword">import</span> org.slf4j.Logger;  
<span class="hljs-keyword">import</span> org.slf4j.LoggerFactory;  

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Consumer</span> </span>{  
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Logger log = LoggerFactory.getLogger(Consumer.class);  

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{  
        log.info(<span class="hljs-string">"This class consumes messages from Kafka"</span>);  
    }  
}
</code></pre>
<p>Next, configure the consumer properties.</p>
<pre><code class="lang-java">Properties properties = <span class="hljs-keyword">new</span> Properties();  
properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, <span class="hljs-string">"localhost:9092"</span>);  
properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());  
properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());  
properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, <span class="hljs-string">"lotr_consumer_group"</span>);  
properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, <span class="hljs-string">"earliest"</span>);
</code></pre>
<p>Just like with <code>Producer</code>, these properties are a set of string pairs. The ones we're using are:</p>
<ul>
<li><p><code>ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG</code> which specifies the IP address to use to access the Kafka cluster</p>
</li>
<li><p><code>ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG</code> which specifies the deserializer to use for message keys</p>
</li>
<li><p><code>ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG</code> which specifies the deserializer to use for message values</p>
</li>
<li><p><code>ConsumerConfig.GROUP_ID_CONFIG</code> which specifies the consumer group this consumer belongs to</p>
</li>
<li><p><code>ConsumerConfig.AUTO_OFFSET_RESET_CONFIG</code> which specifies the offset to start reading from</p>
</li>
</ul>
<p>We're connecting to the Kafka cluster on <code>localhost:9092</code>, using string deserializers since our keys and values are strings, setting a group id for our consumer, and telling the consumer to read from the start of the topic.</p>
<p><strong>Note:</strong> If you're running the consumer on Windows and accessing a Kafka broker running on WSL, you'll need to change <code>"localhost:9091"</code> to <code>"[::1]:9092"</code> or <code>"0:0:0:0:0:0:0:1:9092"</code>, like you did in <code>Producer</code>.</p>
<p>Next, we create a <code>KafkaConsumer</code> and pass it the configuration properties.</p>
<pre><code class="lang-java">KafkaConsumer&lt;String, String&gt; consumer = <span class="hljs-keyword">new</span> KafkaConsumer&lt;&gt;(properties);
</code></pre>
<p>We need to tell the consumer which topic, or topics, to subscribe to. The <code>subscribe()</code> method takes in a collection of one or more strings, naming the topics you want to read from. Remember, consumers can subscribe to more than one topic at the same time. For this example, we'll use one topic, the <code>lotr_characters</code> topic.</p>
<pre><code class="lang-java">String topic = <span class="hljs-string">"lotr_characters"</span>;  

consumer.subscribe(Arrays.asList(topic));
</code></pre>
<p>The consumer is now ready to start reading messages from the topic. It does this by regularly polling for new messages.</p>
<p>We'll use a while loop to repeatedly call the <code>poll()</code> method to check for new messages.</p>
<p><code>poll()</code> takes in a duration for how long it should read for at a time. It then batches these messages into an iterable called <code>ConsumerRecords</code>. We can then iterate over <code>ConsumerRecords</code> and do something with each individual <code>ConsumerRecord</code>.</p>
<p>In a real-world application, we would process this data or send it to some further destination, like a database or data pipeline. Here, we're just going to log the key, value, partition, and offset for each message we receive.</p>
<pre><code class="lang-java"><span class="hljs-keyword">while</span>(<span class="hljs-keyword">true</span>){  
    ConsumerRecords&lt;String, String&gt; messages = consumer.poll(Duration.ofMillis(<span class="hljs-number">100</span>));  

    <span class="hljs-keyword">for</span> (ConsumerRecord&lt;String, String&gt; message : messages){  
        log.info(<span class="hljs-string">"key ["</span> + message.key() + <span class="hljs-string">"] value ["</span> + message.value() +<span class="hljs-string">"]"</span>);  
        log.info(<span class="hljs-string">"partition ["</span> + message.partition() + <span class="hljs-string">"] offset ["</span> + message.offset() + <span class="hljs-string">"]"</span>);  
    }  
}
</code></pre>
<p>Now it's time to run our consumer. <strong>Make sure you have Zookeeper and Kafka running.</strong> Run the <code>Consumer</code> class and you'll see the messages that <code>Producer</code> previously sent to the <code>lotr_characters</code> topic in Kafka.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/java-consumer-reading-from-topic.PNG" alt="The Kafka client app consuming messages that were previously produced to Kafka." width="600" height="400" loading="lazy"></p>
<p><em>The Kafka client app consuming messages that were previously produced to Kafka</em></p>
<h3 id="heading-how-to-shut-down-the-consumer">How to Shut Down the Consumer</h3>
<p>Right now, our consumer is running in an infinite loop and polling for new messages every 100 ms. This isn't a problem, but we should add safeguards to handle shutting down the consumer if an exception occurs.</p>
<p>We're going to wrap our code in a try-catch-finally block. If an exception occurs, we can handle it in the <code>catch</code> block.</p>
<p>The <code>finally</code> block will then call the consumer's <code>close()</code> method. This will close the socket the consumer is using, commit the offsets it has processed, and trigger a consumer group rebalance so any other consumers in the group can take over reading the partitions this consumer was handling.</p>
<pre><code class="lang-java"><span class="hljs-keyword">try</span> {
            <span class="hljs-comment">// subscribe to topic(s)</span>
            String topic = <span class="hljs-string">"lotr_characters"</span>;
            consumer.subscribe(Arrays.asList(topic));

            <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {
                <span class="hljs-comment">// poll for new messages</span>
                ConsumerRecords&lt;String, String&gt; messages = consumer.poll(Duration.ofMillis(<span class="hljs-number">100</span>));

                <span class="hljs-comment">// handle message contents</span>
                <span class="hljs-keyword">for</span> (ConsumerRecord&lt;String, String&gt; message : messages) {
                    log.info(<span class="hljs-string">"key ["</span> + message.key() + <span class="hljs-string">"] value ["</span> + message.value() + <span class="hljs-string">"]"</span>);
                    log.info(<span class="hljs-string">"partition ["</span> + message.partition() + <span class="hljs-string">"] offset ["</span> + message.offset() + <span class="hljs-string">"]"</span>);
                }
            }
        } <span class="hljs-keyword">catch</span> (Exception err) {
            <span class="hljs-comment">// catch and handle exceptions</span>
            log.error(<span class="hljs-string">"Error: "</span>, err);
        } <span class="hljs-keyword">finally</span> {
            <span class="hljs-comment">// close consumer and commit offsets</span>
            consumer.close();
            log.info(<span class="hljs-string">"consumer is now closed"</span>);
        }
</code></pre>
<p><code>Consumer</code> will continuously poll its assigned topics for new messages and shut down safely if it experiences an exception.</p>
<p>The full code for the <code>Consumer</code> class should now be:</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> org.example;

<span class="hljs-keyword">import</span> org.apache.kafka.clients.consumer.ConsumerConfig;
<span class="hljs-keyword">import</span> org.apache.kafka.clients.consumer.ConsumerRecord;
<span class="hljs-keyword">import</span> org.apache.kafka.clients.consumer.ConsumerRecords;
<span class="hljs-keyword">import</span> org.apache.kafka.clients.consumer.KafkaConsumer;
<span class="hljs-keyword">import</span> org.apache.kafka.common.serialization.StringDeserializer;
<span class="hljs-keyword">import</span> org.slf4j.Logger;
<span class="hljs-keyword">import</span> org.slf4j.LoggerFactory;

<span class="hljs-keyword">import</span> java.time.Duration;
<span class="hljs-keyword">import</span> java.util.Arrays;
<span class="hljs-keyword">import</span> java.util.Properties;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Consumer</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> Logger log = LoggerFactory.getLogger(Consumer.class);

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">main</span><span class="hljs-params">(String[] args)</span> </span>{
        log.info(<span class="hljs-string">"This class consumes messages from Kafka"</span>);

        Properties properties = <span class="hljs-keyword">new</span> Properties();
        properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, <span class="hljs-string">"localhost:9092"</span>);
        properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
        properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
        properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "lotr_consumer_group");
        properties.setProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

        KafkaConsumer&lt;String, String&gt; consumer = <span class="hljs-keyword">new</span> KafkaConsumer&lt;&gt;(properties);

        <span class="hljs-keyword">try</span> {
            String topic = <span class="hljs-string">"lotr_characters"</span>;
            consumer.subscribe(Arrays.asList(topic));

            <span class="hljs-keyword">while</span> (<span class="hljs-keyword">true</span>) {
                ConsumerRecords&lt;String, String&gt; messages = consumer.poll(Duration.ofMillis(<span class="hljs-number">100</span>));

                <span class="hljs-keyword">for</span> (ConsumerRecord&lt;String, String&gt; message : messages) {
                    log.info(<span class="hljs-string">"key ["</span> + message.key() + <span class="hljs-string">"] value ["</span> + message.value() + <span class="hljs-string">"]"</span>);
                    log.info(<span class="hljs-string">"partition ["</span> + message.partition() + <span class="hljs-string">"] offset ["</span> + message.offset() + <span class="hljs-string">"]"</span>);
                }
            }
        } <span class="hljs-keyword">catch</span> (Exception err) {
            log.error(<span class="hljs-string">"Error: "</span>, err);
        } <span class="hljs-keyword">finally</span> {
            consumer.close();
            log.info(<span class="hljs-string">"The consumer is now closed"</span>);
        }
    }
}
</code></pre>
<p>You now have a basic Java application that can send messages to and read messages from Kafka. If you got stuck at any point, <a target="_blank" href="https://github.com/gerhynes/kafka-java-app">the full code is available on GitHub</a>.</p>
<h2 id="heading-where-to-take-it-from-here">Where to Take it from Here</h2>
<p>Congratulations on making it this far. You've learned:</p>
<ul>
<li><p>the main concepts behind Kafka</p>
</li>
<li><p>how to communicate with Kafka from the command line</p>
</li>
<li><p>how to build a Java app that produces to and consumes from Kafka</p>
</li>
</ul>
<p>There's plenty more to learn about Kafka, whether that's <a target="_blank" href="https://kafka.apache.org/documentation/#connect">Kafka Connect</a> for connecting Kafka to common data systems or the <a target="_blank" href="https://kafka.apache.org/documentation/streams/">Kafka Streams API</a> for processing and transforming your data.</p>
<p>Some resources you might find useful as you continue your journey with Kafka are:</p>
<ul>
<li><p>the <a target="_blank" href="https://kafka.apache.org/documentation/">official Kafka docs</a></p>
</li>
<li><p><a target="_blank" href="https://developer.confluent.io/learn-kafka/">courses from Confluent</a></p>
</li>
<li><p><a target="_blank" href="https://www.conduktor.io/kafka">Conduktor's kafkademy</a></p>
</li>
</ul>
<p>I hope this guide has been helpful and made you excited to learn more about Kafka, event streaming, and real-time data processing.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Object Storage for Data Parallelization and Experimentation ]]>
                </title>
                <description>
                    <![CDATA[ By using big data, companies can learn a lot about how their businesses are performing. Analytics on sales, churn rates, and other basic metrics are available in almost real time as data comes in.  Then there are more complex analyses that you'll nee... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-object-storage-for-parallelization-and-experimentation/</link>
                <guid isPermaLink="false">66bb5252b0a396d22e4116fa</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analysis ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ storage ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ry Vee ]]>
                </dc:creator>
                <pubDate>Mon, 27 Sep 2021 14:09:57 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/09/article-cover-pic.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By using big data, companies can learn a lot about how their businesses are performing. Analytics on sales, churn rates, and other basic metrics are available in almost real time as data comes in. </p>
<p>Then there are more complex analyses that you'll need to do. At times relationships between two seemingly unrelated data sets can provide surprising insights and unveil important opportunities for the organization.</p>
<p>Data scientists and engineers are continuing to improve how they break down and work on data. Experimentation entails discovering the right correlations among data points. </p>
<p>This means they also need to do some sort of parallelization of such data and resulting models. Parallelization simply means that the same data set is being operated upon in many different ways without damaging the integrity of the original data.</p>
<p>In this article we are going to talk about how you can make sure you're doing such experimentation and parallel processing efficiently and that it provides the maximum insights. We will be tackling different concepts related to data storage and data versioning.</p>
<h1 id="heading-block-storage-vs-object-storage">Block Storage vs Object Storage</h1>
<p>For the uninitiated, we first must understand the difference between block and object storage and why the latter is the better option when dealing with data experimentation.</p>
<p><img src="https://lh4.googleusercontent.com/p8F4n7jqjmQtqquQasDGPEj1eRdxhNIsdMFxX9gIM03w6r6u-VRzU6rn2gMqdF1U3lrGOrjWEPwlBFzR-0cYVHWBWF7tigFiS4m_EtYjw0bU4tPATeWsZNYTFwpZTbyLBAzxqmbX=s0" alt="Image" width="1000" height="500" loading="lazy">
_<a target="_blank" href="https://res.cloudinary.com/practicaldev/image/fetch/s--PYImgKrK--/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4519hl0nf6aze73pyvsr.png">Image source</a>_</p>
<h2 id="heading-what-is-block-storage">What is Block Storage?</h2>
<p>It is called “block storage” (also known as <a target="_blank" href="https://www.snia.org/education/storage_networking_primer/san/what_san">SAN</a>) because each dataset (in the form of files) is grouped into blocks stored in disks. </p>
<p>A classic example of block storage is the file system on your personal computer. For enterprise-level use-cases, it is scaled through a network of hard drives connected through fiber optic cables. </p>
<p>There are a few disadvantages to using block storage. First, if a sector (or a block) becomes corrupted, it can damage the files. Another problem is the lack of scalability (expanding the network of fiber optic cables is costly).</p>
<h2 id="heading-what-is-object-storage">What is Object Storage?</h2>
<p>In object storage, data is stored as objects. Each object contains the actual data, called the blob, a unique identifier (UUID), and metadata, which contains information about the object (such as timestamp, version, and author).</p>
<p>Object storage makes it cost-effective to scale your data store—you don’t need complex hardware for this. It also makes data retrieval faster as each object can be retrieved through its UUID. </p>
<p>This is in contrast to block storage, where each data location needs to be identified before the actual information can be retrieved.</p>
<p>One disadvantage of using object storage is that data can only be written once and cannot be updated. But this isn’t really a disadvantage as we will see further on in this article.</p>
<h2 id="heading-what-problems-does-object-storage-solve">What Problems Does Object Storage Solve?</h2>
<p>As we have already seen, data retrieval can be incredibly fast with object storage (no matter the size of the data store). But when it comes to data experimentation and data parallelization, object storage shines the brightest.</p>
<p>As mentioned before, you can't overwrite any data already stored as an object. This ensures object storage is protected from unwanted (or unauthorized) data destruction or updating. That’s great to know if you do a lot of data processing where accidental corruption of information could happen.</p>
<p>One other problem that object storage can solve is that it doesn’t require data to be structured. As companies produce and consume tremendous amounts of information every moment, often non-structured data (such as PDFs, videos, images) are not so easily processed into useful forms (such as for analytics or dashboards). </p>
<p>With object storage, this is now possible. You can now use non-structured data to develop machine learning models.</p>
<p>With data storage, it’s possible to have different versions of the same blob (with different metadata). As there is Git for code version control, we can have similar ways of managing different versions of the same data.</p>
<p>This brings us to the concept of data lakes.</p>
<h2 id="heading-what-are-data-lakes">What are Data Lakes?</h2>
<p>Data lakes are central repositories of data that don’t care which format such data is in. </p>
<p>Companies produce and consume tremendous amounts of data. Such data traditionally sits in silos because they belong to different departments or are in different forms (for example, videos aren’t stored in the same directory as the data in the MySQL database). </p>
<p>With data lakes, any department in the enterprise can store information without the need to pre-process it. Likewise, any data can be retrieved and analyzed by anybody from any department.</p>
<p>Data lakes are important because they make data analytics extremely fast and convenient.</p>
<h2 id="heading-how-data-experimentation-and-parallelization-work-with-object-storage">How Data Experimentation and Parallelization Work with Object Storage</h2>
<p>As with developing software, working with data requires us to utilize tools that can aid us in our workflow. A powerful open source tool for experimenting with data and performing parallelization (that is working on the same data to create different sets of machine learning models) is LakeFS.</p>
<p>LakeFS is an open source platform that provides Git-like capabilities when working with data. This means you can create branches (allowing you to experiment with data) and commit versions of data (and data models).</p>
<h3 id="heading-why-is-this-git-like-feature-important">Why is this Git-like feature important?</h3>
<p>First, you need to make sure that your data lake is <a target="_blank" href="https://mariadb.com/resources/blog/acid-compliance-what-it-means-and-why-you-should-care/">ACID</a> compliant. This means that your data changes can happen in isolation (in branches). Thus, the integrity of the data is maintained in the master branch (until such changes are ready to be merged).</p>
<p>Another important feature of LakeFS is continuous integration of data (again, much like in software development). Enterprises need to incorporate new data quickly and without being disrupted. Therefore, this ability to have a <a target="_blank" href="https://www.infoworld.com/article/3271126/what-is-cicd-continuous-integration-and-continuous-delivery-explained.html">CI/CD</a> workflow is invaluable. </p>
<p>So, let’s see how we can get started with using LakeFS with our object storage experimentation and parallelization.</p>
<h3 id="heading-how-to-install-lakefs">How to Install LakeFS</h3>
<p>Locally you can install LakeFS by running the following command in your terminal:*  </p>
<p><img src="https://lh4.googleusercontent.com/pTYRbQlB2_Mp8j_XGxUOvBI0PLf5kuuT1tYV5AxcPmrnq8K5sjLCUBwQqp4klk4rnraQnK9OD5hrudEFUwBLNcvmyNGQqDPkLQ_DkVBoVgCUfITIFdS6d1RxtkTFG_T40ZV0ia0L=s0" alt="Image" width="501" height="111" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=curl%2520https%253A%252F%252Fcompose.lakefs.io%2520%257C%2520docker-compose%2520-f%2520-%2520up%250A">Code source</a></em></p>
<p>_*This is assuming you have Docker and Docker-Compose installed in your system. If you don’t have Docker and Docker-Compose, you may try other installation methods <a target="_blank" href="https://docs.lakefs.io/quickstart/more_quickstart_options.html">here</a>._</p>
<p>Now visit <a target="_blank" href="http://127.0.0.1:8000/setup">http://127.0.0.1:8000/setup</a> in your browser to verify you have installed it correctly.</p>
<h3 id="heading-how-to-create-a-repository-in-lakefs">How to Create a Repository in LakeFS</h3>
<p>Once you’ve verified that LakeFS is installed correctly, go ahead and create an admin user.</p>
<p><img src="https://lh5.googleusercontent.com/kRpsNjJe60f7fiIEFC0O5ZbY88F9g-F4X-GRtl8L8WiVJ_sDiKcnz-0jmprZc-bVkfq029fYhq4K-jdBXyBQttc012Nv4v6j2vbJvk4jnbs71BF9Wulo_5JwsvmSjRE1nkQ-ltRe=s0" alt="Image" width="1627" height="923" loading="lazy">
<em><a target="_blank" href="https://docs.lakefs.io/assets/img/setup.png">Image source</a></em></p>
<p><img src="https://lh3.googleusercontent.com/oez-1Q1JH6Q_cqUh0tKE1bW-IbEXg92UP4NVkTy_o-vVETELASw8R8CoPS5ogWDZNl4hH8W3cb68_PvEECO1os9U1sgfJFA2PMnc1J57wEjomp9SrN0ZZK-OXoOjJpZcF-LPZlhu=s0" alt="Image" width="1627" height="921" loading="lazy">
_<a target="_blank" href="https://docs.lakefs.io/assets/img/setup_done.png">Image source</a>_</p>
<p>Click on the login link and log in as an administrator. </p>
<p>On the page to which you get redirected, click on Create Repository. A popup will appear:</p>
<p><img src="https://lh6.googleusercontent.com/2abxJeRjLk7IRzhohW7jlG3cKQKH4kRCjIyVbQkHe_Fa9qdcGPdrbcTsFRhW7lv3S5LQtfa4xBmnNu0wRqhFSvwi1hp5_ARB_fRJlcLgz1TmDa_a9DQ-apmcIiclMLwsgfuyoD9P=s0" alt="Image" width="1622" height="907" loading="lazy">
_<a target="_blank" href="https://docs.lakefs.io/assets/img/create_repo_local.png">Image source</a>_</p>
<p>Congratulations! You now have your first repository. This is the main “bucket” in which you are going to store your data. </p>
<p>Next, we’ll start adding some data.</p>
<h3 id="heading-how-to-add-data-to-your-lakefs-repository">How to Add Data to your LakeFS Repository</h3>
<p>Visit <a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html">here</a> to install AWS CLI.</p>
<p>With the credentials created during the admin-user creation phase, configure a new connection profile:</p>
<p><img src="https://lh5.googleusercontent.com/D9FDuc11VgqsUr5LfN2UE_zTQYSKinNHB_saQxvr0MJj2yurnDCTqEC0cWA-dvOj3TYGMxJq52Una4zpaG6hrImrAaOWA43V1nMsUg0NpI9XIj8lKF6THD3ZoC0BNMqd-uRUsS6p=s0" alt="Image" width="645" height="204" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=aws%2520configure%2520--profile%2520local%250A%2523%2520output%253A%250A%2523%2520AWS%2520Access%2520Key%2520ID%2520%255BNone%255D%253A%2520AKIAJVHTOKZWGCD2QQYQ%250A%2523%2520AWS%2520Secret%2520Access%2520Key%2520%255BNone%255D%253A%2520****************************************%250A%2523%2520Default%2520region%2520name%2520%255BNone%255D%253A%250A%2523%2520Default%2520output%2520format%2520%255BNone%255D%253A%250A">Code source</a></em></p>
<p>To test if the connection is working, run the following:</p>
<p><img src="https://lh5.googleusercontent.com/oP-iisEz7w9qQM-zQaAUcdhXj_YMRGamhV-AwwNfFsDVm_p4HcKlGsw0sVD0aJS-Q-3rCy3VlhtcvtBxJgFCrHQLXrPB7ZyHVril1iGeWKP_mqPPrxizpw8NNAGWdNc2ZF36mfX4=s0" alt="Image" width="560" height="148" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=aws%2520--endpoint-url%253Dhttp%253A%252F%252Flocalhost%253A8000%2520--profile%2520local%2520s3%2520ls%250A%2523%2520output%253A%250A%2523%25202021-06-15%252013%253A43%253A03%2520example-repo%250A">Code source</a></em></p>
<p>Now, to copy files into the main branch:</p>
<p><img src="https://lh5.googleusercontent.com/Z_3sbfX6IMJzPkYeejJ1O9ftjkO3c4kPk_rlCJ1iOP2FgTnJTZ03cB8C8Ml2u4bet4cvBS60rHt7Ns-xgLWix422-w3ZvpGQCyeGKgBDd0Oog-sV-E4XSpV4ARpoYeQhR2INZV_H=s0" alt="Image" width="847" height="148" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=aws%2520--endpoint-url%253Dhttp%253A%252F%252Flocalhost%253A8000%2520--profile%2520local%2520s3%2520cp%2520.%252Ffoo.txt%2520s3%253A%252F%252Fexample-repo%252Fmain%252F%250A%2523%2520output%253A%250A%2523%2520upload%253A%2520.%252Ffoo.txt%2520to%2520s3%253A%252F%252Fexample-repo%252Fmain%252Ffoo.txt%250A">Code source</a></em></p>
<p>Just note that we need to prefix the path with the name of the branch we want to use.</p>
<p>Now, we will see the file we’ve added in the UI:</p>
<p><img src="https://lh6.googleusercontent.com/F8UCd8s43wM0y4WgRhHWy04p2rzBQ1ccvUZhppCzl30fE0FJEpMQb7Y1X06x-WDx3J9I5LELQv4FtFKOYWJqU2E9dENB5MMqjsv-MYfLI-oCEXLekhWH9xTcazm1-_Fmo4NxgDb_=s0" alt="Image" width="1627" height="934" loading="lazy">
_<a target="_blank" href="https://docs.lakefs.io/assets/img/object_added.png">Image source</a>_</p>
<p>Next, we will need to know how to commit and create branches. To do that, we will need to install the LakeFS CLI.</p>
<h3 id="heading-how-to-install-the-lakefs-cli">How to Install the LakeFS CLI</h3>
<p>You need to first download the binary file <a target="_blank" href="https://docs.lakefs.io/#downloads">here</a>. </p>
<p>Again, we need to use the earlier created admin credentials:</p>
<p><img src="https://lh4.googleusercontent.com/KQntIwi6YaOyp2kKvKLxeYs4Il4czCGCv8fj2_PFhg2Bqy2RRGNNQtLsCxS8YT57DEH-Q63obz7emujS5tST4aoPx0qb4XLjJV3AeKEwRwQGATfJd6us3BA5Svo7Lz_i3k_Smy7N=s0" alt="Image" width="552" height="204" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=lakectl%2520config%250A%2523%2520output%253A%250A%2523%2520Config%2520file%2520%252Fhome%252Fjanedoe%252F.lakectl.yaml%2520will%2520be%2520used%250A%2523%2520Access%2520key%2520ID%253A%2520AKIAJVHTOKZWGCD2QQYQ%250A%2523%2520Secret%2520access%2520key%253A%2520****************************************%250A%2523%2520Server%2520endpoint%2520URL%253A%2520http%253A%252F%252Flocalhost%253A8000%252Fapi%252Fv1%250A">Code source</a></em></p>
<p>Here are some of the commands we can run to try it out:</p>
<p><img src="https://lh4.googleusercontent.com/4HuuBJwfpif6TzMS5spkzhkLQf_TC-rZ6WMjAiOOrsv3z8iF2vaTtKTjzicnm5qDjXmLq_aSGqXvAF7RE43BWd9hGB7gUSb76w1bt6ntyLJgAVFBMLwP7uYRPLFUd-1G27kVER7O=s0" alt="Image" width="721" height="521" loading="lazy">
<em><a target="_blank" href="https://carbon.now.sh/?bg=rgba%28171%2C+184%2C+195%2C+1%29&amp;t=seti&amp;wt=none&amp;l=application%2Fx-sh&amp;ds=true&amp;dsyoff=20px&amp;dsblur=68px&amp;wc=true&amp;wa=true&amp;pv=56px&amp;ph=56px&amp;ln=false&amp;fl=1&amp;fm=Hack&amp;fs=14px&amp;lh=133%25&amp;si=false&amp;es=2x&amp;wm=false&amp;code=lakectl%2520branch%2520list%2520lakefs%253A%252F%252Fexample-repo%250A%2523%2520output%253A%250A%2523%2520%252B----------%252B------------------------------------------------------------------%252B%250A%2523%2520%257C%2520REF%2520NAME%2520%257C%2520COMMIT%2520ID%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%2520%257C%250A%2523%2520%252B----------%252B------------------------------------------------------------------%252B%250A%2523%2520%257C%2520main%2520%2520%2520%2520%2520%257C%2520a91f56a7e11be1348fc405053e5234e4af7d6da01ed02f3d9a8ba7b1f71499c8%2520%257C%250A%2523%2520%252B----------%252B------------------------------------------------------------------%252B%250A%2520%2520%2520%2520%2520%250Alakectl%2520commit%2520lakefs%253A%252F%252Fexample-repo%252Fmain%2520-m%2520%27added%2520our%2520first%2520file%21%27%250A%2523%2520output%253A%250A%2523%2520Commit%2520for%2520branch%2520%2522main%2522%2520done.%250A%2523%2520%250A%2523%2520ID%253A%2520901f7b21e1508e761642b142aea0ccf28451675199655381f65101ea230ebb87%250A%2523%2520Timestamp%253A%25202021-06-15%252013%253A48%253A37%2520%252B0300%2520IDT%250A%2523%2520Parents%253A%2520a91f56a7e11be1348fc405053e5234e4af7d6da01ed02f3d9a8ba7b1f71499c8%250A%2520%2520%250Alakectl%2520log%2520lakefs%253A%252F%252Fexample-repo%252Fmain%250A%2523%2520output%253A%2520%2520%250A%2523%2520commit%2520901f7b21e1508e761642b142aea0ccf28451675199655381f65101ea230ebb87%250A%2523%2520Author%253A%2520Example%2520User%2520%253Cuser%2540example.com%253E%250A%2523%2520Date%253A%25202021-06-15%252013%253A48%253A37%2520%252B0300%2520IDT%250A%2520%2520%2520%2520%2520%2520%2520%250A%2520%2520%2520%2520%2520%2520added%2520our%2520first%2520file%21%250A%2520%2520%2520%2520%2520%2520%2520">Code source</a></em></p>
<p>You can find all the other commands, such as branch creation, and so on, <a target="_blank" href="https://docs.lakefs.io/reference/commands.html">online</a>.</p>
<p>There you have it! Now, you can work with your data any way you like. Experiment without guilt and create multiple versions of your data models.</p>
<h2 id="heading-in-closing">In Closing</h2>
<p>In this article, we covered a bit of ground. We learned the different kinds of data storage mechanisms and why object storage has a lot of edge when dealing with data experimentations and parallelism. </p>
<p>Next, we looked into data lakes and LakeFS, which is a powerful tool for working with data.</p>
<p>At first, it might seem a daunting task. But, as we’ve shown here, with the right set of tools and knowledge, there’s a lot you can accomplish.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ A Quick Overview of the Apache Hadoop Framework ]]>
                </title>
                <description>
                    <![CDATA[ Hadoop, now known as Apache Hadoop, was named after a toy elephant that belonged to co-founder Doug Cutting’s son. Doug chose the name for the open-source project as it was easy to spell, pronounce, and find in search results. The original yellow stu... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/a-quick-overview-of-the-apache-hadoop-framework/</link>
                <guid isPermaLink="false">66c3431d4f1fc448a3678f81</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hadoop ]]>
                    </category>
                
                    <category>
                        <![CDATA[ toothbrush ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 01 Feb 2020 00:00:00 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9c9d24740569d1a4ca3622.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Hadoop, now known as Apache Hadoop, was named after a toy elephant that belonged to co-founder Doug Cutting’s son. Doug chose the name for the open-source project as it was easy to spell, pronounce, and find in search results. The original yellow stuffed elephant that inspired the name appears in Hadoop’s logo.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/1200px-Hadoop_logo_new.svg.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h2 id="heading-what-is-apache-hadoop">What is Apache Hadoop?</h2>
<blockquote>
<p>The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-availability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-available service on top of a cluster of computers, each of which may be prone to failures.  </p>
<p>Source: <a target="_blank" href="https://hadoop.apache.org/">Apache Hadoop</a></p>
</blockquote>
<p>In 2003 Google released their paper on the Google File System (GFS). It detailed a proprietary distributed file system intended to provide efficient access to large amounts of data using commodity hardware. A year later, Google released another paper entitled “MapReduce: Simplified Data Processing on Large Clusters.” At the time, Doug was working at Yahoo. These papers were the inspiration for his open-source project Apache Nutch. In 2006, the project components then known as Hadoop moved out of Apache Nutch and was released.</p>
<h2 id="heading-why-is-hadoop-useful">Why is Hadoop useful?</h2>
<p>Every day, billions of gigabytes of data are created in a variety of forms. Some examples of frequently created data are:</p>
<ul>
<li>Metadata from phone usage</li>
<li>Website logs</li>
<li>Credit card purchase transactions</li>
<li>Social media posts</li>
<li>Videos</li>
<li>Information gathered from medical devices</li>
</ul>
<p>“Big data” refers to data sets that are too large or complex to process using traditional software applications. Factors that contribute to the complexity of data are the size of the data set, speed of available processors, and the data’s format.</p>
<p>At the time of its release, Hadoop was capable of processing data on a larger scale than traditional software.</p>
<h3 id="heading-core-hadoop"><strong>Core Hadoop</strong></h3>
<p>Data is stored in the Hadoop Distributed File System (HDFS). Using map reduce, Hadoop processes data in parallel chunks (processing several parts at the same time) rather than in a single queue. This reduces the time needed to process large data sets.</p>
<p>HDFS works by storing large files divided into chunks, and replicating them across many servers. Having multiple copies of files creates redundancy, which protects against data loss.</p>
<h3 id="heading-hadoop-ecosystem"><strong>Hadoop Ecosystem</strong></h3>
<p>Many other software packages exist to complement Hadoop. These programs comprise the the Hadoop Ecosystem. Some programs make it easier to load data into the Hadoop cluster, while others make Hadoop easier to use.</p>
<p>The Hadoop Ecosystem includes:</p>
<ul>
<li>Apache Hive</li>
<li>Apache Pig</li>
<li>Apache HBase</li>
<li>Apache Phoenix</li>
<li>Apache Spark</li>
<li>Apache ZooKeeper</li>
<li>Cloudera Impala</li>
<li>Apache Flume</li>
<li>Apache Sqoop</li>
<li>Apache Oozie</li>
</ul>
<h2 id="heading-more-information">More Information:</h2>
<ul>
<li><a target="_blank" href="http://hadoop.apache.org/">Apache Hadoop</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ I ranked every Intro to Data Science course on the internet, based on thousands of data points ]]>
                </title>
                <description>
                    <![CDATA[ By David Venturi A year ago, I dropped out of one of the best computer science programs in Canada. I started creating my own data science master’s program using online resources. I realized that I could learn everything I needed through edX, Coursera... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/i-ranked-all-the-best-data-science-intro-courses-based-on-thousands-of-data-points-db5dc7e3eb8e/</link>
                <guid isPermaLink="false">66c35767d372f14b49bdcb93</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ startup ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 27 Dec 2019 03:24:00 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*s4RqFZgSAluZq2lcWhp5JA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By David Venturi</p>
<p>A year ago, I dropped out of one of the best computer science programs in Canada. I started creating my own <a target="_blank" href="https://medium.com/@davidventuri/i-dropped-out-of-school-to-create-my-own-data-science-master-s-here-s-my-curriculum-1b400dcee412#.5fwwphdqd">data science master’s program</a> using online resources. I realized that I could learn everything I needed through edX, Coursera, and Udacity instead. And I could learn it faster, more efficiently, and for a fraction of the cost.</p>
<p>I’m almost finished now. I’ve taken many data science-related courses and audited portions of many more. I know the options out there, and what skills are needed for learners preparing for a data analyst or data scientist role. <strong>A few months ago, I started creating a review-driven guide that recommends the best courses for each subject within data science.</strong></p>
<p>For the first guide in the series, I recommended a few <a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-start-with-one-of-these-programming-classes-fb694ffe780c/#.42hhzxopw">coding classes</a> for the beginner data scientist. Then it was <a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-take-a-few-of-these-statistics-classes-9bbabab098b9/#.p7pac546r">statistics and probability classes</a>.</p>
<h3 id="heading-now-onto-introductions-to-data-science">Now onto introductions to data science.</h3>
<p><em>(Don’t worry if you’re unsure of what an intro to data science course entails. I’ll explain shortly.)</em></p>
<p>For this guide, I spent 10+ hours trying to identify every online intro to data science course offered as of January 2017, extracting key bits of information from their syllabi and reviews, and compiling their ratings. For this task, I turned to none other than the open source Class Central community and its database of thousands of course ratings and reviews.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*PEbx8gPbRHuABqdNw0_dDw.png" alt="Image" width="800" height="482" loading="lazy">
_Class Central’s [homepage](https://www.class-central.com/" rel="noopener" target="<em>blank" title=").</em></p>
<p>Since 2011, <a target="_blank" href="https://www.class-central.com/">Class Central</a> founder <a target="_blank" href="https://www.class-central.com/@dhawal">Dhawal Shah</a> has kept a closer eye on online courses than arguably anyone else in the world. Dhawal personally helped me assemble this list of resources.</p>
<h3 id="heading-how-we-picked-courses-to-consider">How we picked courses to consider</h3>
<p>Each course must fit three criteria:</p>
<ol>
<li><strong>It must teach the data science process.</strong> More on that soon.</li>
<li><strong>It must be on-demand or offered every few months.</strong></li>
<li><strong>It must be an interactive online course, so no books or read-only tutorials</strong>. Though these are viable ways to learn, this guide focuses on courses.</li>
</ol>
<p>We believe we covered every notable course that fits the above criteria. Since there are seemingly hundreds of courses on <a target="_blank" href="https://www.udemy.com/">Udemy</a>, we chose to consider the most-reviewed and highest-rated ones only. There’s always a chance that we missed something, though. So please let us know in the comments section if we left a good course out.</p>
<h3 id="heading-how-we-evaluated-courses">How we evaluated courses</h3>
<p>We compiled average rating and number of reviews from Class Central and other review sites to calculate a weighted average rating for each course. We read text reviews and used this feedback to supplement the numerical ratings.</p>
<p>We made subjective syllabus judgment calls based on two factors:</p>
<ol>
<li><p><strong>Coverage of the data science process.</strong> Does the course brush over or skip certain subjects? Does it cover certain subjects in too much detail? See the next section for what this process entails.</p>
</li>
<li><p><strong>Usage of common data science tools.</strong> Is the course taught using popular programming languages like Python and/or R? These aren’t necessary, but helpful in most cases so slight preference is given to these courses.</p>
</li>
</ol>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*4NoJKhtSpxGrqFOjl89MeQ.png" alt="Image" width="800" height="234" loading="lazy">
<em>Python and R are the two most popular programming languages used in data science.</em></p>
<h3 id="heading-what-is-the-data-science-process">What is the data science process?</h3>
<p><em>What is data science? What does a data scientist do?</em> These are the types of fundamental questions that an intro to data science course should answer. The following infographic from Harvard professors Joe Blitzstein and Hanspeter Pfister outlines a typical <strong>data science process</strong>, which will help us answer these questions.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*ius9T3uGkd743dljInNF8w.jpeg" alt="Image" width="800" height="831" loading="lazy">
_Visualization from [Opera Solutions](http://blog.operasolutions.com/bid/384900/what-is-data-science" rel="noopener" target="<em>blank" title=").</em></p>
<p>Our goal with this introduction to data science course is to become familiar with the data science process. We don’t want too in-depth coverage of specific aspects of the process, hence the “intro to” portion of the title.</p>
<p>For each aspect, the ideal course explains key concepts within the framework of the process, introduces common tools, and provides a few examples (preferably hands-on).</p>
<p>We’re only looking for an introduction. This guide therefore won’t include full specializations or programs like Johns Hopkins University’s [Data Science Specialization](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=479491.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science &amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Fspecializations%2Fjhu-data-science%2F) on Coursera or Udacity’s <a target="_blank" href="https://www.udacity.com/course/data-analyst-nanodegree--nd002?utm_medium=referral&amp;utm_campaign=api">Data Analyst Nanodegree</a>. These compilations of courses elude the purpose of this series: to find the best <strong>individual</strong> courses for each subject to comprise a data science education. The final three guides in this series of articles will cover each aspect of the data science process in detail.</p>
<h3 id="heading-basic-coding-stats-and-probability-experience-required">Basic coding, stats, and probability experience required</h3>
<p>Several courses listed below require basic programming, statistics, and probability experience. This requirement is understandable given that the new content is reasonably advanced, and that these subjects often have several courses dedicated to them.</p>
<p>This experience can be acquired through our recommendations in the first two articles (<a target="_blank" href="https://medium.freecodecamp.com/if-you-want-to-learn-data-science-start-with-one-of-these-programming-classes-fb694ffe780c#.ld31z08y5">programming</a>, <a target="_blank" href="https://medium.freecodecamp.com/if-you-want-to-learn-data-science-take-a-few-of-these-statistics-classes-9bbabab098b9">statistics</a>) in this Data Science Career Guide.</p>
<h3 id="heading-our-pick-for-the-best-intro-to-data-science-course-is">Our pick for the best intro to data science course is…</h3>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;offerid=507388.9685&amp;type=3&amp;subid=0&amp;u1=cc-medium-career-guide-intro-to-data-science">Data Science A-Z™: Real-Life Data Science Exercises Included</a> (Kirill Eremenko/Udemy)</li>
</ul>
<p>Kirill Eremenko’s <a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdatascience%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Data Science A-Z™</a> on Udemy is the clear winner in terms of breadth and depth of coverage of the data science process of the 20+ courses that qualified. It has a 4.5-star weighted average rating over 3,071 reviews, which places it among the highest rated and most reviewed courses of the ones considered.</p>
<p>It outlines the full process and provides real-life examples. At 21 hours of content, it is a good length. Reviewers love the instructor’s delivery and the organization of the content. The price varies depending on Udemy discounts, which are frequent, so you may be able to purchase access for as little as $10.</p>
<p>Though it doesn’t check our “usage of common data science tools” box<strong>,</strong> the non-Python/R tool choices (gretl, Tableau, Excel) are used effectively in context. Eremenko mentions the following when explaining the gretl choice (gretl is a statistical software package), though it applies to all of the tools he uses (emphasis mine):</p>
<blockquote>
<p>In gretl, we will be able to do the same modeling just like in R and Python but we won’t have to code. That’s the big deal here. Some of you may already know R very well, but some may not know it at all. My goal is to show you how to build a robust model and <strong>give you a framework that you can apply in any tool you choose</strong>. gretl will help us avoid getting bogged down in our coding.</p>
</blockquote>
<p>One prominent reviewer noted the following:</p>
<blockquote>
<p>Kirill is the best teacher I’ve found online. He uses real life examples and explains common problems so that you get a deeper understanding of the coursework. He also provides a lot of insight as to what it means to be a data scientist from working with insufficient data all the way to presenting your work to C-class management. I highly recommend this course for beginner students to intermediate data analysts!</p>
</blockquote>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*gl_KL2hhIkodQpznSzu8ZA.png" alt="Image" width="800" height="265" loading="lazy"></p>
<h3 id="heading-a-great-python-focused-introduction">A great Python-focused introduction</h3>
<ul>
<li><a target="_blank" href="https://www.class-central.com/mooc/4937/udacity-intro-to-data-analysis">Intro to Data Analysis</a> (Udacity)</li>
</ul>
<p>Udacity’s <a target="_blank" href="https://www.class-central.com/mooc/4937/udacity-intro-to-data-analysis">Intro to Data Analysis</a> is a relatively new offering that is part of Udacity’s popular <a target="_blank" href="https://medium.com/@davidventuri/review-udacity-data-analyst-nanodegree-1e16ae2b6d12#.8uvi6hlpv">Data Analyst Nanodegree</a>. It covers the data science process clearly and cohesively using Python, though it lacks a bit in the modeling aspect. The estimated timeline is 36 hours (six hours per week over six weeks), though it is shorter in my experience. It has a 5-star weighted average rating over two reviews. It is free.</p>
<p>The videos are well-produced and the instructor (Caroline Buckey) is clear and personable. Lots of programming quizzes enforce the concepts learned in the videos. Students will leave the course confident in their new and/or improved NumPy and Pandas skills (these are popular Python libraries). The final project — which is graded and reviewed in the Nanodegree but not in the free individual course — can be a nice add to a portfolio.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*5IXXOHV9XjA_mcl9tiii8Q.png" alt="Image" width="800" height="152" loading="lazy"></p>
<h3 id="heading-an-impressive-offering-with-no-review-data">An impressive offering with no review data</h3>
<ul>
<li><a target="_blank" href="https://bigdatauniversity.com/learn/data-science/">Data Science Fundamentals</a> (Big Data University)</li>
</ul>
<p>Data Science Fundamentals is a four-course series provided by IBM’s Big Data University. It includes courses titled <a target="_blank" href="https://bigdatauniversity.com/courses/data-science-101/">Data Science 101</a>, <a target="_blank" href="https://bigdatauniversity.com/courses/data-science-methodology-2/">Data Science Methodology</a>, <a target="_blank" href="https://bigdatauniversity.com/courses/data-science-hands-open-source-tools/">Data Science Hands-on with Open Source Tools</a>, and <a target="_blank" href="https://bigdatauniversity.com/courses/r-101/">R 101</a>.</p>
<p>It covers the full data science process and introduces Python, R, and several other open-source tools. The courses have tremendous production value. 13–18 hours of effort is estimated, depending on if you take the “R 101” course at the end, which isn’t necessary for the purpose of this guide. Unfortunately, it has no review data on the major review sites that we used for this analysis, so we can’t recommend it over the above two options yet. It is free.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*K0C--VIZ0DyImJexZyzFHg.png" alt="Image" width="800" height="242" loading="lazy"></p>
<h3 id="heading-the-competition">The competition</h3>
<p>Our #1 pick had a weighted average rating of 4.5 out of 5 stars over 3,068 reviews. Let’s look at the other alternatives, sorted by descending rating. Below you’ll find several R-focused courses, if you are set on an introduction in that language.</p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;offerid=507388.9690&amp;type=3&amp;subid=0&amp;u1=cc-medium-career-guide-intro-to-data-science">Python for Data Science and Machine Learning Bootcamp</a> (Jose Portilla/Udemy): Full process coverage with a tool-heavy focus (Python). Less process-driven and more of a very detailed intro to Python. Amazing course, though not ideal for the scope of this guide. It, like Jose’s R course below, can double as both intros to Python/R and intros to data science. 21.5 hours of content. It has a <strong>4.7</strong>-star weighted average rating over 1,644 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-science-and-machine-learning-bootcamp-with-r%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Data Science and Machine Learning Bootcamp with R</a> (Jose Portilla/Udemy): Full process coverage with a tool-heavy focus (R). Less process-driven and more of a very detailed intro to R. Amazing course, though not ideal for the scope of this guide. It, like Jose’s Python course above, can double as both intros to Python/R and intros to data science. 18 hours of content. It has a <strong>4.6</strong>-star weighted average rating over 847 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*31ne7XmQ_fvDRA6FiGrFFA.jpeg" alt="Image" width="750" height="422" loading="lazy"></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*E8aXOussUt-BCJ8awVjgpg.jpeg" alt="Image" width="750" height="422" loading="lazy">
_Jose Portilla has two Data Science and Machine Learning Bootcamps on Udemy: one for [R](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fpython-for-data-science-and-machine-learning-bootcamp%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science" rel="noopener" target="_blank" title=""&gt;Python and one for &lt;a href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-science-and-machine-learning-bootcamp-with-r%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science" rel="noopener" target="<em>blank" title=").</em></p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fdata-science-and-machine-learning-with-python-hands-on%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Data Science and Machine Learning with Python — Hands On!</a> (Frank Kane/Udemy): Partial process coverage. Focuses on statistics and machine learning. Decent length (nine hours of content). Uses Python. It has a <strong>4.5</strong>-star weighted average rating over 3,104 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Flearn-data-science%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Introduction to Data Science</a> (Data Hawk Tech/Udemy): Full process coverage, though limited depth of coverage. Quite short (three hours of content). Briefly covers both R and Python. It has a <strong>4.4</strong>-star weighted average rating over 62 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="https://www.class-central.com/mooc/1806/open-education-by-blackboard-applied-data-science-an-introduction">Applied Data Science: An Introduction</a> (Syracuse University/Open Education by Blackboard): Full process coverage, though not evenly spread. Heavily focuses on basic statistics and R. Too applied and not enough process focus for the purpose of this guide. Online course experience feels disjointed. It has a <strong>4.33</strong>-star weighted average rating over 6 reviews. Free.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fintroduction-to-data-science%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Introduction To Data Science</a> (Nina Zumel &amp; John Mount/Udemy): Partial process coverage only, though good depth in the data preparation and modeling aspects. Okay length (six hours of content). Uses R. It has a <strong>4.3</strong>-star weighted average rating over 101 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fapplied-data-science-with-python%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Applied Data Science with Python</a> (V2 Maestros/Udemy): Full process coverage with good depth of coverage for each aspect of the process. Decent length (8.5 hours of content). Uses Python. It has a <strong>4.3</strong>-star weighted average rating over 92 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*5s_UKt1N7jx5Plq_GNVv-Q.png" alt="Image" width="800" height="460" loading="lazy">
_V2 Maestros has two versions of their “Applied Data Science” course: one for [R](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fapplied-data-science-with-python%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science" rel="noopener" target="_blank" title=""&gt;Python and one for &lt;a href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fapplied-data-science-with-r%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science" rel="noopener" target="<em>blank" title=").</em></p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fwant-to-be-a-data-scientist%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Want to be a Data Scientist?</a> (V2 Maestros/Udemy): Full process coverage, though limited depth of coverage. Quite short (3 hours of content). Limited tool coverage. It has a <strong>4.3</strong>-star weighted average rating over 790 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="https://www.class-central.com/mooc/2129/futurelearn-data-to-insight-an-introduction-to-data-analysis">Data to Insight: an Introduction to Data Analysis</a> (University of Auckland/FutureLearn): Breadth of coverage unclear. Claims to focus on data exploration, discovery, and visualization. Not offered on demand. 24 hours of content (three hours per week over eight weeks). It has a <strong>4</strong>-star weighted average rating over 2 reviews. Free with paid certificate available.</li>
<li><a target="_blank" href="https://www.class-central.com/mooc/6405/edx-data-science-orientation">Data Science Orientation</a> (Microsoft/edX): Partial process coverage (lacks modeling aspect). Uses Excel, which makes sense given it is a Microsoft-branded course. 12–24 hours of content (two-four hours per week over six weeks). It has a <strong>3.95</strong>-star weighted average rating over 40 reviews. Free with Verified Certificate available for $25.</li>
<li><a target="_blank" href="https://www.class-central.com/mooc/3954/edx-dat203x-data-science-and-machine-learning-essentials">Data Science Essentials</a> (Microsoft/edX): Full process coverage with good depth of coverage for each aspect. Covers R, Python, and Azure ML (a Microsoft machine learning platform). Several 1-star reviews citing tool choice (Azure ML) and the instructor’s poor delivery. 18–24 hours of content (three-four hours per week over six weeks). It has a <strong>3.81</strong>-star weighted average rating over 67 reviews. Free with Verified Certificate available for $49.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*s_kLWZG31jVM_neaLZhXZg.png" alt="Image" width="800" height="170" loading="lazy">
_The above two courses are from Microsoft’s [Professional Program Certificate in Data Science](http://www.awin1.com/awclick.php?gid=295463&amp;mid=6798&amp;awinaffid=301045&amp;linkid=599979&amp;clickref=&amp;p=https%3A%2F%2Fwww.edx.org%2Fmicrosoft-professional-program-certficate-data-science" rel="noopener" target="<em>blank" title=") on edX.</em></p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=323058.1&amp;type=10&amp;tmpid=14538&amp;RD_PARM1=https%3A%2F%2Fwww.udemy.com%2Fapplied-data-science-with-r%2F%26u1%3Dcc-medium-career-guide-intro-to-data-science">Applied Data Science with R</a> (V2 Maestros/Udemy): The R companion to V2 Maestros’ Python course above. Full process coverage with good depth of coverage for each aspect of the process. Decent length (11 hours of content). Uses R. It has a <strong>3.8</strong>-star weighted average rating over 212 reviews. Cost varies depending on Udemy discounts, which are frequent.</li>
<li><a target="_blank" href="https://www.class-central.com/mooc/1480/udacity-intro-to-data-science">Intro to Data Science</a> (Udacity): Partial process coverage, though good depth for the topics covered. Lacks the exploration aspect, though Udacity has a great, full <a target="_blank" href="https://www.class-central.com/mooc/1478/udacity-data-analysis-with-r">course</a> on exploratory data analysis (EDA). Claims to be 48 hours in length (six hours per week over eight weeks), but is shorter in my experience. Some reviews think the set-up to the advanced content is lacking. Feels disorganized. Uses Python. It has a <strong>3.61</strong>-star weighted average rating over 18 reviews. Free.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;tmpid=18061&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fpython-data-analysis">Introduction to Data Science in Python</a> (University of Michigan/Coursera): Partial process coverage. No modeling and vizualization, though courses #2 and #3 in the <a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Fspecializations%2Fdata-science-python">Applied Data Science with Python Specialization</a> cover these aspects. Taking all three courses would be too in depth for the purpose of this guides. Uses Python. Four weeks in length. It has a <strong>3.6</strong>-star weighted average rating over 15 reviews. Free and paid options available.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*iOuqB7POLAuBFsORues5cQ.png" alt="Image" width="800" height="122" loading="lazy">
_The University of Michigan teaches the [Applied Data Science with Python Specialization](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Fspecializations%2Fdata-science-python" rel="noopener" target="<em>blank" title=") on Coursera.</em></p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fdecision-making">Data-driven Decision Making</a> (PwC/Coursera): Partial coverage (lacks modeling) with a business focus. Introduces many tools, including R, Python, Excel, SAS, and Tableau. Four weeks in length. It has a <strong>3.5</strong>-star weighted average rating over 2 reviews. Free and paid options available.</li>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;tmpid=18061&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fdata-science-course">A Crash Course in Data Science</a> (Johns Hopkins University/Coursera): An extremely brief overview of the full process. Too brief for the purpose of this series. Two hours in length. It has a <strong>3.4</strong>-star weighted average rating over 19 reviews. Free and paid options available.</li>
<li>[The Data Scientist’s Toolbox](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;u1=cc-medium-career-guide-intro-to-data-science &amp;type=10&amp;tmpid=18061&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fdata-scientists-tools) (Johns Hopkins University/Coursera): An extremely brief overview of the full process. More of a set-up course for Johns Hopkins University’s [Data Science Specialization](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=479491.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science &amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Fspecializations%2Fjhu-data-science%2F). Claims to have 4–16 hours of content (one-four hours per week over four weeks), though one reviewer noted it could be completed in two hours. It has a <strong>3.22</strong>-star weighted average rating over 182 reviews. Free and paid options available.</li>
<li>[Data Management and Visualization](http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science &amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fdata-visualization) (Wesleyan University/Coursera): Partial process coverage (lacks modeling). Four weeks in length. Good production value. Uses Python and SAS. It has a <strong>2.67</strong>-star weighted average rating over 6 reviews. Free and paid options available.</li>
</ul>
<p>The following courses had no reviews as of January 2017.</p>
<ul>
<li><a target="_blank" href="http://cs109.github.io/2015/">CS109 Data Science</a> (Harvard University): Full process coverage in great depth (probably too in depth for the purpose of this series). A full 12-week undergraduate course. Course navigation is difficult since the course is not designed for online consumption. Actual Harvard lectures are filmed. The above data science process infographic originates from this course. Uses Python. No review data. Free.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*kzaTOFrktzFvvsIkVNP0Mw.png" alt="Image" width="800" height="358" loading="lazy">
_The featured viz on Harvard CS109’s [homepage](http://cs109.github.io/2015/" rel="noopener" target="<em>blank" title=").</em></p>
<ul>
<li><a target="_blank" href="http://click.linksynergy.com/fs-bin/click?id=SAyYsTvLiGQ&amp;subid=&amp;offerid=451430.1&amp;type=10&amp;tmpid=18061&amp;u1=cc-medium-career-guide-intro-to-data-science&amp;RD_PARM1=https%3A%2F%2Fwww.coursera.org%2Flearn%2Fdata-analytics-business">Introduction to Data Analytics for Business</a> (University of Colorado Boulder/Coursera): Partial process coverage (lacks modeling and visualization aspects) with a focus on business. The data science process is disguised as the “Information-Action Value chain” in their lectures. Four weeks in length. Describes several tools, though only covers SQL in any depth. No review data. Free and paid options available.</li>
<li><a target="_blank" href="https://www.lynda.com/Big-Data-tutorials/Introduction-Data-Science/420305-2.html">Introduction to Data Science</a> (Lynda): Full process coverage, though limited depth of coverage. Quite short (three hours of content). Introduces both R and Python. No review data. Cost depends on Lynda subscription.</li>
</ul>
<h3 id="heading-wrapping-it-up">Wrapping it Up</h3>
<p>This is the third of a six-piece series that covers the best online courses for launching yourself into the data science field. We covered programming in the <a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-start-with-one-of-these-programming-classes-fb694ffe780c/#.fhrn45v3c">first article</a> and statistics and probability in the <a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-take-a-few-of-these-statistics-classes-9bbabab098b9/#.p7pac546r">second article</a>. The remainder of the series will cover other data science core competencies: data visualization and machine learning.</p>
<p><strong><a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-start-with-one-of-these-programming-classes-fb694ffe780c/">If you want to learn Data Science, start with one of these programming classes</a></strong></p>
<p><strong><a target="_blank" href="https://www.freecodecamp.org/news/if-you-want-to-learn-data-science-take-a-few-of-these-statistics-classes-9bbabab098b9/#.p7pac546r">If you want to learn Data Science, take a few of these statistics classes</a></strong></p>
<p>The final piece will be a summary of those articles, plus the best online courses for other key topics such as data wrangling, databases, and even software engineering.</p>
<p>If you’re looking for a complete list of Data Science online courses, you can find them on Class Central’s <a target="_blank" href="https://www.class-central.com/subject/data-science">Data Science and Big Data</a> subject page.</p>
<p>If you enjoyed reading this, check out some of <a target="_blank" href="https://www.class-central.com/">Class Central</a>’s other pieces:</p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/ivy-league-free-online-courses-a0d7ae675869/"><strong>Here are 250 Ivy League courses you can take online right now for free</strong><br><em>250 MOOCs from Brown, Columbia, Cornell, Dartmouth, Harvard, Penn, Princeton, and Yale.</em></a></p>
<p><a target="_blank" href="https://www.freecodecamp.org/news/the-data-dont-lie-here-are-the-50-best-free-online-university-courses-of-all-time-b2d9a64edfac/"><strong>The 50 best free online university courses according to data</strong><br><em>When I launched Class Central back in November 2011, there were around 18 or so free online courses, and almost all of…</em></a></p>
<p>If you have suggestions for courses I missed, let me know in the responses!</p>
<p>If you found this helpful, click the ? so more people will see it here on Medium.</p>
<p><em>This is a condensed version of my <a target="_blank" href="https://www.class-central.com/report/best-intro-data-science-courses/">original article published on Class Central</a>, where I’ve included further course descriptions, syllabi, and multiple reviews.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Powerful tools for Elasticsearch data visualization & analysis ]]>
                </title>
                <description>
                    <![CDATA[ By Veronika Rovnik The goal is to turn data into information, and information into insight. ―Carly Fiorina About Kibana Kibana is a piece of data visualization software that provides a browser-based interface for exploring Elasticsearch data and n... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/powerful-tools-for-elasticsearch-data-visualization-analysis/</link>
                <guid isPermaLink="false">66d4617cd14641365a05098d</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data visualization ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Developer Tools ]]>
                    </category>
                
                    <category>
                        <![CDATA[ elasticsearch ]]>
                    </category>
                
                    <category>
                        <![CDATA[ NoSQL ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 13 Aug 2019 17:00:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2019/08/Copy-of-designing-a-scandinavian-style-home--1--1.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Veronika Rovnik</p>
<blockquote>
<p>The goal is to turn data into information, and information into insight.</p>
<p>―Carly Fiorina</p>
</blockquote>
<h1 id="heading-about-kibana">About Kibana</h1>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/Kibana-Color-Lockup.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p><a target="_blank" href="https://www.elastic.co/products/kibana/?r=fr4">Kibana</a> is a piece of <strong>data visualization software</strong> that provides a browser-based interface for <em>exploring Elasticsearch data</em> and <em>navigating the Elastic Stack</em> — a collection of open-source products (Elasticsearch, Logstash, Beats, and others).</p>
<p>While Logstash and Bits deliver data to Elasticsearch, <strong>Kibana</strong> <em>opens the window into the Elastic Stack</em>, allowing you to track the <em>health of your cluster</em>, perform <em>log</em> and <em>time-series analysis</em>, detect anomalies in the data with <em>unsupervised machine learning</em>, discover relationships using <em>graphs</em> and, most importantly, extract insights from the Elasticsearch data with <strong>visualizations</strong> that can be combined together in a <em>custom interactive dashboard</em>.</p>
<p>Today I’d like to show you how to create a stunning <strong>dashboard</strong> and a tabular <strong>report</strong> based on the Elasticsearch data.</p>
<p>Roll up your sleeves and let’s start!</p>
<h1 id="heading-where-to-start">Where to start</h1>
<p>The <strong>Home</strong> page is the place where everything starts.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/0_fpQgMCmvLqiFhur2.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>Here you can decide which actions to take next. The available functionality can be divided into two logical sections:</p>
<ul>
<li><strong>Visualizing</strong> and <strong>exploring</strong> the data. Here you can create a new dashboard, visualization or presentation, build a machine learning model, analyze relationships in your data using <strong>graphs</strong>, and more.</li>
<li><strong>Managing</strong> the <strong>Elastic Stack</strong>: configure your spaces, analyze logs of an application, configure security settings, etc.</li>
</ul>
<p>We’ll focus on the process of creating visualizations and adding them to the dashboard.</p>
<h1 id="heading-how-to-create-a-dashboard-in-kibana">How to create a dashboard in Kibana</h1>
<p>Let me get you a feel for how easy it is to set up a <em>rich dashboard and start reporting.</em></p>
<p>The first essential step to take is to <em>import your data</em> into Kibana. Multiple options for adding data are at your disposal — you can choose the one that works best for you:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/0_sRsqKuv7Ptw0Clt1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>For demonstration purposes, I’ve selected the sample data.</p>
<p>To design your first data visualizations and combine them into the dashboard, open the <strong>Visualize</strong> page. Here you can create, modify and view the existing visualizations.</p>
<p>What will strike you at once is the abundance of <strong>visualization types</strong> you can choose from.</p>
<p>After you’ve selected the one you need, choose an index pattern as a source so as to inform Kibana about your index. Let’s choose <code>kibana_sample_data_flights</code> and start creating a horizontal bar chart.</p>
<p>Now you can apply a metric aggregation for the Y-axis and a bucket aggregation for the X-axis. Here is a <a target="_blank" href="https://www.elastic.co/guide/en/kibana/7.1/xy-chart.html">list</a> of all available aggregations for charts.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/HorizontalBarChartKibana.gif" alt="Image" width="600" height="400" loading="lazy">
<em>Creating a horizontal bar chart in Kibana</em></p>
<p>Optionally, you can customize the colors of the visualization.</p>
<p><strong>Filtering</strong> is another mighty feature of Elasticsearch and Kibana. It provides a way to visualize only a selected subset of documents.</p>
<p>See how you can apply filters to the fields based on logical conditions:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/FilteringBarChartKibana.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>As you see, Kibana provides a straightforward way of filtering the data via the comfy interface. Along with that, you can choose how to filter the data — either by using the <strong>Kibana Query Language</strong> (a simplified query syntax) or <strong>Lucene</strong>.</p>
<p>To allow end-users to filter the data interactively, you can add <strong>control</strong> widgets — special elements of the dashboard which allow filtering the data simply by clicking them.</p>
<p>Another feature I’d like to highlight is the <strong>advanced filtering by dates</strong> and the ability to set time intervals for refreshing the data in the dashboard.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/0_dO63HLLppucTAw4M.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>The good thing is that visualizations are <strong>reusable</strong>. After creating it, you can <strong>save your result</strong> and add it to the dashboard any time as well as <strong>share</strong> with your colleagues given they have access to your Kibana instance.</p>
<p><img src="https://miro.medium.com/max/38/0*sIPxndN5TdA8xOEH?q=20" alt="Image" width="600" height="400" loading="lazy">
<em>Saving a visualization in Kibana</em></p>
<p>After arranging all the visualization elements on a single page, you can export the final dashboard to <strong>PNG</strong> or <strong>PDF</strong> format. This is what makes the dashboards portable — it’s easy to share them across departments in no time.</p>
<p>Let’s look at an example of the dashboard you can create:</p>
<p><img src="https://miro.medium.com/max/38/0*N3TOSp4x8RObP9O-?q=20" alt="Image" width="600" height="400" loading="lazy">
<em>Interacting with the dashboard in Kibana</em></p>
<p>To my mind, the principal features which make each dashboard special are <strong>interactivity</strong> and <strong>expressiveness</strong>. With it, you can communicate business metrics efficiently.</p>
<h1 id="heading-personal-impression">Personal impression</h1>
<p>The visualizations in Kibana ideally perform the tasks they are designed for. What is more, all the visualizations are <strong>eye-catching</strong> and you can tailor them according to your design ideas. The entire process of creating a dashboard in Kibana is meant to be <em>fast</em> and <em>efficient</em> — and it is so due to the Kibana’s user-friendly and intuitive interface.</p>
<p>On the other hand, I’ve felt that some functionality is missing here.</p>
<p>When working with data, one of the effective exploratory techniques you can apply is <strong>slicing</strong> and <strong>dicing</strong> your data before getting to know which aspects of the data to pay attention to. To my mind, the data table widget isn’t the best option — it presents the data in a flat table which doesn’t support a multi-dimensional view of the data. But playing with data should be done interactively and fast.</p>
<p>And this is where a <strong>pivot table control</strong> comes into play. After searching for available solutions, my choice fell on one open-source <strong>plugin</strong> called <a target="_blank" href="https://www.flexmonster.com/?r=fr4">Flexmonster</a>. It handles connecting to the <em>Elasticsearch index</em> and allows creating <strong>tabular reports</strong> based on the data from its documents. Along with that, integrating with Kibana is smooth — the only thing required to get started is to install a plugin by running one line of code in the command line. You can find more details on <a target="_blank" href="https://github.com/flexmonster/pivot-kibana">GitHub</a>. Before using it, I recommend making sure that your Kibana and Elasticsearch instances are of the same version.</p>
<p>Once you set up a tool, you are ready to use all available features for searching in-depth insights.</p>
<h1 id="heading-features-for-analytics-and-reporting">Features for analytics and reporting</h1>
<p>Flexmonster Pivot provides fast access to the most essential reporting functionality. Its toolbar allows connecting to the data source, loading previously saved reports, exporting reports to <strong>PDF</strong>, <strong>Excel</strong>, <strong>HTML</strong>, <strong>CSV</strong>, and images. Besides, I’ve managed to quickly switch between two different modes — the grid and the charts. Cells formatting options include <strong>conditional</strong> and <strong>number formatting</strong>. The field list deserves particular attention — here you can select hierarchies to rows, columns, measures, and report filters. There is also the <em>search input field</em> which is helpful if the index has a long list of fields.</p>
<p>One of the features I’d like to highlight is the ability to <strong>drag and drop</strong> the hierarchies right on the grid. Thereby, you can change the slice completely via the UI.</p>
<p>Another one is the <strong>drill-through</strong> feature — it helps to know which records stand behind the aggregated values.</p>
<h1 id="heading-working-with-a-pivot-table">Working with a pivot table</h1>
<p>Let me show you how to create a report based on the Elasticsearch data:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2019/08/ReportInKibanaDevTo2.gif" alt="Image" width="600" height="400" loading="lazy"></p>
<p>While testing the tool, I’ve managed to <em>aggregate</em> and <em>filter</em> the data, <em>sort</em> the values on the grid and save the results to continue working with the report later. Plus, exporting works well — it’s easy to share the reports with teammates.</p>
<h1 id="heading-bringing-it-all-together">Bringing it all together</h1>
<p>Today I’ve covered the benefits Kibana provides for visualization of Elasticsearch data. You’ve been able to make sure how dashboards can empower the analysis process.</p>
<p>To my mind, a pivot table is a good tool which enables you to benefit from exploring data before teasing out the answers to complex questions.</p>
<p>Flexmonster nicely complements the available functionality of Kibana - the reports you are creating with it are insightful, customizable and can be easily shared across departments. </p>
<p>Working together, both tools have all the potential to boost your storytelling. </p>
<p>I encourage you to give such a combination a try.</p>
<h2 id="heading-whats-next">What’s next?</h2>
<ul>
<li><a target="_blank" href="https://www.elastic.co/products/stack/reporting/?r=fr4">Reporting with Kibana</a></li>
<li><a target="_blank" href="https://www.elastic.co/guide/en/kibana/current/createvis.html">Creating a visualization in Kibana</a></li>
<li><a target="_blank" href="https://www.flexmonster.com/demos/connect-elasticsearch/?r=fr4">Pivot Table for Elasticsearch</a></li>
<li><a target="_blank" href="https://www.flexmonster.com/blog/new-pivot-table-for-kibana/?r=fr4">How to add a Pivot Table to Kibana</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to protect your information with Local Sheriff ]]>
                </title>
                <description>
                    <![CDATA[ By Konark Modi Watching them watching us What is a TellTale URL ? A URL is the most commonly tracked piece of information. The innocent choice to structure a URL based on page content can make it easier to learn a users’ browsing history, address, h... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/local-sheriff-watching-them-watching-us-5eacf3eb00ca/</link>
                <guid isPermaLink="false">66c35aa371e87702d4e5b6f5</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ privacy ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 01 May 2019 18:12:00 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*S5zyXVDrpVR24gnN9Vs0Tg.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Konark Modi</p>
<h4 id="heading-watching-them-watching-us">Watching them watching us</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bal86HLtSK3DaHmGSDs2koKIIaTAzzAp23wY" alt="Image" width="800" height="400" loading="lazy"></p>
<h3 id="heading-what-is-a-telltale-url"><strong>What is a TellTale URL ?</strong></h3>
<p>A URL is the most commonly tracked piece of information. The innocent choice to structure a URL based on page content can make it easier to learn a users’ browsing history, address, health information or more sensitive details. They contain sensitive information or can lead to a page which contains sensitive information.</p>
<p>We call such URLs as TellTaleURLs.</p>
<p>Let’s take a look at some examples of such URLs.</p>
<h3 id="heading-example-1"><strong>EXAMPLE #1:</strong></h3>
<p><strong>Website</strong>: <em>donate.mozilla.org (Fixed)</em></p>
<p>After you have finished the payment process on <em>donate.mozilla.org</em>, you are redirected to a “thank you” page. If you look carefully at the URL shown in the below screenshot, it contains some private information like <em>email, country, amount, payment method.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/yFTLh7ZBCOWDlqold7QyIGe9LCTe02pOzgsT" alt="Image" width="800" height="485" loading="lazy">
<em>PII in URL on donate.mozilla.org</em></p>
<p>Now because this page loads some resources from third-parties and the URL is not sanitised, the same information is also shared with those third-parties via referrer and as a value inside payload sent to the third-parties.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/qQpzQGwGsPEJDchKDOrU8ZKXxM7ALe4QO5DI" alt="Image" width="800" height="494" loading="lazy">
<em>URL with PII shared when fonts being loaded from Google Apis.</em></p>
<p>In this particular case, there were 7 third-parties with whom this information was shared.</p>
<p>Mozilla was prompt to fix these issues, more details can be found here: <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1516699">_https://bugzilla.mozilla.org/show<em>bug.cgi?id=1516699</em></a></p>
<h3 id="heading-example-2">EXAMPLE #2:</h3>
<p><strong>Website</strong>: trainline.eu, <em>JustFly.com (Last checked: Aug’18)</em></p>
<p>Once you finish a purchase like train tickets / flight tickets, you receive an email which has a link to manage your booking. Most of the time, when you click on the link, you are shown the booking details - without having to enter any more details like booking code, username/password.</p>
<p>This means that the URL itself contains some token which is unique to the user and provides access to the users’ booking.</p>
<p>It so happens that these URLs are also shared with third-parties, giving these third-parties <a target="_blank" href="https://medium.freecodecamp.org/how-airlines-dont-care-about-your-privacy-case-study-emirates-com-6271b3b8474b">highly sensitive data</a> and <a target="_blank" href="https://cliqz.com/en/magazine/lufthansa-data-leak-what-a-single-url-can-reveal-about-you">access to your bookings</a>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/B6qA9nsCDe3WcNG8MseCRhq0lnG7I2gSG08K" alt="Image" width="800" height="383" loading="lazy">
<em>JustFly.com leaking bookingID to 10 third-party domains</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Sgg5O7vWB-Bh4E5NuAW3wQkr0hkQiUbQN2qI" alt="Image" width="800" height="485" loading="lazy">
<em>trainline.eu sharing booking token with 17 third-party domains.</em></p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/dKN254bU1AgMCf21rWvWc0u6ge6iscwRKT5y" alt="Image" width="800" height="537" loading="lazy">
<em>URL with token being shared via Ref and inside the payload.</em></p>
<h3 id="heading-example-3">EXAMPLE #3:</h3>
<p><strong>Website</strong>: <em>foodora.de, grubhub.com (Last checked: Aug’18)</em></p>
<p>One of the pre-requisites to order food online is entering the address where you want the food to be delivered.</p>
<p>Some popular food delivery websites, convert the address to fine latitude-longitude values and add them to the URL.</p>
<p>The URL is also shared with third-parties, potentially leaking where the user lives.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/zh6XHBxE7ubGBB8l3of-fFhYuNhvQodJGRAf" alt="Image" width="800" height="478" loading="lazy">
<em>Foodora leaking address details to 15 third-party domains.</em></p>
<blockquote>
<p>To be clear, it’s not just these websites that suffer from such leaks. This problem exists everywhere - it’s a default situation, not a rarity. We’ve seen it with Lufthansa, Spotify, Flixbus, Emirates, and even with medical providers.</p>
</blockquote>
<h3 id="heading-risks-of-telltale-urls">Risks of TellTale URLs:</h3>
<ul>
<li>Websites are carelessly leaking sensitive information to plethora of third-parties.</li>
<li>Most often without users’ consent.</li>
<li>More dangerously: Most websites are not aware of these leaks while implementing third-party services.</li>
</ul>
<h3 id="heading-are-these-problems-hard-to-fix">Are these problems hard to fix?</h3>
<p>As a Software Engineer who has worked for some of the largest eCommerce companies, I understand the need to use third party services for optimising and enhancing not only the Digital Product but also how users interact with the product.</p>
<p>It is not the usage of third party services that is of concern in this case but the implementation of these services. Owners should always have the control of their website and what the website shares with third party services.</p>
<p>It is this control that needs to be exercised to limit the leakage of User information.</p>
<p>It is not a mammoth task, it is just a matter of commitment to preserving the basic right to privacy.</p>
<p>For example:</p>
<ol>
<li>Private pages should have <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta">noindex meta tags</a>.</li>
<li>Limit the presence of third-party services on private pages.</li>
<li><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy">Referrer-Policy</a> on pages with sensitive data.</li>
<li>Implement CSP and SRI. Even with a huge footprint of third-party services <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP">CSP</a>, <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity">SRI</a> are not enabled on majority of the websites.</li>
</ol>
<h3 id="heading-introducing-local-sheriff">Introducing Local Sheriff:</h3>
<p>Given that such information leakage is dangerous to both users and the organisations, then why is it a wide-spread problem?</p>
<p>One big reason that these issues exist is lack of awareness.</p>
<p>A good starting point for websites is to see what information is being leaked or detect presence of TellTaleURLs.</p>
<p>But in order to find out if the same is happening with the websites you maintain or visit, you need to learn some tools to inspect network traffic, understand first-party — third-party relationship and then make sure you have these tools open during the transaction process.</p>
<p>To help bridge this gap, we wanted to build a tool with the following guidelines:</p>
<ul>
<li>Easy to install.</li>
<li>Monitors and stores all data being exchanged between websites and third-parties — Locally on the user machine.</li>
<li>Helps identify the users which companies are tracking them on the internet.</li>
<li>Interface to search information being leaked to third-parties.</li>
</ul>
<p>Given the above guidelines, browser extension seemed like a reasonable choice. After you install Local-Sheriff, in the background:</p>
<ol>
<li>Using the WebRequest API, it monitors interaction between first-party and third-party.</li>
<li>Classifies what URL is first-party and third-party.</li>
<li><p>Ships with a copy of database from <a target="_blank" href="https://whotracks.me/">WhoTracksMe</a>. To map which domain belongs to which company.</p>
</li>
<li><p>Provides an interface you can search for values that you think are private to you and see which websites leak it to which third-parties. Eg: name, email, address, date of birth, cookie etc.</p>
</li>
</ol>
<h3 id="heading-revisiting-example-1">Revisiting EXAMPLE #1</h3>
<p><strong>Website:</strong> <em>donate.mozilla.org</em></p>
<ul>
<li>The user has Local-Sheriff installed and donates to mozilla.org.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/xrealtqpe6MuxuFVU6nqyaWR3Z6FZm-J4uwv" alt="Image" width="800" height="485" loading="lazy">
<em>PII in URL on donate.mozilla.org</em></p>
<ul>
<li>Clicks on the icon to open search interface.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/oQTbZxMUMeO0l83pyyvQca-EWggpcB1tMn7Z" alt="Image" width="352" height="154" loading="lazy">
<em>Local sheriff icon.</em></p>
<ul>
<li>Enters emailID used on the website donate.mozilla.org.</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/XU1a1DfPQyJLtvGYM52swvVEyVD5Xj1FH91R" alt="Image" width="800" height="458" loading="lazy">
<em>Search interface Local-Sheriff</em></p>
<p>It can be seen that email address used at the time of donation was shared with <strong>~7 third-party domains.</strong></p>
<p>You can try it yourselves by installing it:</p>
<ul>
<li><strong>Firefox:</strong> <a target="_blank" href="https://addons.mozilla.org/de/firefox/addon/local-sheriff/">https://addons.mozilla.org/de/firefox/addon/local-sheriff/</a></li>
<li><strong>Chrome:</strong> <a target="_blank" href="https://chrome.google.com/webstore/detail/local-sheriff/ckmkiloofgfalfdhcfdllaaacpjjejeg">https://chrome.google.com/webstore/detail/local-sheriff/ckmkiloofgfalfdhcfdllaaacpjjejeg</a></li>
</ul>
<p><strong>Resources:</strong></p>
<ul>
<li><strong>More details</strong>: <a target="_blank" href="https://www.ghacks.net/2018/08/12/local-sheriff-reveals-if-sites-leak-personal-information-with-third-parties/"><em>https://www.ghacks.net/2018/08/12/local-sheriff-reveals-if-sites-leak-personal-information-with-third-parties/</em></a></li>
<li><strong>Source Code</strong>: <a target="_blank" href="https://github.com/cliqz-oss/local-sheriff"><em>https://github.com/cliqz-oss/local-sheriff</em></a></li>
<li><strong>Conferences:</strong> <a target="_blank" href="https://www.defcon.org/html/defcon-26/dc-26-demolabs.html"><em>Defcon 26 Demo Labs</em></a> _, <a target="_blank" href="https://fosdem.org/2019/schedule/event/web_extensions_exposing_privacy_leaks/">FOSDEM 2019</a>_</li>
<li><strong>Code:</strong> <a target="_blank" href="https://github.com/cliqz-oss/local-sheriff">https://github.com/cliqz-oss/local-sheriff</a></li>
<li><strong>Chrome store:</strong> <a target="_blank" href="https://chrome.google.com/webstore/detail/local-sheriff/ckmkiloofgfalfdhcfdllaaacpjjejeg">https://chrome.google.com/webstore/detail/local-sheriff/ckmkiloofgfalfdhcfdllaaacpjjejeg</a></li>
</ul>
<p>Thanks for reading and sharing ! :)</p>
<p>If you liked this story, feel free to ??? a few times (Up to 50 times. Seriously).</p>
<p>Happy Hacking !</p>
<p><a target="_blank" href="https://twitter.com/konarkmodi">- Konark Modi</a></p>
<p><strong><em>Credits:</em></strong></p>
<ul>
<li>_Special thanks to <a target="_blank" href="https://twitter.com/Pythux">Remi</a> , <a target="_blank" href="https://twitter.com/Pi_Modi">Pallavi</a> for reviewing this post :)_</li>
<li><em>Title “Watching them watching us “ comes from a joint talk between Local Sheriff and <a target="_blank" href="https://trackula.org/en/">Trackula</a> at FOSDEM 2019.</em></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How serverless stream processing will make decision-making easier ]]>
                </title>
                <description>
                    <![CDATA[ By Chamath Kirinde About a year ago, we started being a part of the digital transformation with the first ever cloud-based IDE for serverless development. It was no cakewalk — we’ve been burning the candle at both ends trying to cover the majority fr... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-serverless-stream-processing-will-make-decision-making-easier-d929502b43c8/</link>
                <guid isPermaLink="false">66c34eba0fa3812cdd5eaa06</guid>
                
                    <category>
                        <![CDATA[ analytics ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Productivity ]]>
                    </category>
                
                    <category>
                        <![CDATA[ serverless ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 09 Apr 2019 19:08:22 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*0FKhwNV-o-OEiuFqSz_tSQ.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Chamath Kirinde</p>
<p>About a <a target="_blank" href="https://globenewswire.com/news-release/2018/02/06/1333797/0/en/SLAppForge-Announces-Sigma-a-Cloud-IDE-for-Serverless-Computing.html">year ago</a>, we started being a part of the digital transformation with the first ever cloud-based <a target="_blank" href="https://sigma.slappforge.com/?utm_source=freecodecamp&amp;utm_medium=blog&amp;utm_campaign=guide&amp;utm_content=Chamath">IDE</a> for serverless development. It was no cakewalk — we’ve been burning the candle at both ends trying to cover the majority from AWS’s <a target="_blank" href="https://aws.amazon.com/serverless/#The_AWS_Serverless_Platform">serverless stack</a>. Working with AWS Kinesis made me realise the <a target="_blank" href="https://chummycharms.blogspot.com/2018/03/why-serverless-why-now.html">beauty of serverless</a> — of course, the exposure to streaming data with <a target="_blank" href="https://chummycharms.blogspot.com/2017/10/real-time-activity-tracking-with-kafka.html">Kafka</a> spared me some time going through the rudiments.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/IBLdvoo4R41bu17WA8x0Wy7gia9EtFjG4BzO" alt="Image" width="800" height="533" loading="lazy">
_Rational decision making: Photo by [Unsplash](https://unsplash.com/photos/o4c2zoVhjSw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="_blank" title=""&gt;Raj Eiamworakul on &lt;a href="https://unsplash.com/search/photos/rational-decisions?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="<em>blank" title=")</em></p>
<h3 id="heading-tldr">TL;DR</h3>
<p>Did you ever wonder…</p>
<ul>
<li>How <strong>“Google Search”</strong> suggests things to you when you’re half-typing your query?</li>
<li>How <strong>“Cheapest Airlines”</strong> start to appear everywhere after you searched for a country?</li>
<li>How online role-playing games adjust according to your decisions?</li>
<li>How gambling sites predict the odds of a live game?</li>
<li>Why were <a target="_blank" href="https://www.cbssports.com/nba/news/warriors-wearable-weapon-devices-to-monitor-players-while-on-the-court/">Curry and Thompson benched</a> while Portland was handing the Warriors their worst loss in a 73-win NBA season?</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/4vE1DrCz1W1TQwQIWA3IwAsGTeVgcT9Nh-7k" alt="Image" width="1600" height="707" loading="lazy">
<em>Google’s (sometimes so annoying) query autocomplete</em></p>
<p>The power of real-time streaming data analytics is astonishing indeed. Now, since serverless technology is gaining some momentum, maybe you won’t have to worry about taking risky decisions on your own at all. This post covers the basics of “Serverless Streaming Data Processing” and how it will be an influential component of our decision making in the future.</p>
<h3 id="heading-data-data-everywhere">Data, Data Everywhere</h3>
<p>Life is an endless series of events. The technology around us has made it a stream of digital actions emitting streams of data. If you turn back and investigate your life very carefully, you’ll see the never-ending string of data you have generated with your every digital action. It could be a lot to digest at first, but let’s explore some scenarios and try to find what applies to you and me.</p>
<ul>
<li>Online banking and convenient e-commerce purchasing capabilities</li>
<li>Ride-sharing, modern-day traveling and transportation</li>
<li>Industrial equipment and agricultural use cases like monitored machinery, autonomous tractors, and precision farming</li>
<li>Automated power generation and smart grids, Zero-net Buildings, Smart metering</li>
<li>Real-estate property recommendations based on geo-location, predictive maintenance</li>
<li>Online dating and matchmaking relying on complex personality patterns and attribute distribution</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/UoE9uNA5mdznpmW5aFLsmjQZkO4K5JibcOSh" alt="Image" width="400" height="400" loading="lazy">
<em>Rational Romance: Will you be my Valentine?</em></p>
<ul>
<li>Financial trading according to the real-time changes in the stock market, analytical risk management</li>
<li>Movies, songs and other digital media with a better experience depending on the demographics, preference, and emotions</li>
<li>Improved web and mobile application experience based on usage</li>
<li>Dynamic and personalised experiences in online gaming</li>
<li>Enhanced social media experiences with hyper-personalisation and predictive analytics</li>
<li>Telemetry from connected devices, or remote data centres from geospatial or spatial services like weather, resource assessment</li>
<li>Sports analytics to enhance the players’ performance reducing health risks</li>
</ul>
<p><img src="https://cdn-media-1.freecodecamp.org/images/VuM87-7-xwLq12dD8IBIKTsxcwY18TqGwyfH" alt="Image" width="718" height="793" loading="lazy">
<em>Welcome Analytics</em></p>
<p>All these events produce data — lots of it. Due to the frequency of this data emission, it has become an increasing burden to the digital space.</p>
<h3 id="heading-what-is-streaming-data">What is Streaming Data?</h3>
<p>In a <a target="_blank" href="https://www.domo.com/learn/data-never-sleeps-6">survey</a> conducted last year about data, it’s estimated that with the current pace of data generation,</p>
<blockquote>
<p>1.7 MB of data will be created every second for every person on earth by 2020</p>
</blockquote>
<p>Data that is poured out continuously by a gazillion sources every second has become a fact we can’t just ignore. Big Data discipline was an eye-opener for the tech world to apply this once irritating data to do something useful. This same irksome data is collected and analysed by a new species, namely data scientists ?. Due to the nature of continuity and often being in small sizes (order of Kilobytes) these data flows — usually referred by the moniker streaming data — are collected simultaneously as records and sent in for further processing.</p>
<h3 id="heading-from-stream-processing-to-smart-decisions">From stream processing to smart decisions</h3>
<p>A streaming data processing structure is usually comprised of two layers — a storage layer and a processing layer. The former is responsible for ordering large streams of records and facilitating persistence and accessibility at high speeds. The processing layer takes care of data consumption, executing computations, and notifying the storage layer to get rid of already processed records. Data processing is done for each record incrementally or by matching over sliding time windows. Processed data is then subjected to streaming analytics operations and the derived information is used to make context-based decisions.</p>
<p>For instance, companies can track public sentiment changes on their products by analysing social media streams continuously. The world’s most influential nations can <a target="_blank" href="https://www.bbc.com/news/technology-46590890">intervene in decisive events</a> like presidential elections in other powerful countries. And mobile apps can offer personalised recommendations for products based on geo-location of devices and user emotions.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QxndNC2SRx15iRq02C8qQBWHEAqe5v01WemR" alt="Image" width="800" height="244" loading="lazy">
<em>Poor data analytics — Poor decisions</em></p>
<p>Most applications collect a portion of their data at the outset to produce simple summary reports and take simple decisions such as triggering alarms or calculating a moving average value. As time flies by, these become more and more sophisticated, and companies might want to access profound insights to perform intricate activities in turn with the aid of Machine Learning algorithms and data analysis techniques.</p>
<p>The continual growth of data has made data scientists work around the clock to come up with trailblazing solutions to utilise as much data as possible to fabricate alternate futures with better decisions.</p>
<h3 id="heading-service-facilitators">Service Facilitators</h3>
<p>Adoption of the ideal cloud provider to fit organisational requirements can be overwhelming. However, all the major cloud service providers are equipped with competitive options to accommodate stream processing due to its ubiquitous impact. Here’s a list of commonly used serverless services to bolster enterprise-grade applications, highly relying on streaming data.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/5cstIiKD2o7dl82UVruDBBvv8NmqHTqI0rRE" alt="Image" width="800" height="1880" loading="lazy">
<em>Infographic: Serverless Stream Processing Components</em></p>
<h3 id="heading-live-examples">Live Examples</h3>
<p>Many companies use insights from stream analytics to enhance the visibility of their businesses. This allows them to deliver customers a personalised experience. Additionally, near real-time transparency gives these firms the flexibility to promptly address emergencies.</p>
<p>The emerging serverless architecture has driven all the leading cloud service platforms to present complementary solutions. Stream processing was made available for serverless application development with fully-managed, cloud-based services for real-time data processing over large Distributed Data Streams.</p>
<h4 id="heading-1-hyper-personalised-television">1. Hyper-personalised Television</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/3tdMjLGeH4Oaf2zq84AKbmJvm1H-ejVMEK0H" alt="Image" width="800" height="449" loading="lazy">
_Netflix: Photo by [Unsplash](https://unsplash.com/@jenskreuter?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="_blank" title=""&gt;Jens Kreuter on &lt;a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="<em>blank" title=")</em></p>
<p>Netflix, the leading online television network in the world, developed a solution which centralises their flow logs <a target="_blank" href="https://aws.amazon.com/solutions/case-studies/netflix-kinesis-streams/">using Amazon Kinesis Streams</a>. As a system processing billions of traffic flows every day, this eliminates plenty of complexity for them because of the absence of a database in the architecture. Due to the high scalability and lightning speed, they can discover and address issues as they arise, and monitor the application on a massive scale.</p>
<p>With the upgraded recommendation algorithm, video transcoding, and licensing popular media, this subsequently grants a seamless experience to subscribers. With the exponential growth of subscribers, the company’s responsibilities increase by the day. However, nothing seems to be a problem for Netflix since they are considered to have a <a target="_blank" href="https://www.forbes.com/sites/danpontefract/2019/02/04/the-netflix-decision-making-model-is-why-theyre-so-successful/#11a4e67273bc">sound decision-making model</a>.</p>
<h4 id="heading-2-improving-the-decisions-of-the-decision-makers">2. Improving the decisions of the decision makers</h4>
<p>As a leading source of integrated and intelligent information for businesses and professionals, Thomson Reuters provide their services to decision makers in a wide range of domains like financing and risk, science, legal, technology. This company built an in-house analytics engine to take full control of data and moved to AWS because they were familiar with its capabilities and scale.</p>
<p>The new real-time <a target="_blank" href="https://aws.amazon.com/solutions/case-studies/thomson-reuters/">pipeline attached to Amazon Kinesis</a> stream produces better results in perceptive customer experience with accurate economic forecasts, financial trends for beneficiaries including a range of government activities.</p>
<h4 id="heading-3-unicorn-a-solution-to-traffic-congestion">3. Unicorn: a solution to traffic congestion</h4>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Pz294qBcYfaEhKVPStwmt7eBxJ2YYAqVJsnL" alt="Image" width="800" height="526" loading="lazy">
_Unicorn: Photo by [Unsplash](https://unsplash.com/@boudewijn_huysmans?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="_blank" title=""&gt;Boudewijn Huysmans on &lt;a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral" rel="noopener" target="<em>blank" title=")</em></p>
<p>Jakarta has become a heavily congested city where the motorcycle has been deemed the most efficient mode of transport. To exploit this business opportunity, GO-JEK — one of the few unicorn businesses in Southeast Asia — started as a call centre for motorcycle taxi bookings. However, to meet the demand in exceeding expectations, the company had to consider expansion. Now with the support of Google Cloud Professional Services, the business architecture built on Cloud Dataflow for stream inference enables them to predict changes in demand effectively.</p>
<p>There are more stories about how cloud platforms like <a target="_blank" href="https://aws.amazon.com/lambda/resources/customer-case-studies/">AWS</a>, <a target="_blank" href="https://cloud.google.com/customers/#/products=Big_Data_Analytics,Marketing_Analytics">Google</a>, <a target="_blank" href="https://azure.microsoft.com/en-us/case-studies/?service=stream-analytics%7Cevent-hubs&amp;solution=serverless">Microsoft Azure</a>, and <a target="_blank" href="https://console.bluemix.net/docs/openwhisk/openwhisk_use_cases.html#openwhisk_event_processing">IBM Cloud</a> are exploited by companies to make their clients’ lives better and secure.</p>
<h3 id="heading-limitations-of-serverless-stream-processing">Limitations of Serverless Stream Processing</h3>
<p>Serverless stream processing is increasingly becoming a vital part of decision-making engines. However, with the current set of features, it’s not the ideal solution for some scenarios. Implementing real-time analytics for sliding windows and temporal event patterns is not a course for the faint-hearted.</p>
<p>The best way to assimilate never-ending data of this magnitude is through real-time dashboards which requires additional data organisation and persisting. These manoeuvres introduce undesirable latency and data management issues into the context. However, technology is evolving and trying to catch up to the speeds with integration using advanced cloud data management techniques to produce materialised views.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/nT-vi3LfbSp5CwbMKlR-teyFq5br9oem6MYu" alt="Image" width="729" height="741" loading="lazy">
<em>Security: A major concern</em></p>
<p>Stream Processing often uses a time-based or record-based window to be processed in contrast to the batch-based processing, which can lead to challenges in use cases that require query re-execution.</p>
<p>Nowadays, application requirements grow beyond aggregated analytics. Increasing the window size seems to be an appropriate temporary solution, but it develops another intractable problem — Memory Management. Modern-day solutions usually provide advanced memory management and scheduling techniques to overcome this, but the world will see further improvements.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>All in all, it’s apparent that serverless stream processing has been playing a prominent role around us without us even knowing. With the power of serverless data stream processing, applications can evolve from traditional batch processing to real-time analytics. The revelation of profound insights will result in effective decision making without having to manage infrastructure.</p>
<p>Even today, many organizations practise orthodox decision-making strategies based on the analytics derived using the big data clusters that belonged to <strong>THE PAST</strong>. New horizons of serverless and real-time data processing are now equipped with the power to make effective decisions and create a more productive, relevant, and most importantly secure world around you.</p>
<p>Will serverless stream processing make emotional decision making obsolete and computerized rational judgement the norm?</p>
<p>What do you think?</p>
<h3 id="heading-what-should-you-do-now">What should you do now?</h3>
<ul>
<li><strong>Clap.</strong> Appreciate and let others find this article.</li>
<li><strong>Comment.</strong> Share your thoughts.</li>
<li><strong>Follow me.</strong> <a target="_blank" href="https://medium.com/@jchamath">Chamath Kirinde</a> to receive updates on articles like this.</li>
<li><strong>Keep in touch.</strong> <a target="_blank" href="https://www.linkedin.com/in/jchamath/">LinkedIn</a>, <a target="_blank" href="https://twitter.com/JChamath">Twitter</a>, <a target="_blank" href="https://chummycharms.blogspot.com">Chummy Charms</a></li>
<li><strong>Think Serverless.</strong> <a target="_blank" href="https://slappforge.com/blog">SLAppForge</a></li>
</ul>
<p><em>Originally published at <a target="_blank" href="https://chummycharms.blogspot.com/2019/03/serverless-stream-processing.html">chummycharms.blogspot.com</a>.</em></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ For the love of SQL: why you should learn it and how it’ll help you out ]]>
                </title>
                <description>
                    <![CDATA[ By Matthew Oldham I recently read a great article by the esteemed @craigkerstiens describing why he feels SQL is such a valuable skill for developers. This topic really resonated with me. It lined up well with notes I’d already started sketching out ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/for-the-love-of-sql-why-you-should-learn-it-and-how-itll-help-you-out-22fe307a253/</link>
                <guid isPermaLink="false">66d46012ffe6b1f641b5fa1e</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ database ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 03 Apr 2019 21:22:53 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*wdnZPs8tLOGbEfECpoh5Kg.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Matthew Oldham</p>
<p>I recently read <a target="_blank" href="http://www.craigkerstiens.com/2019/02/12/sql-most-valuable-skill/">a great article</a> by the esteemed <a target="_blank" href="http://twitter.com/craigkerstiens">@craigkerstiens</a> describing why he feels SQL is such a valuable skill for developers. This topic really resonated with me. It lined up well with notes I’d already started sketching out for a similar article about developing a love for data.</p>
<p>The more I fleshed out my topic, however, the more I realized that many of my points and examples seemed to be centering around SQL. Reading Craig’s article convinced me to redirect my focus and talk more about why I personally have such an affinity for SQL.</p>
<p>In short, Craig makes the following assertions about SQL (and I quote):</p>
<blockquote>
<ol>
<li><p>It is valuable across different roles and disciplines</p>
</li>
<li><p>Learning it once doesn’t really require re-learning</p>
</li>
<li><p>You seem like a superhero. You seem extra powerful when you know it because of the amount of people that aren’t fluent</p>
</li>
</ol>
</blockquote>
<p>I’ve found all these points to be true in my own experience, and I’d like to recast and expand on each one.</p>
<h4 id="heading-the-versatility-effect">The Versatility Effect</h4>
<p>The SQL skillset has proven to be an extremely valuable asset in my career. In fact, I believe SQL to be the single most powerful and versatile “programming” language I know.</p>
<p>I have been able to use SQL to solve many problems, and it’s my go-to tool anytime I face a new challenge. In fact, I keep an instance of <a target="_blank" href="https://www.postgresql.org/">PostgreSQL</a> running on my laptop so I can quickly hop into my <a target="_blank" href="https://www.dbvis.com/">favorite SQL GUI</a> whenever I need to test something out.</p>
<p>Here are just some of the cool things I’ve been able to do with SQL:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/C8Q-vL5taSoDEP9SRX2Y02hLc1oA5EHLso5h" alt="Image" width="800" height="305" loading="lazy">
<em>SQL FTW!</em></p>
<p>Are you having a hard time believing that list above? I promise you there’s not an ounce of exaggeration in it. Now, are there some items there that were dependent upon other capabilities of the RDBMS I was using at the time? Sure. Regardless, each of those solutions was implemented in SQL.</p>
<h4 id="heading-the-bicycle-effect">The Bicycle Effect</h4>
<p>While Structured Query Language has certainly undergone changes and has been expanded over the years, I agree with Craig that the fundamentals have not changed. The overall level of volatility compared to other languages has been relatively low.</p>
<p>I would argue that this fact only strengthens the argument that one should invest the time to learn SQL. You can be confident that you’ll get a lot of mileage out of such an investment without having to look up the latest conventions the next time you need to use it.</p>
<p>So, learn SQL! Here are some great places to get started:</p>
<p><a target="_blank" href="http://www.sqltutorial.org/"><strong>SQL Tutorial — Essential SQL For The Beginners</strong></a><br><a target="_blank" href="http://www.sqltutorial.org/">_This SQL tutorial helps you get started with SQL quickly and effectively through many practical examples. After the…_www.sqltutorial.org</a></p>
<p>There are even interactive tutorials:</p>
<p><a target="_blank" href="https://sqlbolt.com/"><strong>SQLBolt — Learn SQL — Introduction to SQL</strong></a><br><a target="_blank" href="https://sqlbolt.com/">_SQLBolt provides a set of interactive lessons and exercises to help you learn SQL_sqlbolt.com</a></p>
<p>There are also some versatile sandboxes out there that allow you to run SQL in various dialects without having to install anything. For example, <a target="_blank" href="http://sqlfiddle.com/">SQL Fiddle</a>:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/-Yav499rZkhE8ee4JtdnkvLE4pgFfRcUUc76" alt="Image" width="800" height="438" loading="lazy">
<em>SQL Fiddle</em></p>
<p>Or, <a target="_blank" href="https://www.db-fiddle.com/">DB Fiddle</a>:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/yvN5Y8Qk9QgHq1V1A1MorV5GjCbi2Vh3Yxw-" alt="Image" width="736" height="446" loading="lazy">
<em>DB Fiddle</em></p>
<h4 id="heading-the-superhero-effect">The Superhero Effect</h4>
<p>I remember a colleague once saying he broke into a cold sweat every time he had to write SQL. ?</p>
<p>It sounds exaggerated, but SQL can be intimidating to anyone who properly regards the database as the sensitive asset it is and is not familiar with how to safely interact with it. SQL, being one of the adults in the room, also doesn’t get as much attention as other shiny new programming languages. That means that it remains a less common skillset among contemporary and emerging developers.</p>
<p>As such, having a solid understanding of SQL and the insight to see the set-based facets of a given problem or challenge provides the opportunity to be a hero.</p>
<p>One of my favorite personal experiences was helping a customer debug a slow and complex <a target="_blank" href="https://en.wikipedia.org/wiki/SAS_(software)">SAS</a> program. The goal of this program was to extract a list of state transitions from an audit table in order to measure the mean duration a widget spent in each phase of a given business workflow. The implementation of these calculations was complex and required building multiple local data sets.</p>
<p>I remember reverse engineering this program and realizing that I could solve the problem much more easily using a single SQL query and the magical <a target="_blank" href="http://www.sqltutorial.org/sql-window-functions/sql-lag/">LAG</a> window function.</p>
<p>The customer was simply blown away.</p>
<p>Not just because he learned about the LAG function, but because he saw just how powerful SQL can be.</p>
<p>An even more dramatic example was during a large data warehouse migration where I replaced an entire Java program (that took more than 20 minutes to complete!) with a single SQL query that ran in seconds. The original author of the program was shocked! That was a really good day. ?</p>
<p>So, I encourage you to dive into SQL today and broaden your skillset with one of the most versatile tools I’ve had the pleasure of working with. If you already know SQL and agree, or if I’ve convinced you to give it a try, please consider leaving me a comment.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to import Google BigQuery tables to AWS Athena ]]>
                </title>
                <description>
                    <![CDATA[ By Aftab Ansari As a data engineer, it is quite likely that you are using one of the leading big data cloud platforms such as AWS, Microsoft Azure, or Google Cloud for your data processing. Also, migrating data from one platform to another is somethi... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-import-google-bigquery-tables-to-aws-athena-5da842a13539/</link>
                <guid isPermaLink="false">66c352c5c2631756f9f063d7</guid>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data-engineering ]]>
                    </category>
                
                    <category>
                        <![CDATA[ data migration ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 11 Mar 2019 18:55:49 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*518Z4MAe36ZqeLX2LTzeDA.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Aftab Ansari</p>
<p>As a data engineer, it is quite likely that you are using one of the leading big data cloud platforms such as AWS, Microsoft Azure, or Google Cloud for your data processing. Also, migrating data from one platform to another is something you might have already faced or will face at some point.</p>
<p>In this post, I will show how I imported Google BigQuery tables to AWS Athena. If you only need a list of tools to be used with some very high-level guidance, you can quickly look at this <a target="_blank" href="https://amazon-aws-big-data-demystified.ninja/2018/05/27/how-to-export-data-from-google-big-query-into-aws-s3-emr-hive/">post that shows how to import a single BigQuery table into Hive metastore</a>. In this article, I will show one way of importing a full BigQuery project (multiple tables) into both Hive and Athena metastore.</p>
<p>There are few import limitations: for example, when you import data from partitioned tables, you cannot import individual partitions. Please check the <a target="_blank" href="https://cloud.google.com/bigquery/docs/exporting-data">limitations</a> before starting the process.</p>
<p>In order to successfully import Google BigQuery tables to Athena, I performed the steps shown below. I used AVRO format when dumping data and the schemas from Google BigQuery and loading them into AWS Athena.</p>
<p><a class="post-section-overview" href="#264f">Step 1. Dump BigQuery data to Google Cloud Storage</a></p>
<p><a class="post-section-overview" href="#3af9">Step 2. Transfer data from Google Cloud Storage to AWS S3</a></p>
<p><a class="post-section-overview" href="#c089">Step 3. Extract AVRO schema from AVRO files stored in S3</a></p>
<p><a class="post-section-overview" href="#cc2d">Step 4. Create Hive tables on top of AVRO data, use schema from Step 3</a></p>
<p><a class="post-section-overview" href="#fbf3">Step 5. Extract Hive table definition from Hive tables</a></p>
<p><a class="post-section-overview" href="#c6f6">Step 6. Use the output of Step 3 and 5 to create Athena tables</a></p>
<p>So why do I have to create Hive tables in the first place although the end goal is to have data in Athena? This is because:</p>
<ul>
<li>Athena does not support using <code>avro.schema.url</code> to specify table schema.</li>
<li>Athena requires you to explicitly specify field names and their data types in CREATE statement.</li>
<li>Athena also requires the AVRO schema in JSON format under <code>avro.schema.literal</code>.</li>
<li>You can check this AWS <a target="_blank" href="https://docs.aws.amazon.com/athena/latest/ug/avro.html">doc</a> for more details.</li>
</ul>
<p>So, Hive tables can be created directly by pointing to AVRO schema files stored on S3. But to have the same in Athena, columns and schema are required in the CREATE TABLE statement.</p>
<p>One way to overcome this is to first extract schema from AVRO data to be supplied as <code>avro.schema.literal</code> . Second, for field names and data types required for CREATE statement, create Hive tables based on AVRO schemas stored in S3 and use <code>SHOW CREATE TABLE</code> to dump/export Hive table definitions which contain field names and datatypes. Finally, create Athena tables by combining the extracted AVRO schema and Hive table definition. I will discuss in detail in subsequent sections.</p>
<p>For the demonstration, I have the following BigQuery tables that I would like to import to Athena.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/klOvEMVXS8X9k5YaxGkacXgjhdsxMGwmnupj" alt="Image" width="800" height="232" loading="lazy"></p>
<p>So, let’s get started!</p>
<h3 id="heading-step-1-dump-bigquery-data-to-google-cloud-storage">Step 1. Dump BigQuery data to Google Cloud Storage</h3>
<p>It is possible to dump BigQuery data in Google storage with the help of the Google cloud UI. However, this can become a tedious task if you have to dump several tables manually.</p>
<p>To tackle this problem, I used Google Cloud Shell. In Cloud Shell, you can combine regular shell scripting with BigQuery commands and dump multiple tables relatively fast. You can activate Cloud Shell as shown in the picture below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/o3Vj-2DY5je5jS1wZeE84Dh6OuO37CrR106-" alt="Image" width="800" height="143" loading="lazy"></p>
<p>From Cloud Shell, the following operation provides the BigQuery <code>extract</code> commands to dump each table of the “backend” dataset to Google Cloud Storage.</p>
<pre><code>bq ls backend | cut -d <span class="hljs-string">' '</span> -f3 | tail -n+<span class="hljs-number">3</span> | xargs -I@ echo bq --location=US extract --destination_format AVRO --compression SNAPPY &lt;dataset&gt;.@ gs:<span class="hljs-comment">//&lt;bucket&gt;@</span>
</code></pre><p>In my case it prints:</p>
<pre><code>aftab_ansari@cloudshell:~ (project-ark-archive)$ bq ls backend | cut -d <span class="hljs-string">' '</span> -f3 | tail -n+<span class="hljs-number">3</span> | xargs -I@ echo bq --location=US extract --destination_format AVRO --compression SNAPPY backend.@ gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/@/@-*.avro</span>
</code></pre><pre><code>bq --location=US extract --destination_format AVRO --compression SNAPPY backend.sessions_daily_phase2 gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_daily_phase2/sessions_daily_phase2-*.avro</span>
</code></pre><pre><code>bq --location=US extract --destination_format AVRO --compression SNAPPY backend.sessions_detailed_phase2 gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_detailed_phase2/sessions_detailed_phase2-*.avro</span>
</code></pre><pre><code>bq --location=US extract --destination_format AVRO --compression SNAPPY backend.sessions_phase2 gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_phase2/sessions_phase2-*.avro</span>
</code></pre><p>Please note: <code>--compression SNAPPY</code>, this is important, as uncompressed and big files can cause the <code>gsutil</code> command (that is used to transfer data to AWS S3) to get stuck. The wildcard (<strong>*</strong>) makes <code>bq extract</code> split bigger tables (&gt;1GB) into multiple output files. Running those commands on Cloud Shell, copy data to the following Google Storage directory.</p>
<pre><code>gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/table_name/table_name-*.avro</span>
</code></pre><p>Let’s do <code>ls</code> to see the dumped AVRO file.</p>
<pre><code>aftab_ansari@cloudshell:~ (project-ark-archive)$ gsutil ls gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_daily_phase2</span>
</code></pre><pre><code>gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_daily_phase2/sessions_daily_phase2-000000000000.avro</span>
</code></pre><p>I can also browse from the UI and find the data like shown below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bdhhLC9Dyuv59VpLeMhLhHNm0Ul-sAe7L8f8" alt="Image" width="800" height="289" loading="lazy"></p>
<h3 id="heading-step-2-transfer-data-from-google-cloud-storage-to-aws-s3">Step 2. Transfer data from Google Cloud Storage to AWS S3</h3>
<p>Transferring data from Google Storage to AWS S3 is straightforward. First, set up your S3 credentials. On Cloud Shell, create or edit <code>.boto</code> file ( <code>vi ~/.boto</code>) and add these:</p>
<pre><code>[Credentials]aws_access_key_id = &lt;your aws access key ID&gt;aws_secret_access_key = &lt;your aws secret access key&gt;[s3]host = s3.us-east-1.amazonaws.comuse-sigv4 = True
</code></pre><p>Please note: <strong>s3.us-east-1.amazonaws.com</strong> has to correspond with the region where the bucket is.</p>
<p>After setting up the credentials, execute <code>gsutil</code> to transfer data from Google Storage to AWS S3. For example:</p>
<pre><code>gsutil rsync -r gs:<span class="hljs-comment">//your-gs-bucket/your-extract-path/your-schema s3://your-aws-bucket/your-target-path/your-schema</span>
</code></pre><p>Add the <strong><em>-n</em></strong> flag to the command above to display the operations that would be performed using the specified command without actually running them.</p>
<p>In this case, to transfer the data to S3, I used the following:</p>
<pre><code>aftab_ansari@cloudshell:~ (project-ark-archive)$ gsutil rsync -r gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend s3://my-bucket/bq_data/backend</span>
</code></pre><pre><code>Building synchronization state…Starting synchronization…Copying gs:<span class="hljs-comment">//plr_data_transfer_temp/bigquery_data/backend/sessions_daily_phase2/sessions_daily_phase2-000000000000.avro [Content-Type=application/octet-stream]...Copying gs://plr_data_transfer_temp/bigquery_data/backend/sessions_detailed_phase2/sessions_detailed_phase2-000000000000.avro [Content-Type=application/octet-stream]...Copying gs://plr_data_transfer_temp/bigquery_data/backend/sessions_phase2/sessions_phase2-000000000000.avro [Content-Type=application/octet-stream]...| [3 files][987.8 KiB/987.8 KiB]Operation completed over 3 objects/987.8 KiB.</span>
</code></pre><p>Let’s check if the data got transferred to S3. I verified that from my local machine:</p>
<pre><code>aws s3 ls --recursive  s3:<span class="hljs-comment">//my-bucket/bq_data/backend --profile smoke | awk '{print $4}'</span>
</code></pre><pre><code>bq_data/backend/sessions_daily_phase2/sessions_daily_phase2<span class="hljs-number">-000000000000.</span>avrobq_data/backend/sessions_detailed_phase2/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avrobq_data/backend/sessions_phase2/sessions_phase2<span class="hljs-number">-000000000000.</span>avro
</code></pre><h3 id="heading-step-3-extract-avro-schema-from-avro-files-stored-in-s3">Step 3. Extract AVRO schema from AVRO files stored in S3</h3>
<p>To extract schema from AVRO data, you can use the Apache <code>avro-tools-&lt;version&amp;g</code>t;.jar wit<code>h the get</code>schema parameter. The benefit of using this tool is that it returns schema in the form you can use direct<code>ly in WITH SERDEPROP</code>ERTIES statement when creating Athena tables.</p>
<p>You noticed I got only one <code>.avro</code> file per table when dumping BigQuery tables. This was because of small data volume — otherwise, I would have gotten several files per table. Regardless of single or multiple files per table, it’s enough to run avro-tools against any single file per table to extract that table’s schema.</p>
<p>I downloaded the latest version of avro-tools which is <code>avro-tools-1.8.2.jar</code>. I first copied all <code>.avro</code> files from s3 to local disk:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ aws s3 cp s3:<span class="hljs-comment">//my-bucket/bq_data/backend/ bq_data/backend/ --recursive</span>
</code></pre><pre><code>download: s3:<span class="hljs-comment">//my-bucket/bq_data/backend/sessions_detailed_phase2/sessions_detailed_phase2-000000000000.avro to bq_data/backend/sessions_detailed_phase2/sessions_detailed_phase2-000000000000.avro</span>
</code></pre><pre><code>download: s3:<span class="hljs-comment">//my-bucket/bq_data/backend/sessions_phase2/sessions_phase2-000000000000.avro to bq_data/backend/sessions_phase2/sessions_phase2-000000000000.avro</span>
</code></pre><pre><code>download: s3:<span class="hljs-comment">//my-bucket/bq_data/backend/sessions_daily_phase2/sessions_daily_phase2-000000000000.avro to bq_data/backend/sessions_daily_phase2/sessions_daily_phase2-000000000000.avro</span>
</code></pre><p>Avro-tools command should look like <code>java -jar avro-tools-1.8.2.jar getschema your_data.avro &gt; schema_file.a</code>vsc. This can become tedious if you have several AVRO files (in reality, I’ve done this for a project with many more tables). Again, I used a shell script to generate commands. I creat<code>ed extract_schema_avro</code>.sh with the following content:</p>
<pre><code>schema_avro=(bq_data/backend<span class="hljs-comment">/*)for i in ${!schema_avro[*]}; do  input_file=$(find ${schema_avro[$i]} -type f)  output_file=$(ls -l ${schema_avro[$i]} | tail -n+2 \    | awk -v srch="avro" -v repl="avsc" '{ sub(srch,repl,$9);    print $9 }')  commands=$(    echo "java -jar avro-tools-1.8.2.jar getschema " \      $input_file" &gt; bq_data/schemas/backend/avro/"$output_file  )  echo $commandsdone</span>
</code></pre><p>Running <code>extract_schema_avro.sh</code> provides the following:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ sh extract_schema_avro.sh
</code></pre><pre><code>java -jar avro-tools<span class="hljs-number">-1.8</span><span class="hljs-number">.2</span>.jar getschema bq_data/backend/sessions_daily_phase2/sessions_daily_phase2<span class="hljs-number">-000000000000.</span>avro &gt; bq_data/schemas/backend/avro/sessions_daily_phase2<span class="hljs-number">-000000000000.</span>avsc
</code></pre><pre><code>java -jar avro-tools<span class="hljs-number">-1.8</span><span class="hljs-number">.2</span>.jar getschema bq_data/backend/sessions_detailed_phase2/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avro &gt; bq_data/schemas/backend/avro/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avsc
</code></pre><pre><code>java -jar avro-tools<span class="hljs-number">-1.8</span><span class="hljs-number">.2</span>.jar getschema bq_data/backend/sessions_phase2/sessions_phase2<span class="hljs-number">-000000000000.</span>avro &gt; bq_data/schemas/backend/avro/sessions_phase2<span class="hljs-number">-000000000000.</span>avsc
</code></pre><p>Executing the above commands copies the extracted schema under <code>bq_data/schemas/backend/avro/</code> :</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ ls -l bq_data/schemas/backend/avro<span class="hljs-comment">/* | awk '{print $9}'</span>
</code></pre><pre><code>bq_data/schemas/backend/avro/sessions_daily_phase2<span class="hljs-number">-000000000000.</span>avscbq_data/schemas/backend/avro/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avscbq_data/schemas/backend/avro/sessions_phase2<span class="hljs-number">-000000000000.</span>avsc
</code></pre><p>Let’s also check what’s inside an <code>.avsc</code> file.</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ cat bq_data/schemas/backend/avro/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avsc
</code></pre><pre><code>{<span class="hljs-string">"type"</span> : <span class="hljs-string">"record"</span>,<span class="hljs-string">"name"</span> : <span class="hljs-string">"Root"</span>,<span class="hljs-string">"fields"</span> : [ {<span class="hljs-string">"name"</span> : <span class="hljs-string">"uid"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"string"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"platform"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"string"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"version"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"string"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"country"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"string"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"sessions"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"long"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"active_days"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"long"</span> ]}, {<span class="hljs-string">"name"</span> : <span class="hljs-string">"session_time_minutes"</span>,<span class="hljs-string">"type"</span> : [ <span class="hljs-string">"null"</span>, <span class="hljs-string">"double"</span> ]} ]}
</code></pre><p>As you can see, the schema is in the form that can be directly used in Athena <code>WITH SERDEPROPERTIES</code>. But before Athena, I used the AVRO schemas to create Hive tables. If you want to avoid Hive table creation, you can read the <code>.avsc</code> files to extract field names and data types, but then you have to map the data types yourself from AVRO format to Athena table creation DDL.</p>
<p>The complexity of the mapping task depends on how complex the data types are in your tables. For simplicity (and to cover most simple to complex data types), I let Hive do the mapping for me. So I created the tables first in Hive metastore. Then I used <code>SHOW CREATE TABLE</code> to get the field names and data types part of the DDL.</p>
<h3 id="heading-step-4-create-hive-tables-on-top-of-avro-data-use-schema-from-step-3">Step 4. Create Hive tables on top of AVRO data, use schema from Step 3</h3>
<p>As discussed earlier, Hive allows creating tables by using <code>avro.schema.url</code>. So once you have schema (<code>.avsc</code> file) extracted from AVRO data, you can create tables as follows:</p>
<pre><code>CREATE EXTERNAL TABLE table_nameSTORED AS AVROLOCATION <span class="hljs-string">'s3://your-aws-bucket/your-target-path/avro_data'</span>TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://your-aws-bucket/your-target-path/your-avro-schema'</span>);
</code></pre><p>First, upload the extracted schemas to S3 so that <code>avro.schema.url</code> can refer to their S3 locations:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ aws s3 cp bq_data/schemas s3:<span class="hljs-comment">//my-bucket/bq_data/schemas --recursive</span>
</code></pre><pre><code>upload: bq_data/schemas/backend/avro/sessions_daily_phase2<span class="hljs-number">-000000000000.</span>avsc to s3:<span class="hljs-comment">//my-bucket/bq_data/schemas/backend/avro/sessions_daily_phase2-000000000000.avsc</span>
</code></pre><pre><code>upload: bq_data/schemas/backend/avro/sessions_phase2<span class="hljs-number">-000000000000.</span>avsc to s3:<span class="hljs-comment">//my-bucket/bq_data/schemas/backend/avro/sessions_phase2-000000000000.avsc</span>
</code></pre><pre><code>upload: bq_data/schemas/backend/avro/sessions_detailed_phase2<span class="hljs-number">-000000000000.</span>avsc to s3:<span class="hljs-comment">//my-bucket/bq_data/schemas/backend/avro/sessions_detailed_phase2-000000000000.avsc</span>
</code></pre><p>After having both AVRO data and schema in S3, DDL for Hive table can be created using the template shown at the beginning of this section. I used another shell script <code>create_tables_hive.sh</code> (shown below) to cover any number of tables:</p>
<pre><code>schema_avro=$(ls -l bq_data/backend | tail -n+<span class="hljs-number">2</span> | awk <span class="hljs-string">'{print $9}'</span>)<span class="hljs-keyword">for</span> table_name <span class="hljs-keyword">in</span> $schema_avro; <span class="hljs-keyword">do</span>  file_name=$(ls -l bq_data/backend/$table_name | tail -n+<span class="hljs-number">2</span> | awk \    -v srch=<span class="hljs-string">"avro"</span> -v repl=<span class="hljs-string">"avsc"</span> <span class="hljs-string">'{ sub(srch,repl,$9); print $9 }'</span>)  table_definition=$(    echo <span class="hljs-string">"CREATE EXTERNAL TABLE IF NOT EXISTS backend."</span>$table_name<span class="hljs-string">"\\nSTORED AS AVRO"</span><span class="hljs-string">"\\nLOCATION 's3://my-bucket/bq_data/backend/"</span>$table_name<span class="hljs-string">"'"</span><span class="hljs-string">"\\nTBLPROPERTIES('avro.schema.url'='s3://my-bucket/bq_data/\schemas/backend/avro/"</span>$file_name<span class="hljs-string">"');"</span>  )  printf <span class="hljs-string">"\n$table_definition\n"</span>done
</code></pre><p>Running the script provides the following:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ sh create_tables_hive.sh
</code></pre><pre><code>CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_daily_phase2STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_daily_phase2'</span> TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_daily_phase2-000000000000.avsc'</span>);
</code></pre><pre><code>CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_detailed_phase2 STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_detailed_phase2'</span>TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_detailed_phase2-000000000000.avsc'</span>);
</code></pre><pre><code>CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_phase2STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_phase2'</span> TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_phase2-000000000000.avsc'</span>);
</code></pre><p>I ran the above on Hive console to actually create the Hive tables:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ hiveLogging initialized using configuration <span class="hljs-keyword">in</span> file:<span class="hljs-regexp">/etc/</span>hive/conf.dist/hive-log4j2.properties Async: <span class="hljs-literal">false</span>
</code></pre><pre><code>hive&gt; CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_daily_phase2&gt; STORED AS AVRO&gt; LOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_daily_phase2'</span> TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_daily_phase2-000000000000.avsc'</span>);OKTime taken: <span class="hljs-number">4.24</span> seconds
</code></pre><pre><code>hive&gt;&gt; CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_detailed_phase2 STORED AS AVRO&gt; LOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_detailed_phase2'</span>&gt; TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_detailed_phase2-000000000000.avsc'</span>);OKTime taken: <span class="hljs-number">0.563</span> seconds
</code></pre><pre><code>hive&gt;&gt; CREATE EXTERNAL TABLE IF NOT EXISTS backend.sessions_phase2&gt; STORED AS AVRO&gt; LOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_phase2'</span> TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_phase2-000000000000.avsc'</span>);OKTime taken: <span class="hljs-number">0.386</span> seconds
</code></pre><p>So I have created the Hive tables successfully. To verify that the tables work, I ran this simple query:</p>
<pre><code>hive&gt; select count(*) <span class="hljs-keyword">from</span> backend.sessions_detailed_phase2;Query ID = hadoop_20190214152548_2316cb5b<span class="hljs-number">-29</span>f1<span class="hljs-number">-4416</span><span class="hljs-number">-922</span>e-a6ff02ec1775Total jobs = <span class="hljs-number">1</span>Launching Job <span class="hljs-number">1</span> out <span class="hljs-keyword">of</span> <span class="hljs-number">1</span>Status: Running (Executing on YARN cluster <span class="hljs-keyword">with</span> App id application_1550010493995_0220)----------------------------------------------------------------------------------------------VERTICES      MODE        STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED----------------------------------------------------------------------------------------------<span class="hljs-built_in">Map</span> <span class="hljs-number">1</span> .......... container     SUCCEEDED      <span class="hljs-number">1</span>          <span class="hljs-number">1</span>        <span class="hljs-number">0</span>        <span class="hljs-number">0</span>       <span class="hljs-number">0</span>       <span class="hljs-number">0</span>Reducer <span class="hljs-number">2</span> ...... container     SUCCEEDED      <span class="hljs-number">1</span>          <span class="hljs-number">1</span>        <span class="hljs-number">0</span>        <span class="hljs-number">0</span>       <span class="hljs-number">0</span>       <span class="hljs-number">0</span>----------------------------------------------------------------------------------------------VERTICES: <span class="hljs-number">02</span>/<span class="hljs-number">02</span>  [==========================&gt;&gt;] <span class="hljs-number">100</span>%  ELAPSED TIME: <span class="hljs-number">8.17</span> s----------------------------------------------------------------------------------------------OK6130
</code></pre><p>So it works!</p>
<h3 id="heading-step-5-extract-hive-table-definition-from-hive-tables">Step 5. Extract Hive table definition from Hive tables</h3>
<p>As discussed earlier, Athena requires you to explicitly specify field names and their data types in <code>CREATE</code> statement. In Step 3, I extracted the AVRO schema, which can be used in <code>WITH SERDEPROPERTIES</code> of Athena table DDL, but I also have to specify all the fiend names and their (Hive) data types. Now that I have the tables in the Hive metastore, I can easily get those by running <code>SHOW CREATE TABLE</code>. First, prepare the Hive DDL queries for all tables:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ ls -l bq_data/backend | tail -n+<span class="hljs-number">2</span> | awk <span class="hljs-string">'{print "hive -e '</span>\<span class="hljs-string">''</span>SHOW CREATE TABLE backend.<span class="hljs-string">"$9"</span><span class="hljs-string">'\''</span> &gt; bq_data/schemas/backend/hql/backend.<span class="hljs-string">"$9"</span>.hql;<span class="hljs-string">" }'</span>
</code></pre><pre><code>hive -e <span class="hljs-string">'SHOW CREATE TABLE backend.sessions_daily_phase2'</span> &gt; bq_data/schemas/backend/hql/backend.sessions_daily_phase2.hql;
</code></pre><pre><code>hive -e <span class="hljs-string">'SHOW CREATE TABLE backend.sessions_detailed_phase2'</span> &gt; bq_data/schemas/backend/hql/backend.sessions_detailed_phase2.hql;
</code></pre><pre><code>hive -e <span class="hljs-string">'SHOW CREATE TABLE backend.sessions_phase2'</span> &gt; bq_data/schemas/backend/hql/backend.sessions_phase2.hql;
</code></pre><p>Executing the above commands copies Hive table definitions under <code>bq_data/schemas/backend/hql/</code>. Let’s see what’s inside:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ cat bq_data/schemas/backend/hql/backend.sessions_detailed_phase2.hql
</code></pre><pre><code>CREATE EXTERNAL TABLE <span class="hljs-string">`backend.sessions_detailed_phase2`</span>(<span class="hljs-string">`uid`</span> string COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`platform`</span> string COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`version`</span> string COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`country`</span> string COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`sessions`</span> bigint COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`active_days`</span> bigint COMMENT <span class="hljs-string">''</span>,<span class="hljs-string">`session_time_minutes`</span> double COMMENT <span class="hljs-string">''</span>)ROW FORMAT SERDE<span class="hljs-string">'org.apache.hadoop.hive.serde2.avro.AvroSerDe'</span>STORED AS INPUTFORMAT<span class="hljs-string">'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'</span>OUTPUTFORMAT<span class="hljs-string">'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'</span>LOCATION<span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_detailed_phase2'</span>TBLPROPERTIES (<span class="hljs-string">'avro.schema.url'</span>=<span class="hljs-string">'s3://my-bucket/bq_data/schemas/backend/avro/sessions_detailed_phase2-000000000000.avsc'</span>,<span class="hljs-string">'transient_lastDdlTime'</span>=<span class="hljs-string">'1550157659'</span>)
</code></pre><p>By now all the building blocks needed for creating AVRO tables in Athena are there:</p>
<ul>
<li>Field names and data types can be obtained from the Hive table DDL (to be used in columns section of <code>CREATE</code> statement)</li>
<li>AVRO schema (JSON) can be obtained from the extracted <code>.avsc</code> files (to be supplied in <code>WITH SERDEPROPERTIES</code>).</li>
</ul>
<h3 id="heading-step-6-use-the-output-of-steps-3-and-5-to-create-athena-tables">Step 6. Use the output of Steps 3 and 5 to Create Athena tables</h3>
<p>If you are still with me, you have done a great job coming this far. I am now going to perform the final step which is creating Athena tables. I used the following script to combine <code>.avsc</code> and <code>.hql</code> files to construct Athena table definitions:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> tmpAftab]$ cat create_tables_athena.sh
</code></pre><pre><code># directory where extracted avro schemas are storedschema_avro=(bq_data/schemas/backend/avro<span class="hljs-comment">/*)# directory where extracted HQL schemas are storedschema_hive=(bq_data/schemas/backend/hql/*)for i in ${!schema_avro[*]}; do  schema=$(awk -F '{print $0}' '/CREATE/{flag=1}/STORED/{flag=0}\   flag' ${schema_hive[$i]})  location=$(awk -F '{print $0}' '/LOCATION/{flag=1; next}\  /TBLPROPERTIES/{flag=0} flag' ${schema_hive[$i]})  properties=$(cat ${schema_avro[$i]})  table=$(echo $schema '\n' \    "WITH SERDEPROPERTIES ('avro.schema.literal'='\n"$properties \    "\n""')STORED AS AVRO \n" \    "LOCATION" $location";\n\n")  printf "\n$table\n"done \  &gt; bq_data/schemas/backend/all_athena_tables/all_athena_tables.hql</span>
</code></pre><p>Running the above script copies Athena table definitions to <code>bq_data/schemas/backend/all_athena_tables/all_athena_tables.hql</code>. In my case it contains:</p>
<pre><code>[hadoop@ip<span class="hljs-number">-10</span><span class="hljs-number">-0</span><span class="hljs-number">-10</span><span class="hljs-number">-205</span> all_athena_tables]$ cat all_athena_tables.hql
</code></pre><pre><code>CREATE EXTERNAL TABLE <span class="hljs-string">`backend.sessions_daily_phase2`</span>( <span class="hljs-string">`uid`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`activity_date`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`sessions`</span> bigint COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`session_time_minutes`</span> double COMMENT <span class="hljs-string">''</span>)ROW FORMAT SERDE <span class="hljs-string">'org.apache.hadoop.hive.serde2.avro.AvroSerDe'</span>WITH SERDEPROPERTIES (<span class="hljs-string">'avro.schema.literal'</span>=<span class="hljs-string">'{ "type" : "record", "name" : "Root", "fields" : [ { "name" : "uid", "type" : [ "null", "string" ] }, { "name" : "activity_date", "type" : [ "null", "string" ] }, { "name" : "sessions", "type" : [ "null", "long" ] }, { "name" : "session_time_minutes", "type" : [ "null", "double" ] } ] }'</span>)STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_daily_phase2'</span>;
</code></pre><pre><code>CREATE EXTERNAL TABLE <span class="hljs-string">`backend.sessions_detailed_phase2`</span>( <span class="hljs-string">`uid`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`platform`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`version`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`country`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`sessions`</span> bigint COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`active_days`</span> bigint COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`session_time_minutes`</span> double COMMENT <span class="hljs-string">''</span>)ROW FORMAT SERDE <span class="hljs-string">'org.apache.hadoop.hive.serde2.avro.AvroSerDe'</span>WITH SERDEPROPERTIES (<span class="hljs-string">'avro.schema.literal'</span>=<span class="hljs-string">'{ "type" : "record", "name" : "Root", "fields" : [ { "name" : "uid", "type" : [ "null", "string" ] }, { "name" : "platform", "type" : [ "null", "string" ] }, { "name" : "version", "type" : [ "null", "string" ] }, { "name" : "country", "type" : [ "null", "string" ] }, { "name" : "sessions", "type" : [ "null", "long" ] }, { "name" : "active_days", "type" : [ "null", "long" ] }, { "name" : "session_time_minutes", "type" : [ "null", "double" ] } ] } '</span>)STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_detailed_phase2'</span>;
</code></pre><pre><code>CREATE EXTERNAL TABLE <span class="hljs-string">`backend.sessions_phase2`</span>( <span class="hljs-string">`uid`</span> string COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`sessions`</span> bigint COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`active_days`</span> bigint COMMENT <span class="hljs-string">''</span>, <span class="hljs-string">`session_time_minutes`</span> double COMMENT <span class="hljs-string">''</span>)ROW FORMAT SERDE <span class="hljs-string">'org.apache.hadoop.hive.serde2.avro.AvroSerDe'</span>WITH SERDEPROPERTIES (<span class="hljs-string">'avro.schema.literal'</span>=<span class="hljs-string">'{ "type" : "record", "name" : "Root", "fields" : [ { "name" : "uid", "type" : [ "null", "string" ] }, { "name" : "sessions", "type" : [ "null", "long" ] }, { "name" : "active_days", "type" : [ "null", "long" ] }, { "name" : "session_time_minutes", "type" : [ "null", "double" ] } ] }'</span>)STORED AS AVROLOCATION <span class="hljs-string">'s3://my-bucket/bq_data/backend/sessions_phase2'</span>;
</code></pre><p>And finally, I ran the above scripts in Athena to create the tables:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/9TNErBinL98R9qH9pasv6a99jQWPNANLXPKP" alt="Image" width="800" height="528" loading="lazy"></p>
<p>There you have it.</p>
<p>I feel that the process is a bit lengthy. However, this has worked well for me. The other approach would be to use AWS Glue wizard to crawl the data and infer the schema. If you have used AWS Glue wizard, please share your experience in the comment section below.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ An in-depth introduction to SQOOP architecture ]]>
                </title>
                <description>
                    <![CDATA[ By Jayvardhan Reddy Apache Sqoop is a data ingestion tool designed for efficiently transferring bulk data between Apache Hadoop and structured data-stores such as relational databases, and vice-versa. _Image Credits: [hdfstutorial.com](https://www.h... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/an-in-depth-introduction-to-sqoop-architecture-ad4ae0532583/</link>
                <guid isPermaLink="false">66c343e4ccd54aa295e92c8a</guid>
                
                    <category>
                        <![CDATA[ architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ hadoop ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 26 Feb 2019 17:53:46 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*3aWPwVLlbZ8sq4aboE_CQw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Jayvardhan Reddy</p>
<p><strong>Apache Sqoop</strong> is a data ingestion tool designed for efficiently transferring bulk data between Apache Hadoop and structured data-stores such as relational databases, and vice-versa.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/yA5Wt8JEHKyIDA-bK2ehlgYGN03XXPgKFmdz" alt="Image" width="585" height="271" loading="lazy">
_Image Credits: [hdfstutorial.com](https://www.hdfstutorial.com/sqoop-architecture/" rel="noopener" target="<em>blank" title=")</em></p>
<p>As part of this blog, I will be explaining how the architecture works on executing a Sqoop command. I’ll cover details such as the jar generation via Codegen, execution of MapReduce job, and the various stages involved in running a Sqoop import/export command.</p>
<h3 id="heading-codegen"><strong>Codegen</strong></h3>
<p>Understanding Codegen is essential, as internally this converts our Sqoop job into a jar which consists of several Java classes such as POJO, ORM, and a class that implements DBWritable, extending SqoopRecord to read and write the data from relational databases to Hadoop &amp; vice-versa.</p>
<p>You can create a Codegen explicitly as shown below to check the classes present as part of the jar.</p>
<pre><code>sqoop codegen \   -- connect jdbc:mysql:<span class="hljs-comment">//ms.jayReddy.com:3306/retail_db \   -- username retail_user \   -- password ******* \   -- table products</span>
</code></pre><p>The output jar will be written in your local file system. You will get a Jar file, Java file and java files which are compiled into .class files:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/9584V87MKrbpriG-qjgfkRmU95O4DqMWBMpw" alt="Image" width="800" height="146" loading="lazy"></p>
<p>Let us see a snippet of the code that will be generated.</p>
<p>ORM class for table ‘products’ // Object-relational modal generated for mapping:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/R-YKp7vBHJyG0U9fkHmUrbDnie-O2-3G8PwV" alt="Image" width="800" height="229" loading="lazy"></p>
<p>Setter &amp; Getter methods to get values:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/do50-AIfmsBnWa0UmDElJu8lfJMl0lgATWtk" alt="Image" width="734" height="196" loading="lazy"></p>
<p>Internally it uses JDBC prepared statements to write to Hadoop and ResultSet to read data from Hadoop.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/dp1Oud1aHWZ6zPFRmDhTf5p4KUuPrYIUg4K6" alt="Image" width="800" height="251" loading="lazy"></p>
<h3 id="heading-sqoop-import"><strong>Sqoop Import</strong></h3>
<p>It is used to import data from traditional relational databases into Hadoop.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1fuDCRMH99ZB3HA496qQycCcGQFzs7c6kdNl" alt="Image" width="535" height="346" loading="lazy">
_Image Credits: [dummies.com](https://www.dummies.com/programming/big-data/hadoop/hadoop-for-dummies-cheat-sheet/" rel="noopener" target="<em>blank" title=")</em></p>
<p>Let’s see a sample snippet for the same.</p>
<pre><code>sqoop <span class="hljs-keyword">import</span> \   -- connect jdbc:mysql:<span class="hljs-comment">//ms.jayReddy.com:3306/retail_db \   -- username retail_user \   -- password ******* \   -- table products \   -- warehouse-dir /user/jvanchir/sqoop_prac/import_table_dir \   -- delete-target-dir</span>
</code></pre><p>The following steps take place internally during the execution of sqoop.</p>
<p><strong>Step 1</strong>: Read data from MySQL in streaming fashion. It does various operations before writing the data into HDFS.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/FSvnl854UDyo8C9QKIOO0aMLNBw5uWed-KEJ" alt="Image" width="687" height="24" loading="lazy"></p>
<p>As part of this process, it will first generate code (typical Map reduce code) which is nothing but Java code. Using this Java code it will try to import.</p>
<ul>
<li>Generate the code. (Hadoop MR)</li>
<li>Compile the code and generate the Jar file.</li>
<li>Submit the Jar file and perform the import operations</li>
</ul>
<p>During the import, it has to make certain decisions as to how to divide the data into multiple threads so that Sqoop import can be scaled.</p>
<p><strong>Step 2</strong>: Understand the structure of the data and perform CodeGen</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/iw8VSQhwmd4uvmqwN0MxCG15xrFBPGyRZdXy" alt="Image" width="800" height="45" loading="lazy"></p>
<p>Using the above SQL statement, it will fetch one record along with the column names. Using this information, it will extract the metadata information of the columns, datatype etc.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/rEfjXBnXyMjmyvtcIub-cxby3LS31vpFCFyt" alt="Image" width="476" height="418" loading="lazy">
_Image Credits: [cs.tut.fi](http://www.cs.tut.fi/~aaltone3/kurssit/hadoop/Sqoop_pdf.pdf" rel="noopener" target="<em>blank" title=")</em></p>
<p><strong>Step 3</strong>: Create the java file, compile it and generate a jar file</p>
<p>As part of code generation, it needs to understand the structure of the data and it has to apply that object on the incoming data internally to make sure the data is correctly copied onto the target database. Each unique table has one Java file talking about the structure of data.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/IVi4qXeQV0wHLso3jw-YSNt4Qdq1jz5WOSSQ" alt="Image" width="800" height="39" loading="lazy"></p>
<p>This jar file will be injected into Sqoop binaries to apply the structure to incoming data.</p>
<p><strong>Step 4</strong>: Delete the target directory if it already exists.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/PnNCCNdcFYG63ckjOdNQz9sLwHwp-xQhA6mh" alt="Image" width="800" height="22" loading="lazy"></p>
<p><strong>Step 5</strong>: Import the data</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/L0xKeU6eZzzFNXq9GTUizLA9daPHdicLyKcm" alt="Image" width="800" height="60" loading="lazy"></p>
<p>Here, it connects to a resource manager, gets the resource, and starts the application master.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/0k04I6Df7Ox1UGcxyOEqh-WENTYZtboAPfAH" alt="Image" width="719" height="22" loading="lazy"></p>
<p>To perform equal distribution of data among the map tasks, it internally executes a boundary query based on the primary key by default<br> to find the minimum and maximum count of records in the table.<br> Based on the max count, it will divide by the number of mappers and split it amongst each mapper.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ixpOtqkpYybBmnTLp1o9vsvkG5Z22ybCYWMB" alt="Image" width="800" height="92" loading="lazy"></p>
<p>It uses 4 mappers by default:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/SvulfY8XlKP3-Th9pY7nLI0RBaWZs4spjFWv" alt="Image" width="800" height="284" loading="lazy"></p>
<p>It executes these jobs on different executors as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/4doX1MPcDsGOirBF0qyTlaEZCUEvZfiCqg1w" alt="Image" width="800" height="140" loading="lazy"></p>
<p>The default number of mappers can be changed by setting the following parameter:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/J4gGRZO4nsjSvBqfH8yopHaCgYyodWutLGLl" alt="Image" width="739" height="26" loading="lazy"></p>
<p>So in our case, it uses 4 threads. Each thread processes mutually exclusive subsets, that is each thread processes different data from the others.</p>
<p>To see the different values, check out the below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/bRNZNgynB99qUWQVotlG0PCM7UYUYMzatqE1" alt="Image" width="800" height="338" loading="lazy"></p>
<p>Operations that are being performed under each executor nodes:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/Q6V3RYKFJ56mlEPTX5VTPGQqBYWpdlSGBoXW" alt="Image" width="800" height="153" loading="lazy"></p>
<p>In case you perform a Sqooop hive import, one extra step as part of the execution takes place.</p>
<p><strong>Step 6</strong>: Copy data to hive table</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/TRcmgwhHAQy2SutU-R13R53ejFPJ2j2JsB7R" alt="Image" width="800" height="126" loading="lazy"></p>
<h3 id="heading-sqoop-export"><strong>Sqoop Export</strong></h3>
<p>This is used to export data from Hadoop into traditional relational databases.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/s1lKtokuWsuEqmHsb92--czqDaFuQKd8Dvtm" alt="Image" width="800" height="337" loading="lazy">
_Image Credits: [slideshare.net](https://www.slideshare.net/gharriso/from-oracle-to-hadoop-with-sqoop-and-other-tools" rel="noopener" target="<em>blank" title=")</em></p>
<p>Let’s see a sample snippet for the same:</p>
<pre><code>sqoop <span class="hljs-keyword">export</span> \  -- connect jdbc:mysql:<span class="hljs-comment">//ms.jayReddy.com:3306/retail_export \  -- username retail_user \  -- password ******* \  -- table product_sqoop_exp \  -- export-dir /user/jvanchir/sqoop_prac/import_table_dir/products</span>
</code></pre><p>On executing the above command, the execution steps (1–4) similar to Sqoop import take place, but the source data is read from the file system (which is nothing but HDFS). Here it will use boundaries upon block size to divide the data and it is internally taken care by Sqoop.</p>
<p>The processing splits are done as shown below:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/pFCifYgZx8KRMRCVxfJdk7HOigxDTZOX5UQz" alt="Image" width="800" height="67" loading="lazy"></p>
<p>After connecting to the respective database to which the records are to be exported, it will issue a JDBC insert command to read data from HDFS and store it into the database as shown below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/dWB1TZmEH07zlJ3TOKnVZm1dvzVvbEKOIa5c" alt="Image" width="737" height="26" loading="lazy"></p>
<p>Now that we have seen how Sqoop works internally, you can determine the flow of execution from jar generation to execution of a MapReduce task on the submission of a Sqoop job.</p>
<p><strong>Note<em>:</em></strong> The commands that were executed related to this post are added as part of my <a target="_blank" href="https://github.com/Jayvardhan-Reddy/BigData-Ecosystem-Architecture">GIT</a> account.</p>
<p>Similarly, you can also read more here:</p>
<ul>
<li><a target="_blank" href="https://medium.com/plumbersofdatascience/hive-architecture-in-depth-ba44e8946cbc">Hive Architecture in Depth</a> with <strong>code</strong>.</li>
<li><a target="_blank" href="https://medium.com/plumbersofdatascience/hdfs-architecture-in-depth-1edb822b95fa">HDFS Architecture in Depth</a> with <strong>code</strong>.</li>
</ul>
<p>If you would like too, you can connect with me on LinkedIn - <a target="_blank" href="https://www.linkedin.com/in/jayvardhan-reddy-vanchireddy">Jayvardhan Reddy</a>.</p>
<p>If you enjoyed reading this article, you can click the clap and let others know about it. If you would like me to add anything else, please feel free to leave a response ?</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to work in Data Science, AI, or Big Data based on my experience ]]>
                </title>
                <description>
                    <![CDATA[ By Richard Freeman, PhD In summer 2013, I interviewed for a lead role in the data science and analytics team at tech-for-good company JustGiving. During the interview, I said I planned to deliver batch machine learning, graph analytics and streaming ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/recommendations-for-working-in-data-science-ai-and-big-data-based-on-my-personal-experience-8dbc24be368c/</link>
                <guid isPermaLink="false">66c35daa98047dbdb4839f16</guid>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ technology ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 30 Jan 2019 22:19:43 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*Pl3yIm_lLoIvMcosHAE-pw.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Richard Freeman, PhD</p>
<p>In summer 2013, I interviewed for a lead role in the data science and analytics team at tech-for-good company <a target="_blank" href="https://www.justgiving.com/">JustGiving</a>. During the interview, I said I planned to deliver batch machine learning, graph analytics and streaming analytics systems, both in-house and in the cloud.</p>
<p>A few years later, my former boss <a target="_blank" href="https://www.forbes.com/sites/tommywilliams1/2019/02/28/meet-mike-bugembe-the-data-scientist-who-helped-people-give-more-to-charity">Mike Bugembe</a> and I were both presenting at international conferences, winning awards and becoming authors!</p>
<p>Here is my story, and what I learnt on the journey — plus my recommendations for you.</p>
<h4 id="heading-why-big-data-engineering-and-data-science">Why Big Data Engineering and Data Science?</h4>
<p>I’ve always been interested in artificial intelligence (AI), machine learning (ML) and natural language processing (NLP). In particular, I’ve been interested in scalable systems, and making robots more intelligent and responsive.</p>
<p>My interest in data engineering comes from my background as a solutions architect. In that role, I enjoyed building cloud-based systems to store and process data to derive new insight and knowledge.</p>
<p>I also develop big data and ML pipelines to automate the whole ML process. This helps data scientists and analysts save time preparing data for training and testing their algorithms, running metrics and deriving key performance indicators at scale.</p>
<p>Data preparation is particularly important. Data scientists typically spend about 80% of their time on it. Having access to data shaped in the right way makes them more productive and happier.</p>
<h4 id="heading-my-previous-background">My previous background</h4>
<p>I previously earned a Masters degree in computer systems engineering, and a PhD in ML and NLP. I completed both at the <a target="_blank" href="https://www.manchester.ac.uk/">University of Manchester</a>.</p>
<p>Rather than join a specialised vendor in my Ph.D. area of expertise, I decided to broaden my skills and gain more client exposure by joining <a target="_blank" href="https://www.capgemini.com/">Capgemini</a>. Capgemini are a large global consulting, technology and outsourcing services company.</p>
<p>I worked my way from being a developer to a solution architect. There, I helped deliver large scale projects for Fortune Global 500 companies in sectors including insurance, retail banking, financial services, and central government.</p>
<p>I then joined PageGroup. There, I worked as an lead developer and architect on a global transformation programme across 34 countries. I led the technical delivery of search, multi-channel communication, business intelligence, text analytics, job board integration, and advertising solutions.</p>
<h4 id="heading-current-roles">Current roles</h4>
<p>Now I am a lead big data and machine learning engineer at JustGiving. JustGiving is a tech-for-good company that’s helped 26 million users in 164 countries raise $5 billion for good causes. It was acquired in 2017 by <a target="_blank" href="https://www.blackbaud.com/">Blackbaud</a> — the world’s leading software company powering social good.</p>
<p>I currently lead the delivery and architecture of our <a target="_blank" href="https://aws.amazon.com/solutions/case-studies/justgiving/">in-house data science platform RAVEN</a> and production ML systems. These were initially deployed with Azure, but later hosted in AWS. I also dive in as a data scientist specialising in scalable streaming analytics, ML and NLP algorithms.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/QESY3vZCMskw2pow6E8Al6qyPF6AHWsTCZgL" alt="Image" width="770" height="861" loading="lazy"></p>
<p>I share my technical experience and knowledge internally and externally relating to AWS, stream processing, serverless stacks, ML and NLP. I also present regularly at industry conferences, <a target="_blank" href="https://github.com/astarwolf">open source my code</a> and write technical blog posts on <a target="_blank" href="https://medium.com/@rfreeman">Medium</a> and for AWS such as <a target="_blank" href="https://aws.amazon.com/blogs/big-data/analyze-a-time-series-in-real-time-with-aws-lambda-amazon-kinesis-and-amazon-dynamodb-streams/">Analyze a Time Series in Real Time</a>.</p>
<p>I’m also an <a target="_blank" href="https://www.linkedin.com/in/drfreeman/">independent freelance advisor and consultant</a> helping organisations with cloud architecture, serverless computing and ML at Starwolf.</p>
<h3 id="heading-a-typical-day-in-the-office">A typical day in the office</h3>
<p>JustGiving is still a start-up at heart, so there is no typical day. I get involved in various tasks, such as data and report requirements capture, engineering new data pipeline, investigating operational issues, running data experiments, analysing unstructured data looking for useful patterns, exploring new ways to use the data to answer questions, presenting a data story, and sharing my knowledge and experience. This means that I work closely with marketing, product managers and product analysts to understand their data needs and what metrics and predictions are important for them.</p>
<p><strong>Speaking to others outside your specialist area helps to broaden your views, gives you a new perspective, and new areas you can apply your skills.</strong></p>
<p>On the technical side, I work with engineers, data analysts, developers, business intelligence analysts, operations, and data scientists to support their data and platform requirements.</p>
<h3 id="heading-things-i-enjoy-about-work">Things I enjoy about work</h3>
<p>I am passionate about working with huge data sets, as you face different kinds of performance, costs and operational issues that require you to think differently in order to scale your data warehouse, ETL processes, and algorithms and how you present your results. A lot of what you know about data warehousing with their millions of records goes out the roof when you hit hundreds of billions rows and need to iterate or do complex joins to run ML data preparation queries.</p>
<p>Building and running large-scale data infrastructure and distributed model training are active areas in academia and industry. They are evolving at a fast pace, with new tooling being introduced every few months. I like to use cloud solutions in an innovative way to improve our in-house data science platform, enhance our business processes, and make data insights available to internal and external users.</p>
<p>I’ve found that <strong>a lot of companies give their power away by using 3rd parties for their web analytics solutions, rather than building their own</strong>. That data is then siloed in marketing or sales departments, is difficult if not possible to get back in its raw form, and cannot be streamed back for example preventing you from making real-time ML recommendation or predictions directly in your product.</p>
<p>At JustGiving we built an in-house web analytics product called KOALA and have this data available in real-time as an AWS Serverless stack. This allowed us to have a full suite of data pipelines for ML training and analytics in-house, and the likes of MAGPIE that allows us to create real-time metrics and insighs that we can serve back to the users.</p>
<p>For example here is early version shown in this Tweet during a crowdfunding campaign for the <a target="_blank" href="https://twitter.com/MENnewsdesk/status/867330719420428291">Manchester attacks victims families’ in May 2017</a>.</p>
<p>In addition KOALA allows us to make predictions from streaming data. It is extremely costs effective solution compared to paying for a vendor product. If you compare it to a vendor solution based on the same web traffic, KOALA is 10x cheaper, more developer friendly, and we get the raw streamed data back in real-time, rather than in batches or having to use a propitiatory locked down querying or reporting system.</p>
<p>I am also a big fan of Python and have successfully encouraged its uptake in the company and wider community for the data pipelines, ML and serverless computing. Why Python? It has extensive ML Libraries, scales with the likes of pySpark, and easy to read / write.</p>
<p>I also enjoy working with different organisations, charities, universities and giving back to the wider technical community with my experience and time such as at the <a target="_blank" href="https://twitter.com/richardtfreeman/status/1092832770294984704">AWS and British Heart Foundation Hackathon recently</a>.</p>
<h3 id="heading-the-future-of-big-data-data-science-and-ai">The Future of Big Data, Data Science and AI</h3>
<p>I see more people using ML, real-time analytics, graph analytics and NLP in their products and applications, not just offline on their laptops. This is accelerating as the cloud providers offer ML and NLP application program interfaces (APIs).</p>
<p>For real-time analytics, there is a growing demand from consumers that are much more data aware and impatient. For example they want to know what is happening right now, see the results of their action, and use more intelligent applications and websites that adapt as they are interacting with them.</p>
<p>On the infrastructure side, I see serverless computing and Platform as a Service (PaaS) infrastructure in the public cloud such as AWS and Azure becoming more prominent. Functions in serverless computing are particularly interesting for me, as they can auto-scale in less than a 100 milliseconds, are highly available and are low cost. They are low cost as you only pay for the time your code is executed, rather than for an always-on machine or container like in more traditional cloud infrastructure. I’ve even shown that you can implement most of the existing container-based <a target="_blank" href="https://www.packtpub.com/application-development/implementing-serverless-microservices-architecture-patterns-video">microservices patterns using a serverless stack</a>.</p>
<p>The open source frameworks and programming languages will also continue to grow compared to closed vendor specific products and languages, e.g. Apache Spark framework, Python, R, SQL. The same goes for data storage and access: cloud storage, data warehouses and data lakes will store data in more open rather than proprietary formats, and this will be more accessible over standard APIs or open protocols.</p>
<p>There will also be growing requirements to analyse unstructured and multimedia data sources, and again the cloud providers will have a growing role to play.</p>
<p>We will also see more companies making the transition from using strategies decided by a few on gut instinct at the top, to becoming more experiment-based, evidence-based, and data-driven as described by my former CAO <a target="_blank" href="https://www.amazon.co.uk/Cracking-Data-Code-Unlock-organisation/dp/1781333335/ref=sr_1_1">Mike Bugembe in his book</a>. For example the testing of new products or features, identifying new opportunities and strategic decisions will come more and more from the data analysis, insight and predictions.</p>
<p><strong>This will require more staff to get involved in data capture, data preparation, running experiments using algorithms, data visualisation and presenting results.</strong></p>
<p>As such, new data orientated jobs based on creating and training data models will emerge, disrupting some of the existing specialist fields such as health care, accountancy and law. AI, Internet of things (IoT) and robotics will also replace some existing blue and white collar jobs so we will need to think about training and upskilling people to the changing landscape, and possibly introduce some kind of universal basic income.</p>
<p>You can draw parallels with the shift seen during the industrial revolution from the agrarian or pre-industrial times. For AI to take off, we need two things to happen: the cost of human workers becomes higher than the AI alternative, and for AI to be deployed in a scalable way.</p>
<p>In the much the longer term, quantum computing will also disrupt the field again in terms of how we process, analyse and store data, and will transform areas like cyber security, banking and existing AI.</p>
<h3 id="heading-how-to-inspire-people-to-pursue-careers-in-data-science">How to inspire people to pursue careers in data science</h3>
<p>I think it’s a lot easier to get people interested in big data and data science than it used to be, thanks to the likes of Google and Facebook that make it fashionable to be smart and work within technology.</p>
<p>In addition, the growing number of young and flexible startup companies with infrastructures in the public cloud are successfully competing and winning market shares from large established companies. Employers need to be willing to educate and upskill existing staff or graduates rather than solely recruit people with existing data engineering or data science skills.</p>
<p>For inspiring existing staff, we need to show the benefits, use cases and data sources most relevant to them, which makes them more productive and their jobs easier. With more data exploration tools available, staff in other departments outside IT or finance, such as customer support, marketing and product managers will be self-serving on the data and insights.</p>
<p>For people who have not worked in industry, I think we need to start early in schools and then universities. Teachers and lecturers in non-computer science subjects could make data more visual and interactive in their respective fields.</p>
<p>I think that almost any subject can benefit — for example even in English literature you can draw a relationship graph of the characters and their connections linked to main themes, events and locations. In history classes, you could have and interactive visual maps and time evolving graph representations of key events their dependencies.</p>
<h3 id="heading-advice-i-would-you-give-to-someone-considering-a-career-in-big-data-and-data-science">Advice I would you give to someone considering a career in Big Data and Data Science</h3>
<p>Whether you are a graduate, already working in an organisation or not from a technical background, you can benefit from analysing and understanding data. For example, data journalists are typically not from a technical or scientific background, yet are able to do simple analysis and create an interesting data story for the general public.</p>
<p>It’s about self-motivation: when things move at such a fast pace, you can look broadly across the sector to gain a general understanding. But you also need to focus your energy on one specific course or project and complete it. The industry also tends to repackage old technologies with some improvements as new trending ones, like cyber security, cognitive computing, chatbots, virtual reality and deep learning at the moment. So I would follow your heart for the areas you are truly interested in and want to focus on rather than the latest trend.</p>
<p><strong>Behind each viral trend there have usually been early explorers that have worked and struggled on that area for years!</strong></p>
<p>In terms of gaining the knowledge, it is a lot easier than it used to be. For example in the past you had to pay for specific vendor training and there was the cost of the product itself. You can now access the <strong>learning materials</strong>, <strong>data sources</strong>, and <strong>tools</strong> all for free, so there is no excuse not to get started today!</p>
<p>For the <strong>learning materials</strong>, a lot of the content is available for free in massive open online courses, forms, blogs, and source code repositories. Equally there are numerous free <strong>data sources</strong> like ML datasets, open data, news feeds and social media you can use.</p>
<p>There are many <strong>tools</strong> out there. Some are graphical, but in my view you should learn to program in SQL, Python, or R. All three have the ability to do data science at scale thanks to frameworks like Apache Spark. I particularly like Python as it benefits from being an efficient development language with a solid test framework and numerous data science packages.</p>
<p>As an ML engineer or data scientist, expect to spend a lot of time on data preparation. This is an important process to master, which involves the cleaning, parsing, enriching and shaping the data so that it can be used in the ML algorithms and experiments. Overall, remember that the processes, tools and data sources are always evolving, so there is no one-off unicorn training course you can do. You will need be self-motivated and open to constantly learn and adapt to the data ecosystem.</p>
<p>I would recommend that you learn another language such as Mandarin (1.1 billion speakers) or Spanish (0.5 billion speakers), to remain mobile, get more career opportunities, and be competitive within this interconnected world. This will also open your mind and give you an insight into other cultures and values, and how they use their data.</p>
<p>Cloud computing also means that you no longer need a physical presence in a country to operate in it, so you need to be open to building systems across regions and analysing data from many countries. Start using collaborative tools and participate in <a target="_blank" href="https://medium.com/@rfreeman/using-your-skills-to-get-involved-in-tech-for-good-c43f4e18a947">tech for good communities</a>.</p>
<p>Some jobs and professions will be replaced, and some human expertise will be lost, but we will still rely on the data and algorithms. For example, once driverless transportation is widely adopted and considered safer, cheaper and more convenient than human drivers, future generations may not wish to drive a car or even have a driving license. However humans will still be involved in the systems that automate the driving, the creative analysis of the telemetry and IoT data, the supervision and monitoring of the ecosystem, and the wider participation in the transport industry and sharing economy.</p>
<h3 id="heading-summary">Summary</h3>
<p>If you want to have a career in data science, ML, or data engineering, the business needs still drive the software development and analysis. Think about the metrics you want to calculate that will benefit your business decisions, or the hypothesis you want to validate with an experiment.</p>
<p>What actions will your audience take with your results? What growth or cost savings opportunities for a business are out there? Then work back to see what data, models and infrastructure you need for the task. I think that being curious, inquisitive, and having an experimental mind are important qualities.</p>
<p>Feel free to connect with me on <a target="_blank" href="https://www.linkedin.com/in/drfreeman/">LinkedIn</a>, follow me on <a target="_blank" href="https://twitter.com/@richardtfreeman">Twitter</a>, or message me for comments and questions. If you want to have a more personalised chat with me, based on your requests, I’m offering short 30min Skype calls on career advice or mentoring for a small fee. I also do short term consultancy, and provide expert advice and audit services to organisations building and running big data and data science platforms in the cloud.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What to consider for painless Apache Kafka integration ]]>
                </title>
                <description>
                    <![CDATA[ By Adi Polak Apache Kafka’s real-world adoption is exploding, and it claims to dominate the world of stream data. It has a huge developer community all over the world that keeps on growing. But, it can be painful too. So, just before jumping head fir... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-to-consider-for-painless-apache-kafka-integration-df559e828876/</link>
                <guid isPermaLink="false">66d45d5923b027d0ff16f2c2</guid>
                
                    <category>
                        <![CDATA[ Apache Kafka ]]>
                    </category>
                
                    <category>
                        <![CDATA[ architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 22 Jan 2019 18:04:27 +0000</pubDate>
                <media:content url="https://cdn-media-2.freecodecamp.org/w1280/5f9ca635740569d1a4ca6eb0.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Adi Polak</p>
<p>Apache Kafka’s real-world adoption is exploding, and it claims to dominate the world of stream data. It has a huge developer community all over the world that keeps on growing. But, it can be painful too. So, just before jumping head first and fully integrating with Apache Kafka, let’s check the water and plan ahead for painless integration.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/DdJhig6V7tsyyPxWQThFzKGd6R-8dbmw3-nw" alt="Image" width="800" height="533" loading="lazy">
_nPhoto by [Unsplash](https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="_blank" title=""&gt;Helloquence on &lt;a href="https://unsplash.com/search/photos/computer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText" rel="noopener" target="<em>blank" title=")</em></p>
<h4 id="heading-what-is-it">What is it?</h4>
<p>Apache Kafka is an open source framework for asynchronous messaging and it’s a distributed streaming platform. It is TCP based. The messages are persisted in topics. Message producers are called <em>publishers</em> and message consumers are called <em>subscribers</em>.</p>
<p>Consumers can subscribe to <strong>one or more topics</strong> and consume all the messages in that topic. Messages are written into the topic partitions.</p>
<p><em>Topics</em> are always multilayer subscriber, they can have zero, one, or many consumers that subscribe to the data written to it. For each topic Kafka maintains a partition log. Metadata for the partition’s logs and topics are usually managed by Zookeeper.</p>
<p>If you would like to learn more about Kafka message delivery semantics — like, <em>at most once</em>, <em>at least once</em> and <em>exactly once —</em> read <a target="_blank" href="http://bit.ly/2Shu9L5">here</a>.</p>
<p>Many tech companies have already integrated Apache Kafka into their production as a <strong>message broker, user activities tracking pipeline, metrics gatherer, log aggregation mechanism, stream processing device</strong> and much more. Apache Kafka is written in Scala and Java.</p>
<h4 id="heading-why-kafka">Why Kafka?</h4>
<ul>
<li><em>Kafka provides <strong>High Availability</strong> and <strong>Fault Tolerance</strong> message logs.</em> Kafka clusters retain all published records. It is by default <strong>persistent —</strong> If you don’t set a limit for Kafka, it will keep records until it runs out of disk space. When <strong>data loss</strong> means awful failure for the product, this is essential for recovery.</li>
<li><strong>Multiple Topic Consumers</strong> — when configuring the consumers under multiple consumers groups, it helps to reduce the old bottleneck of sending the data to multiple applications for processing. Kafka is distributed, hence, it can send information to consumers from various physical machines/services instances. Replicating topics to a secondary cluster is also relatively easy using Apache Kafka’s mirroring feature, MirrorMaker — see an <a target="_blank" href="http://bit.ly/2CsENsU">example</a> of mirroring data between two HDInsight clusters. <strong>Just remember</strong>, if multiple consumers are defined as part of the same group (defined by the group.id) the data will be balanced over all the consumers within the group.</li>
<li>Kafka is <strong>polyglot</strong> — there are many clients in C#, Java, C, python and more. The ecosystem also provides a REST proxy which allows easy integration via HTTP and JSON.</li>
<li><strong>Real-Time Handling</strong> — Kafka can handle real-time data pipelines for real time messaging for applications.</li>
<li><strong>Scalable</strong> — due to distributed architecture, Kafka can scale out without incurring any downtime.</li>
<li>and more…</li>
</ul>
<h3 id="heading-lets-make-integration-with-kafka-painless">Let’s make integration with Kafka painless</h3>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ltseK3C8ZbvxjNtH95aPcVfZhWGx1wCqoapf" alt="Image" width="800" height="533" loading="lazy"></p>
<h4 id="heading-here-are-6-things-to-know-before-integrating">Here are 6 things to know before integrating:</h4>
<p><strong>1 — Apache Zookeeper can become a pain point with a Kafka cluster</strong></p>
<p>In the past ( versions &lt; 0.81) Kafka used Zookeeper to maintain offsets of each topic and partition. Zookeeper used to take part in the read path, where too frequent commits and too many consumers led to sever performance and stability issues.</p>
<p>On top of that, it is better to use commits manually with old Zookeeper-based consumers, since careless auto-commits could lead to data loss.</p>
<p>The newer versions of Kafka offer their own management, where the consumer can use Kafka itself to manage offsets. This means that there is a specific topic that manages the read offsets instead of Zookeeper.</p>
<p>Yet, Kafka still needs a cluster with Zookeeper, even in the later versions 2.+. Zookeeper is used to store Kafka configs (reassigning partitions when needed) and the Kafka topics API, like create topic, add partition, etc.</p>
<p>The load on Kafka is strictly related to the number of consumers, brokers, partitions and frequency of commits from the consumer.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/YHjRwjTTwgWD4nilJIADm7GF9KkNyZPWG4NG" alt="Image" width="800" height="603" loading="lazy"></p>
<p><strong>2 — You shouldn’t send large messages or payloads through Kafka</strong></p>
<p>According to Apache Kafka, for better throughput, the max message size should be <strong>10KB<em>.</em></strong> If the messages are larger than this, it is better to check the alternatives or find a way to chop the message into smaller parts before writing to Kafka. Best practice to do so is using a message key to make sure all chopped messages will be written to the same partition.</p>
<p><strong>3 — Apache Kafka can’t transform data</strong></p>
<p>Many developers are mistaken and think that they can create Kafka parsers or do a data transformation over Kafka. However, Kafka does not enable transformation of data. If you are using Azure services, there is a great list of <a target="_blank" href="http://bit.ly/2Sk8rpS">data factories services</a> that you can use to transform the data like <a target="_blank" href="http://bit.ly/2Lv6uEm">Azure Databricks</a>, <a target="_blank" href="http://bit.ly/2EK5EDp">HDInsights Spark</a> and others that connects to Kafka.</p>
<p>Another solution is using <a target="_blank" href="https://kafka.apache.org/documentation/streams/">Apache Kafka stream</a>. This is actually a new API that is build on top of Kafka’s producer and consumer clients. It’s significantly more powerful and also more expressive than the Kafka consumer client.</p>
<p>The <code>[KafkaStreams](https://kafka.apache.org/10/javadoc/org/apache/kafka/streams/KafkaStreams.html)</code> client allows us to perform continuous computation on input coming from one or more input topics and sends output to zero, one, or more output topics. Internally a <code>KafkaStreams</code> instance contains a normal <code>[KafkaProducer](https://kafka.apache.org/10/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html)</code> and <code>[KafkaConsumer](https://kafka.apache.org/10/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html)</code> instance that is used for reading input and writing output.</p>
<p>Another option is using Flink, check it out <a target="_blank" href="https://www.baeldung.com/kafka-flink-data-pipeline">here</a>.</p>
<p><strong>4 — Apache Kafka supports a binary protocol over TCP</strong></p>
<p>Apache Kafka communication protocol is TCP based. It doesn’t support MQTT or JMS or other non-based TCP protocols out of the box. However, many users have written adaptors to read data from those protocols and write to Apache Kafka. For example <a target="_blank" href="https://github.com/adispennette/apache-kafka-jms">kafka-jms-client</a>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/ScLTW1xegqrB9bKdZwmPrT0WUgzsmRzycyFV" alt="Image" width="800" height="591" loading="lazy">
<em>Simple TCP handshake</em></p>
<p><strong>5 — Apache Kafka management / support and the steep learning curve</strong></p>
<p>As of today, there are limited <em>free</em> UI based management system for Apache Kafka, and most the the DevOps I worked with are using scripting tools. However, it can be tedious for beginner to jump into Apache Kafka scripting tools without taking the time for training. The Learning curve is steep and takes some time to get moving and integrate into big running systems.</p>
<p>For experienced DevOps/ developers it might take a few months (2+) to fully understand how to integrate, support and work with Apache Kafka. It is important to learn how Kafka works in order to use the configuration in the way that will best suit the system’s needs.</p>
<p>Here’s a list of management tools that you can use for <strong>almost free (</strong>some are restricted to personal/community use):</p>
<ul>
<li><a target="_blank" href="http://www.kafkatool.com/">KafkaTool</a> — GUI application for managing and using <strong>Apache Kafka</strong> clusters.</li>
<li><a target="_blank" href="https://www.confluent.io/product/confluent-platform/">Confluent platform</a> — full enterprise streaming platform solution.</li>
<li><a target="_blank" href="https://github.com/HomeAdvisor/Kafdrop">KafDrop</a> — tool for displaying information such as brokers, topics, partitions, and even lets you view messages. It is a lightweight application that runs on Spring Boot and requires very little configuration.</li>
<li><a target="_blank" href="https://github.com/yahoo/kafka-manager">Yahoo Kafka Manager</a> —another tool for monitoring Kafka, yet it offers much less than the rest.</li>
</ul>
<p><strong>Supporting Managed Kafka on the cloud</strong></p>
<p>Today almost all clouds support Kafka, if it is fully managed or using integration with Confluent from the cloud store up to just purchasing Kafka machines:</p>
<ul>
<li><a target="_blank" href="https://www.confluent.io/confluent-cloud/">Confluent Cloud- Kafka as a Service</a></li>
<li><a target="_blank" href="http://bit.ly/2Ah5MGo">Azure Event Hub</a>- fully managed Kafka</li>
<li><a target="_blank" href="http://bit.ly/2BEpPyp">Managed Kafka on HDInsight — Azure</a></li>
<li><a target="_blank" href="https://console.cloud.google.com/marketplace/details/click-to-deploy-images/kafka?pli=1">Kafka Machine on Google cloud</a></li>
<li><a target="_blank" href="https://aws.amazon.com/quickstart/architecture/confluent-platform/">Kafka on AWS using Confluent solution</a></li>
<li>... many more</li>
</ul>
<p><strong>6 — Kafka is no magic — There is still a possibility of data loss</strong></p>
<p>Apache Kafka is probably the most popular tool for distributed asynchronous messaging. This is mainly due to his <strong>high throughput, low latency, scalability, centralised and real time</strong> abilities. Most of this is due to using data replicas which in Kafka are called partitions.</p>
<p>However, with misconfiguration there is a high chance of <em>data loss</em> when machines/processes are failing, and they will fail. Therefore, it’s important to understand how Kafka works and what the product/system requirements are.</p>
<p><strong>7 — Kafka built-in failure testing framework Trogdor</strong></p>
<p>To assist you in finding the right configuration, the Kafka team created <a target="_blank" href="https://cwiki.apache.org/confluence/display/KAFKA/Fault+Injection">Trogdor</a>. Trogdor is a failure testing framework.</p>
<p><strong>How it works</strong></p>
<ul>
<li>Configure Kafka the way you would in production</li>
<li>Create a producer that generates messages with sequence 1…X million.</li>
<li>Run the producer</li>
<li>Run the consumer</li>
<li>Create failure by crashing and/or hanging broker.</li>
<li>Test and check that every event produced was consumed.</li>
<li>… if that’s not the case, it is better to go back and update the configuration accordingly!</li>
</ul>
<h4 id="heading-on-top-of-that-it-is-important-to-remember-that-apache-kafka">On top of that, it is important to remember that Apache Kafka …</h4>
<ul>
<li>Is <strong><em>not a RPC</em></strong> —Apache Kafka is a messaging system. For RPC, service X needs to be aware of Service Y and the call signature. For example, in Kafka, if you send a message it doesn't mean that someone will consume it, ever. In RPC, there is always a consumer since the service itself is aware of the consumer Y and creates a call to its signature/function.</li>
<li>It is <strong><em>not a Database</em></strong> — it’s not a good place to save messages since you can’t jump between them or create a search without an expensive full scan.</li>
</ul>
<h4 id="heading-just-a-word-about-ksql">Just a word about KSQL</h4>
<p>An interesting library brought to us by the Confluent Community is <a target="_blank" href="https://github.com/confluentinc/ksql">KSQL</a>. It is build on top of Kafka stream. KSQL is a completely interactive SQL interface. You can use it without writing any code. KSQL is under the Confluent Community licensing.</p>
<h3 id="heading-tldr">TL;DR</h3>
<p>Apache Kafka has many benefits, yet before adding it in production, one should be aware that:</p>
<ul>
<li>It has a steep learning curve — make time to learn the bits and bits of Kafka</li>
<li>You must manage cluster resources — be aware of the requirements like Zookeeper</li>
<li>You can still lose data with Apache Kafka</li>
<li>Most clouds provide managed Apache Kafka</li>
<li>It won’t transform data</li>
<li>It’s not a Database</li>
<li>It support binary protocol over TCP protocol</li>
<li>At the moment, you can’t sent large messages using Kafka</li>
<li>You should use Trogdor for fault testing of your system</li>
</ul>
<p>All that being said, Apache Kafka is probably the best tool for messaging and streaming tasks.</p>
<p>Thank you <a target="_blank" href="https://www.freecodecamp.org/news/what-to-consider-for-painless-apache-kafka-integration-df559e828876/undefined">Gwen Shapira</a> for your input and guidance along the way.</p>
<p>If you enjoyed this story, please click the ? button. Feel free to leave a comment below.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/aPn5w0kq5WP9lvUQ2a7dF1Yx-bUxVfvMDO1i" alt="Image" width="800" height="569" loading="lazy"></p>
<p><a target="_blank" href="https://medium.com/@adipolak">Follow me</a> here, or <a target="_blank" href="https://twitter.com/adipolak">here</a> for more posts about Scala, Kotlin, Big data, clean code and software engineers nonsense. Cheers!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ These Are The Best Free Open Data Sources Anyone Can Use ]]>
                </title>
                <description>
                    <![CDATA[ By Hiren Patel What is Open Data? In simple terms, Open Data means the kind of data which is open for anyone and everyone for access, modification, reuse, and sharing. Open Data derives its base from various “open movements” such as open source, open... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/https-medium-freecodecamp-org-best-free-open-data-sources-anyone-can-use-a65b514b0f2d/</link>
                <guid isPermaLink="false">66c3571b1efc805979ae9f7c</guid>
                
                    <category>
                        <![CDATA[ big data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Data Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Machine Learning ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open data ]]>
                    </category>
                
                    <category>
                        <![CDATA[ open source ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Thu, 10 Jan 2019 17:28:42 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*UBez92qzGAno5MLXjnIMIw.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Hiren Patel</p>
<h2 id="heading-what-is-open-data">What is Open Data?</h2>
<p>In simple terms, <a target="_blank" href="https://en.wikipedia.org/wiki/Open_data">Open Data</a> means the kind of data which is open for anyone and everyone for access, modification, reuse, and sharing.</p>
<p>Open Data derives its base from various “open movements” such as open source, open hardware, open government, open science etc.</p>
<p>Governments, independent organizations, and agencies have come forward to open the floodgates of data to create more and more open data for free and easy access.</p>
<h2 id="heading-why-is-open-data-important">Why Is Open Data Important?</h2>
<p><a target="_blank" href="http://www.prowebscraper.com/blog/6-major-benefits-of-open-data/">Open data is important</a> because the world has grown increasingly data-driven. But if there are restrictions on the access and use of data, the idea of data-driven business and governance will not be materialized.</p>
<p>Therefore, open data has its own unique place. It can allow a fuller understanding of the global problems and universal issues. It can give a big boost to businesses. It can be a great impetus for machine learning. It can help fight global problems such as disease or crime or famine. Open data can empower citizens and hence can strengthen democracy. It can streamline the processes and systems that the society and governments have built. It can help transform the way we understand and engage with the world.</p>
<p><strong>So here’s my list of 15 awesome Open Data sources:</strong></p>
<h3 id="heading-1-world-bank-open-datahttpsdataworldbankorg">1. <a target="_blank" href="https://data.worldbank.org/"><strong>World Bank Open Data</strong></a></h3>
<p>As a repository of the world’s most comprehensive data regarding what’s happening in different countries across the world, World Bank Open Data is a vital source of Open Data. It also provides access to other datasets as well which are mentioned in the data catalog.</p>
<p>World Bank Open Data is massive because it has got 3000 datasets and 14000 indicators encompassing microdata, time series statistics, and geospatial data.</p>
<p>Accessing and discovering the data you want is also quite easy. All you need to do is to specify the indicator names, countries or topics and it will open up the treasure-house of Open Data for you. It also allows you to download data in different formats such as CSV, Excel, and XML.</p>
<p>If you are a journalist or academic, you will be enthralled by the array of tools available to you. You can get access to analysis and visualization tools that can bolster your research. It can felicitate a deeper and better understanding of global problems.</p>
<p>You can get access to the API which can help you create the data visualizations you need, live combinations with other data sources and many more such features.</p>
<p>Therefore, it’s no surprise that World Bank Open Data tops any list of Open Data sources!</p>
<h3 id="heading-2-who-world-health-organization-open-data-repositoryhttpswwwwhointghodatabaseen">2. <a target="_blank" href="https://www.who.int/gho/database/en/"><strong>WHO (World Health Organization) — Open data repository</strong></a></h3>
<p>WHO’s Open Data repository is how WHO keeps track of health-specific statistics of its 194 Member States.</p>
<p>The repository keeps the data systematically organized. It can be accessed as per different needs. For instance, whether it is mortality or burden of diseases, one can access data classified under 100 or more categories such as the Millennium Development Goals (child nutrition, child health, maternal and reproductive health, immunization, HIV/AIDS, tuberculosis, malaria, neglected diseases, water and sanitation), non communicable diseases and risk factors, epidemic-prone diseases, health systems, environmental health, violence and injuries, equity etc.</p>
<p>For your specific needs, you can go through the datasets according to themes, category, indicator, and country.</p>
<p>The good thing is that it is possible to download whatever data you need in Excel Format. You can also monitor and analyze data by making use of its data portal.</p>
<p>The API to the World Health Organization’s data and statistics content is also available.</p>
<h3 id="heading-3-google-public-data-explorerhttpswwwgooglecompublicdatadirectory">3. <a target="_blank" href="https://www.google.com/publicdata/directory"><strong>Google Public Data Explorer</strong></a></h3>
<p>Launched in 2010, Google Public Data Explorer can help you explore vast amounts of public-interest datasets. You can visualize and communicate the data for your respective uses.</p>
<p>It makes the data from different agencies and sources available. For instance, you can access data from World Bank, U. S. Bureau of Labor Statistics and U.S. Bureau, OECD, IMF, and others.</p>
<p>Different stakeholders access this data for a variety of purposes. Whether you are a student or a journalist, whether you are a policy maker or an academic, you can leverage this tool in order to create visualizations of public data.</p>
<p>You can deploy various ways of representing the data such as line graphs, bar graphs, maps and bubble charts with the help of Data Explorer.</p>
<p>The best part is that you would find these visualizations quite dynamic. It means that you will see them change over time. You can change topics, focus on different entries and modify the scale.</p>
<p>It is easily shareable too. As soon as you get the chart ready, you can embed it on your website or blog or simply share a link with your friends.</p>
<h3 id="heading-4-registry-of-open-data-on-aws-rodahttpsregistryopendataaws">4. <a target="_blank" href="https://registry.opendata.aws/"><strong>Registry of Open Data on AWS (RODA)</strong></a></h3>
<p>This is a repository containing public datasets. It is data which is available from AWS resources.</p>
<p>As far as RODA is concerned, you can discover and share the data which is publicly available.</p>
<p>In RODA, you can use keywords and tags for common types of data such as genomic, satellite imagery and transportation in order to search whatever data that you are looking for. All of this is possible on a simple web interface.</p>
<p>For every dataset, you will discover detail page, usage examples, license information and tutorials or applications that use this data.</p>
<p>By making use of a broad range of compute and data analytics products, you can analyze the open data and build whatever services you want.</p>
<p>While the data you access is available through AWS resources, you need to bear in mind that it is not provided by AWS. This data belongs to different agencies, government organizations, researchers, businesses and individuals.</p>
<h3 id="heading-5-european-union-open-data-portalhttpopen-dataeuropaeuendata">5. <a target="_blank" href="http://open-data.europa.eu/en/data/"><strong>European Union Open Data Portal</strong></a></h3>
<p>You can access whatever open data EU institutions, agencies and other organizations publish on a single platform namely European Union Open Data Portal.</p>
<p>The EU Open Data Portal is home to vital open data pertaining to EU policy domains. These policy domains include economy, employment, science, environment, and education.</p>
<p>Around 70 EU institutions, organizations or departments such as Eurostat, the European Environment Agency, the Joint Research Centre and other European Commission Directorates General and EU Agencies have made their datasets public and allowed access. These datasets have crossed the number of 11700 till date.</p>
<p>The portal enables easy access. You can easily search, explore, link, download and reuse the data through a catalog of common metadata. You can do so for your specific purposes. It could be commercial or non-commercial purposes.</p>
<p>You can search the metadata catalog through an interactive search engine (Data tab) and SPARQL queries (Linked data tab).</p>
<p>By making use of this catalog, you can gain access to the data stored on the different websites of the EU institutions, agencies and organizations.</p>
<h3 id="heading-6-fivethirtyeighthttpsdatafivethirtyeightcom">6. <a target="_blank" href="https://data.fivethirtyeight.com/"><strong>FiveThirtyEight</strong></a></h3>
<p>It is a great site for data-driven journalism and story-telling.</p>
<p>It provides its various sources of data for a variety of sectors such as politics, sports, science, economics etc. You can download the data as well.</p>
<p>When you access the data, you will come across a brief explanation regarding each dataset with respect to its source. You will also get to know what it stands for and how to use it.</p>
<p>In order to render this data user-friendly, it provides datasets in as simple, non-proprietary formats such as CSV files as possible. Needless to say, these formats can be easily accessed and processed by humans as well as machines.</p>
<p>With the help of these datasets, you can create stories and visualizations as per your own requirements and preference.</p>
<h3 id="heading-7-us-census-bureauhttpwwwcensusgovdatahtml">7. <a target="_blank" href="http://www.census.gov/data.html"><strong>U.S. Census Bureau</strong></a></h3>
<p>U.S. Census Bureau is the biggest statistical agency of the federal government. It stores and provides reliable facts and data regarding people, places, and economy of America.</p>
<p>The Census Bureau considers its noble mission to extend its services as the most reliable provider of quality data.</p>
<p>Whether it is a federal, state, local or tribal government, all of them make use of census data for a variety of purposes. These governments use this data to determine the location of new housing and public facilities. They also make use of it at the time of examining the demographic characteristics of communities, states, and the USA.</p>
<p>This data is also made use of in planning of transportation systems and roadways. When it comes to deciding quotas and creating police and fire precincts, this data comes in handy. When governments create localized areas of elections, schools, utilities etc, they make use of this data. It is a practice to compile population information once a decade and this data are quite useful in accomplishing the same.</p>
<p>There are various tools such as American Fact Finder, Census Data Explorer and Quick Facts which are useful in case you want to search, customize and visualize data.</p>
<p>For instance, Quick Facts alone contains statistics for all the states, counties, cities and even towns with a population of 5000 or more.</p>
<p>Likewise, American Fact Finder can help you discover popular facts such as population, income etc. It provides information that is frequently requested.</p>
<p>The good thing is that you can search, interact with the data, get to know about popular statistics and see the related charts through Census Data Explorer. Moreover, you can also use visual tool to customize data on an interactive maps experience.</p>
<h3 id="heading-8-datagovhttpswwwdatagov">8. <a target="_blank" href="https://www.data.gov/"><strong>Data.gov</strong></a></h3>
<p>Data.gov is the treasure-house of US government’s open data. It was only recently that the decision was made to make all government data available for free.</p>
<p>When it was launched, there were only 47. There are now 180,000 datasets.</p>
<p>Why Data.gov is a great resource is because you can find data, tools, and resources that you can deploy for a variety of purposes. You can conduct your research, develop your web and mobile applications and even design data visualizations.</p>
<p>All you need to do is enter keywords in the search box and browse through types, tags, formats, groups, organization types, organizations, and categories. This will facilitate easy access to data or datasets that you need.</p>
<p>Data.gov follows the Project Open Data Schema — a set of requisite fields (Title, Description, Tags, Last Update, Publisher, Contact Name, etc.) for every data set displayed on Data.gov.</p>
<h3 id="heading-9-dbpediahttpswikidbpediaorg">9. <a target="_blank" href="https://wiki.dbpedia.org/"><strong>DBpedia</strong></a></h3>
<p>As you know, Wikipedia is a great source of information. DBpedia aims at getting structured content from the valuable information that Wikipedia created.</p>
<p>With DBpedia, you can semantically search and explore relationships and properties of Wikipedia resource. This includes links to other related datasets as well.</p>
<p>There are around 4.58 million entities in the DBpedia dataset. 4.22 million are classified in ontology, including 1,445,000 persons, 735,000 places, 123,000 music albums, 87,000 films, 19,000 video games, 241,000 organizations, 251,000 species and 6,000 diseases.</p>
<p>There are labels and abstracts for these entities in around 125 languages. There are 25.2 million links to images. There are 29.8 million links to external web pages.</p>
<p>All you need to do in order to use DBpedia is write SPARQL queries against endpoint or by downloading their dumps.</p>
<p>DBpedia has benefitted several enterprises, such as Apple (via Siri), Google (via Freebase and Google Knowledge Graph), and IBM (via Watson), and particularly their respective prestigious projects associated with artificial intelligence.</p>
<h3 id="heading-10-freecodecamp-open-datahttpsgithubcomfreecodecampopen-data">10. <a target="_blank" href="https://github.com/freeCodeCamp/open-data"><strong>freeCodeCamp Open Data</strong></a></h3>
<p>It is an open source community. Why it matters is because it enables you to code, build pro bono projects after nonprofits and grab a job as a developer.</p>
<p>In order to make this happen, the freeCodeCamp.org community makes available enormous amounts of data every month. They have turned it into open data.</p>
<p>You will find a variety of things in this repository. You can find datasets, analysis of the same and even demos of projects based on the freeCodeCamp data. You can also find links to external projects involving the freeCodeCamp data.</p>
<p>It can help you with a diversity of projects and tasks that you may have in mind. Whether it is web analytics, social media analytics, social network analysis, education analysis, data visualization, data-driven web development or bots, the data offered by this community can extremely useful and effective.</p>
<h3 id="heading-11-yelp-open-datasetshttpswwwyelpcomdataset">11. <a target="_blank" href="https://www.yelp.com/dataset"><strong>Yelp Open Datasets</strong></a></h3>
<p>The Yelp dataset is basically a subset of nothing but our own businesses, reviews and user data for use in personal, educational and academic pursuits.</p>
<p>There are 5,996,996 reviews, 188,593 businesses, 280,991 pictures and 10 metropolitan areas included in Yelp Open Datasets.</p>
<p>You can use them for different purposes. Since they are available as JSON files, you can use them in order to teach students about databases. You can use them to learn NLP or for sample production data while you understand how to design mobile apps.</p>
<p>In this dataset, you will find each file composed of a single object type, one JSON-object per-line.</p>
<h3 id="heading-12-unicef-datasethttpsdatauniceforg">12. <a target="_blank" href="https://data.unicef.org/"><strong>UNICEF Dataset</strong></a></h3>
<p>Since UNICEF concerns itself with a wide variety of critical issues, it has compiled relevant data on education, child labor, child disability, child mortality, maternal mortality, water and sanitation, low birth-weight, antenatal care, pneumonia, malaria, iodine deficiency disorder, female genital mutilation/cutting, and adolescents.</p>
<p>UNICEF’s open datasets published on the IATI Registry: <a target="_blank" href="http://www.iatiregistry.org/publisher/unicef">http://www.iatiregistry.org/publisher/unicef</a> has been extracted directly from UNICEF’s operating system (VISION) and other data systems, and it reflects inputs made by individual UNICEF offices.</p>
<p>The good thing is that there is a regular update when it comes to these datasets. Every month, the data is updated in order to make it more comprehensive, reliable and accurate.</p>
<p>You can freely and easily access this data. In order to do so, you can download this data in CSV format. You can also preview sample data prior to downloading it.</p>
<p>While anybody can explore and visualize UNICEF’s datasets, there are three principal publishers:</p>
<p><a target="_blank" href="http://open.unicef.org/">UNICEF’s AID TRANSPARENCY PORTAL</a> : You can far more easily access the datasets if you use this portal. It also includes details for each country that UNICEF works in.</p>
<p><a target="_blank" href="http://d-portal.org/ctrack.html?publisher=41122">Publisher d-portal</a> : It is, at the moment, in BETA. With this, portal, you can explore IATI data.</p>
<p>You can search the information related to development activities, budgets etc. You can explore this information country-wise.</p>
<p><a target="_blank" href="http://open.unicef.org/">Publisher’s data platform</a> : On this platform, you can easily access statistics, charts, and metrics on data accessed via the IATI Registry. If you click on the headers, you can also sort many of the tables that you see on the platform. You will also find many of the datasets in the platforms in machine-readable JSON format.</p>
<h3 id="heading-13-kagglehttpswwwkagglecomdatasets">13. <a target="_blank" href="https://www.kaggle.com/datasets"><strong>Kaggle</strong></a></h3>
<p>Kaggle is great because it promotes the use of different dataset publication formats. However, the better part is that it strongly recommends that the dataset publishers share their data in an accessible, non-proprietary format.</p>
<p>The platform supports open and accessible data formats. It is important not just for access but also for whatever you want to do with this data. Therefore, Kaggle Dataset clearly defines the file formats which are recommended while sharing data.</p>
<p>The unique thing about Kaggle datasets is that it is not just a data repository. Each dataset stands for a community that enables you to discuss data, find out public codes and techniques, and conceptualize your own projects in Kernels.</p>
<p>CSV, JSON, SQLite, Archive, Big Query etc. are files types that Kaggle supports. You can find a variety of resources in order to start working on your open data project.</p>
<p>The best part is that Kaggle allows you to publish and share datasets privately or publicly.</p>
<h3 id="heading-14-lodumhttpslodumde">14. <a target="_blank" href="https://lodum.de"><strong>LODUM</strong></a></h3>
<p>It is the Open Data initiative of the University of Münster. Under this initiative, it is made possible for anyone to access any public information about the university in machine-readable formats. You can easily access and reuse it as per your needs.</p>
<p>Open data about scientific artifacts and encoded as linked data is made available under this project.</p>
<p>With the help of Linked Data, it is possible to share and use data, ontologies and various metadata standards. It is, in fact, envisaged that it will be the accepted standard for providing metadata, and the data itself on the Web.</p>
<p>The LODUM team has co-initiated <a target="_blank" href="http://linkeduniversities.org/">LinkedUniversities.org</a> and <a target="_blank" href="http://linkedscience.org/">LinkedScience.org</a>.</p>
<p>You can use <a target="_blank" href="http://data.uni-muenster.de/php/sparql/">SPARQL editor</a> or <a target="_blank" href="https://cran.r-project.org/web/packages/SPARQL/SPARQL.pdf">SPARQL package</a> of R to analyze data.</p>
<p>SPARQL Package enables to connect to a SPARQL endpoint over HTTP, pose a SELECT query or an update query (LOAD, INSERT, DELETE).</p>
<h3 id="heading-15-uci-machine-learning-repositoryhttpsarchiveicsuciedumlindexphp">15. <a target="_blank" href="https://archive.ics.uci.edu/ml/index.php"><strong>UCI Machine Learning Repository</strong></a></h3>
<p>It serves as a comprehensive repository of databases, domain theories, and data generators that are used by the machine learning community for the empirical analysis of machine learning algorithms.</p>
<p>In this repository, there are, at present, 463 datasets as a service to the machine learning community.</p>
<p>The Center for Machine Learning and Intelligent Systems at the University of California, Irvine hosts and maintains it. David Aha had originally created it as a graduate student at UC Irvine.</p>
<p>Since then, students, educators, and researchers all over the world make use of it as a reliable source of machine learning datasets.</p>
<p>How it works is that each dataset has its distinct webpage which enlists all the known details including any relevant publications that investigate it. You can download these datasets as ASCII files, often the useful CSV format.</p>
<p>The details of datasets are summarized by aspects like attribute types, number of instances, number of attributes and year published that can be sorted and searched.</p>
<h4 id="heading-open-data-portals-and-search-engines"><strong>Open Data Portals and Search Engines:</strong></h4>
<p>While there are plenty of datasets published by numerous agencies every year, very few datasets become recognized and established.</p>
<p>The reason why very few such datasets sustain as useful resource is that it is a challenge to develop, manage and provide the data in a way that people and organizations find it useful and easy to use.</p>
<p>However, please find below a list of other few important open data portals and platforms that permit users to access open data quite easily, study the impact and glean valuable insights.</p>
<ol>
<li><a target="_blank" href="https://toolbox.google.com/datasetsearch">Google dataset search</a></li>
<li><a target="_blank" href="https://dataverse.org">Dataverse</a></li>
<li><a target="_blank" href="https://opendatakit.org">Open Data Kit</a></li>
<li><a target="_blank" href="https://ckan.org">Ckan</a></li>
<li><a target="_blank" href="https://opendatamonitor.eu/frontend/web/index.php?r=dashboard%2Findex">Open Data Monitor</a></li>
<li><a target="_blank" href="http://plenar.io">Plenar.io</a></li>
<li><a target="_blank" href="http://opendataimpactmap.org/">Open Data Impact Map</a></li>
</ol>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>Open data is the order of the day. The world has gradually started moving towards open systems and open data is rightly in sync with that.</p>
<p>The business and organizations which leverage open data will gain a competitive edge and will be able to dominate the future.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
