Following my last post, I will present a real-time processing sample with Kafka and Storm using the Twitter Streaming API.
The solution consists of the following:
- twitter-kafka-producer: A very basic producer that reads tweets from the Twitter Streaming API and stores them in Kafka.
- twitter-storm-topology: A Storm topology that reads tweets from Kafka and, after applying filtering and sanitization, process the messages in parallel for:
- Sentiment Analysis: Using a sentiment analysis algorithm to classify the tweet into a positive or negative feeling.
- Top Hashtags: Calculates the top 20 hashtags using a sliding window.
The Storm topology consist of the following elements:
Kafka Spout: The spout implementation to read messages from Kafka.
Filtering: Filtering out all non-english language tweets.
Sanitization: Text normalization in order to be processed properly by the sentiment analysis algorithm.
Sentiment Analysis: The algorithm that analyses word by word the text of the tweet, giving a value between -1 to 1.
Sentiment Analysis to Cassandra: Stores the tweets and its sentiment value in Cassandra.
Hashtag Splitter: Splits the different hashtags appearing in a tweet.
Hashtag Counter: Counts hashtag occurrences.
Top Hashtag: Does a ranking of the top 20 hashtags given a sliding windows (using the Tick Tuple feature from Storm).
Top Hashtag to Cassandra: Stores the top 20 hashtags in Cassandra.
In this post we have seen the benefits of using Apache Kafka & Apache Storm to ingest and process streams of data, on next posts will look at the implementation details and will provide some analytical insight from the data stored in Cassandra.
The sample can be found on Github: https://github.com/mserrate/twitter-streaming-app