Book Image

Learning Apache Apex

By : Thomas Weise, Ananth Gundabattula, Munagala V. Ramanath, David Yan, Kenneth Knowles
Book Image

Learning Apache Apex

By: Thomas Weise, Ananth Gundabattula, Munagala V. Ramanath, David Yan, Kenneth Knowles

Overview of this book

Apache Apex is a next-generation stream processing framework designed to operate on data at large scale, with minimum latency, maximum reliability, and strict correctness guarantees. Half of the book consists of Apex applications, showing you key aspects of data processing pipelines such as connectors for sources and sinks, and common data transformations. The other half of the book is evenly split into explaining the Apex framework, and tuning, testing, and scaling Apex applications. Much of our economic world depends on growing streams of data, such as social media feeds, financial records, data from mobile devices, sensors and machines (the Internet of Things - IoT). The projects in the book show how to process such streams to gain valuable, timely, and actionable insights. Traditional use cases, such as ETL, that currently consume a significant chunk of data engineering resources are also covered. The final chapter shows you future possibilities emerging in the streaming space, and how Apache Apex can contribute to it.
Table of Contents (17 chapters)
Title Page
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Preface

With business demand for faster insights derived from a growing number of information sources, the stream data processing technology is gaining popularity. Open-source-based products have become the prevailing implementation choice, and there has been a shift from the early MapReduce-based batch processing paradigm to newer, more expressive frameworks designed to process data as streams with minimal latency, high reliability, and accuracy guarantees.

Apache Apex is a large-scale stream-first big data processing framework that can be used to build low-latency, high-throughput complex analytics pipelines that execute on clusters. Apex was developed in 2012, and is continuously improving, and today it is being used in production by a number of companies for real time and batch processing at scale.

The big data landscape has a wide array of technology components and choices, and it remains a challenge for end users to piece everything together to be successful with their big data projects and realize value from their technology investments. 

This book will focus on how to apply Apex to big data processing use cases. It is written by experts in the area, including key contributors of Apache Apex who built the platform and have extensive experience working with users in the field that use Apex in their enterprise solutions. This book is an instructional and example-driven guide on how to build Apex applications for developers and hands-on enterprise architects. It will help identify use cases, the building blocks needed to put together solutions, and the process of implementing, testing and tuning applications for production. Fully functional example projects are provided to cover key aspects of data processing pipelines such as connectors for sources and sinks and common transformations. These projects can also be used as starting points for custom development. 

To connect with the Apache Apex project, please visit the website (http://apex.apache.org/), subscribe to the mailing lists mentioned there, or follow @ApacheApex on Twitter (https://twitter.com/apacheapex) or on SlideShare (http://www.slideshare.net/ApacheApex/presentations).

What this book covers

Chapter 1, Introduction to Apex, tells us how processing of data-in-motion is realized by Apache Apex. It also gives us a few Apex stream processing use cases and applications, and talks about their value propositions.

Chapter 2, Getting Started with Application Development, shows us how the Apex development process works from project creation to application deployment; the result is a simple working application.

Chapter 3, The Apex Library, talks about the Malhar library, which contains functional building blocks for writing real-world Apex applications.

Chapter 4, Scalability, Low Latency, and Performance, teaches us how Apex can scale and parallize processing, how to achieve dynamic scaling and better resource allocation in general, and why low latency and high throughput are both achievable without trading one off against the other. Operator partitioning and related techniques are central to this endeavor and are shown in practice in a sample application.

Chapter 5, Fault Tolerance and Reliability, explores the implementation of fault-tolerance and reliability in Apex including exactly-once semantics via distributed checkpointing and effective state management.

Chapter 6, Example Project – Real-Time Aggregation and Visualization, puts together all the building blocks to show a streaming analytics project and how to integrate it with a UI and existing infrastructure.

Chapter 7, Example Project – Real-Time Ride Service Data Processing, relies on a historical dataset to simulate a real-time ride service data stream. We are using event time and out-of-order processing, in particular, to build a simple analytics application that can serve as a template for more complicated event stream data pipelines.

Chapter 8, Example Project – ETL Using SQL, shows how to build a classic ETL application using Apex and Apache Calcite.

Chapter 9, Introduction to Apache Beam, introduces the Beam stream processing framework and an approach that allows a stream application engine such as Apex to be swapped in if needed.

Chapter 10, The Future of Stream Processing, looks at the road ahead for Apex and stream processing in general. We are going to examine the role of machine learning, as well as the role of SQL and why it is important for streaming.

What you need for this book 

Apex applications can be built and run locally on the user’s development machine via a properly written JUnit test. To do this, the user need only ensure that recent versions of the following software packages are present:

  • Java JDK (please note that the JRE alone is not adequate).
  • Maven build system
  • Git revision control system (optional)
  • A Java IDE such as Eclipse or IntelliJ (optional)

To run Apex applications on a cluster, one needs a cluster with Hadoop installed and a client to launch them. This client needs to be installed on the edge node (sometimes referred to as the gateway node or the client node); there is no need to install anything on the entire cluster.

There are several options to install the client, and some of them are listed on the Apex download page: http://apex.apache.org/downloads.html.

Without an existing Hadoop cluster, an easy way to get started for experimentation is a sandbox VM that already has a single node cluster configured (sandbox VMs are available from Hadoop vendors, as docker images and so on).

Who this book is for

This book is a practical and example-oriented guide on how to use Apache Apex to successfully implement solutions for real-world big data problems. The book assumes knowledge of application development with Java and familiarity with distributed systems. It does not require prior knowledge of Apex or stream processing, although knowledge of other big data processing frameworks is helpful. 

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text (such as database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles) are shown as follows where the code word is "10011": "This result tells the driver to drive toward the zip code 10011."

A block of code is set as follows:

PubSubWebSocketAppDataResult wsResult = dag.addOperator("QueryResult", new PubSubWebSocketAppDataResult());
  wsResult.setTopic("nyctaxi.result");
  try {
    wsResult.setUri(new URI("ws://localhost:8890/pubsub"));
  } catch (URISyntaxException ex) {
    throw Throwables.propagate(ex);
  }
dag.addStream("server_to_query_output", dataServer.queryResult, wsResult.input);

Any command-line input or output is written as follows:

bash> apex 
apex> launch target/malhar-examples-nyc-taxi-3.8.0-SNAPSHOT.apa

New terms and important words are shown in bold.

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to [email protected], and mention the book title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your email address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Apache-Apex. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/LearningApacheApex_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at [email protected] if you are having a problem with any aspect of the book, and we will do our best to address it.