Preface - Real-time Analytics with Storm and Cassandra (2015)

Real-time Analytics with Storm and Cassandra (2015)


Storm, initially a project from the house of Twitter, has graduated to the league of Apache and thus rechristened from Twitter Storm. It is the brainchild of Nathan Marz that's now adopted by leagues of Cloudera's Distribution Including Apache Hadoop (CDH) and the Hortonworks Data Platform (HDP), and so on.

Apache Storm is a highly scalable, distributed, fast, and reliable real-time computing system designed to process very high velocity data. Cassandra complements the computing capability by providing lightning-fast read and writes, and this is the best combination currently available for data storage with Storm.

The combination of the Storm computing and Cassandra storage is helping technology evangelists to solve various business problems involving complex and high data volume situations such as real-time customer service, dashboards, security, sensor data analysis, data monetization, and so on.

This book will equip users with the capability to harness the processing power of Storm in combination with the speed and reliability of Cassandra to develop production-grade enterprise solutions on real-time use cases.

What this book covers

Chapter 1, Let's Understand Storm, gets you acquainted with the problems that need distributed computing solutions. It will take you through the journey of Storm and its advent.

Chapter 2, Getting Started with Your First Topology, teaches you to set up the developer's environment—sandbox and execute some of the code samples.

Chapter 3, Understanding Storm Internals by Examples, teaches you how to prepare Storm spouts and custom spouts. You will understand various kinds of groupings provided by Storm and their application to practical problems.

Chapter 4, Storm in a Clustered Mode, teaches you how to set up a multi-node Storm cluster to get the user acquainted with the distributed Storm setup and its components. This chapter will also get your acquainted with the Storm UI and various monitoring tools for Storm.

Chapter 5, Storm High Availability and Failover, conjugates the Storm topology with the RabbitMQ broker service and explores the high availability and failover scenarios of Storm with the help of various practical examples.

Chapter 6, Adding NoSQL Persistence to Storm, introduces you to Cassandra and explores various wrapper API's available to work with Cassandra. We will use the Hector API to connect Storm and Cassandra.

Chapter 7, Cassandra Partitioning, High Availability, and Consistency, walks you through the Cassandra internals. You will understand and apply the concepts of high availability, hinted handoff, and eventual consistency in context to Cassandra.

Chapter 8, Cassandra Management and Maintenance, gets you acquainted with the management aspects of Cassandra, such as scaling the cluster, node replacement, and so on, thus equipping you with all the experience required to handle real-life situations with Cassandra.

Chapter 9, Storm Management and Maintenance, gets you acquainted with the management aspects of Storm, such as scaling the cluster, setting up parallelism, and troubleshooting Storm.

Chapter 10, Advance Concepts in Storm, gives you an understanding of the Trident API. You will be building the Trident API with certain examples and illustrations around Trident.

Chapter 11, Distributed Cache and CEP with Storm, gets you acquainted with distributed cache, its need, and applicability to solve real-life use cases with Storm. It will also educate you about Esper as a CEP in combination with Storm.

Appendix, Quiz Answers, contains all the answers to the questions of the true or false statements and the fill in the blanks section.

Bonus Chapter, Using Storm and Cassandra for Real Life Use Cases, explains a few real-life use cases and blueprints to solve these cases using the technologies such as Storm and Cassandra. This chapter can be found online at

What you need for this book

For this book, you will require a Linux/Ubuntu OS, Eclipse, and 8 GB of RAM. The steps to set up other components such as Storm, RabbitMQ, Cassandra, memcache, Esper, and so on are covered in chapters corresponding to the said topics.

Who this book is for

This book is intended for Java developers who wish to get started on near real-time analytics track using Storm. This will serve as an expert's guide to developing highly available and scalable solutions to complex real-time problems. Apart from development, this book also covers the management and maintenance aspects of Storm and Cassandra, which is a mandatory requirement for productionizing any solution.


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, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The NumWorker configuration or TOPOLOGY_WORKERS configuration defined in Storm."

A block of code is set as follows:

// instantiates the new builder object

TopologyBuilder builder = new TopologyBuilder();

// Adds a new spout of type "RandomSentenceSpout" with a parallelism hint of 5

builder.setSpout("spout", new RandomSentenceSpout(), 5);

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are highlighted:

public void execute(Tuple tuple) {

String sentence = tuple.getString(0);

for(String word: sentence.split(" ")) {

_collector.emit(tuple, new Values(word)); //1


_collector.ack(tuple); //2


public void declareOutputFields(OutputFieldsDeclarer declarer) {

declarer.declare(new Fields("word")); //3



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

sudo apt-get -qy install rabbitmq-server

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: " Go to the Admin tab and select Policies and click on Add policy".


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.