Click Stream Data Analysis Using Hadoop

Similar documents
Hadoop: A Framework for Data- Intensive Distributed Computing. CS561-Spring 2012 WPI, Mohamed Y. Eltabakh

INTRODUCTION TO APACHE HADOOP MATTHIAS BRÄGER CERN GS-ASE

Introduction to Hadoop HDFS and Ecosystems. Slides credits: Cloudera Academic Partners Program & Prof. De Liu, MSBA 6330 Harvesting Big Data

Lecture 32 Big Data. 1. Big Data problem 2. Why the excitement about big data 3. What is MapReduce 4. What is Hadoop 5. Get started with Hadoop

Introduction to Big data. Why Big data? Case Studies. Introduction to Hadoop. Understanding Features of Hadoop. Hadoop Architecture.

Chapter 7. Using Hadoop Cluster and MapReduce

Implement Hadoop jobs to extract business value from large and varied data sets

Data processing goes big

Hadoop Introduction. Olivier Renault Solution Engineer - Hortonworks

Weekly Report. Hadoop Introduction. submitted By Anurag Sharma. Department of Computer Science and Engineering. Indian Institute of Technology Bombay

Hadoop Job Oriented Training Agenda

Hadoop 只 支 援 用 Java 開 發 嘛? Is Hadoop only support Java? 總 不 能 全 部 都 重 新 設 計 吧? 如 何 與 舊 系 統 相 容? Can Hadoop work with existing software?

MapReduce. Tushar B. Kute,

Hadoop Submitted in partial fulfillment of the requirement for the award of degree of Bachelor of Technology in Computer Science

Open source software framework designed for storage and processing of large scale data on clusters of commodity hardware

Map Reduce & Hadoop Recommended Text:

HDFS. Hadoop Distributed File System

Constructing a Data Lake: Hadoop and Oracle Database United!

L1: Introduction to Hadoop

Integrating Big Data into the Computing Curricula

Cloudera Certified Developer for Apache Hadoop

Qsoft Inc

Programming Hadoop 5-day, instructor-led BD-106. MapReduce Overview. Hadoop Overview

PassTest. Bessere Qualität, bessere Dienstleistungen!

Introduction to Pig. Content developed and presented by: 2009 Cloudera, Inc.

CSE 590: Special Topics Course ( Supercomputing ) Lecture 10 ( MapReduce& Hadoop)

Hadoop. Apache Hadoop is an open-source software framework for storage and large scale processing of data-sets on clusters of commodity hardware.

ITG Software Engineering

A bit about Hadoop. Luca Pireddu. March 9, CRS4Distributed Computing Group. (CRS4) Luca Pireddu March 9, / 18

Big Data With Hadoop

Big Data: Using ArcGIS with Apache Hadoop. Erik Hoel and Mike Park

Open source large scale distributed data management with Google s MapReduce and Bigtable

Hadoop and Map-Reduce. Swati Gore

International Journal of Advancements in Research & Technology, Volume 3, Issue 2, February ISSN

Prepared By : Manoj Kumar Joshi & Vikas Sawhney

Internals of Hadoop Application Framework and Distributed File System

Open source Google-style large scale data analysis with Hadoop

Introduction to Hadoop. New York Oracle User Group Vikas Sawhney

BIG DATA SOLUTION DATA SHEET

H2O on Hadoop. September 30,

COURSE CONTENT Big Data and Hadoop Training

HADOOP ADMINISTATION AND DEVELOPMENT TRAINING CURRICULUM

Tutorial: Big Data Algorithms and Applications Under Hadoop KUNPENG ZHANG SIDDHARTHA BHATTACHARYYA

Hadoop IST 734 SS CHUNG

Hadoop. MPDL-Frühstück 9. Dezember 2013 MPDL INTERN

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Manifest for Big Data Pig, Hive & Jaql

Big Data and Analytics by Seema Acharya and Subhashini Chellappan Copyright 2015, WILEY INDIA PVT. LTD. Introduction to Pig

Search Engine Marketing Analytics with Hadoop. Ecosystem: Case Study for Red Engine Digital Agency

Hadoop Ecosystem Overview. CMSC 491 Hadoop-Based Distributed Computing Spring 2015 Adam Shook

t] open source Hadoop Beginner's Guide ij$ data avalanche Garry Turkington Learn how to crunch big data to extract meaning from

Yahoo! Grid Services Where Grid Computing at Yahoo! is Today

NIST/ITL CSD Biometric Conformance Test Software on Apache Hadoop. September National Institute of Standards and Technology (NIST)

Big Data Too Big To Ignore

Detection of Distributed Denial of Service Attack with Hadoop on Live Network

What We Can Do in the Cloud (2) -Tutorial for Cloud Computing Course- Mikael Fernandus Simalango WISE Research Lab Ajou University, South Korea

NETWORK TRAFFIC ANALYSIS: HADOOP PIG VS TYPICAL MAPREDUCE

ITG Software Engineering

CSE-E5430 Scalable Cloud Computing Lecture 2

Big Data Analytics by Using Hadoop

Chase Wu New Jersey Ins0tute of Technology

MapReduce with Apache Hadoop Analysing Big Data

Lecture 10 - Functional programming: Hadoop and MapReduce

Systems Infrastructure for Data Science. Web Science Group Uni Freiburg WS 2012/13

Deploying Hadoop with Manager

Workshop on Hadoop with Big Data

Department of Computer Science University of Cyprus EPL646 Advanced Topics in Databases. Lecture 15

BIG DATA HANDS-ON WORKSHOP Data Manipulation with Hive and Pig

MapReduce and Hadoop. Aaron Birkland Cornell Center for Advanced Computing. January 2012

MapReduce, Hadoop and Amazon AWS

Infomatics. Big-Data and Hadoop Developer Training with Oracle WDP

Getting to know Apache Hadoop

COSC 6397 Big Data Analytics. 2 nd homework assignment Pig and Hive. Edgar Gabriel Spring 2015

Hadoop Architecture. Part 1

Jeffrey D. Ullman slides. MapReduce for data intensive computing

A STUDY ON HADOOP ARCHITECTURE FOR BIG DATA ANALYTICS

Hadoop for MySQL DBAs. Copyright 2011 Cloudera. All rights reserved. Not to be reproduced without prior written consent.

Role of Cloud Computing in Big Data Analytics Using MapReduce Component of Hadoop

Data-Intensive Computing with Map-Reduce and Hadoop

BIG DATA HADOOP TRAINING

Session: Big Data get familiar with Hadoop to use your unstructured data Udo Brede Dell Software. 22 nd October :00 Sesión B - DB2 LUW

NoSQL and Hadoop Technologies On Oracle Cloud

THE HADOOP DISTRIBUTED FILE SYSTEM

Research Laboratory. Java Web Crawler & Hadoop MapReduce Anri Morchiladze && Bachana Dolidze Supervisor Nodar Momtselidze

Generic Log Analyzer Using Hadoop Mapreduce Framework

Big Data Weather Analytics Using Hadoop

Big Data and Scripting map/reduce in Hadoop

CSE-E5430 Scalable Cloud Computing. Lecture 4


Extreme Computing. Hadoop MapReduce in more detail.

Survey of the Benchmark Systems and Testing Frameworks For Tachyon-Perf

Hadoop Streaming. Table of contents

Big Data and Apache Hadoop Adoption:

The Hadoop Eco System Shanghai Data Science Meetup

Hadoop and Eclipse. Eclipse Hawaii User s Group May 26th, Seth Ladd

Cloudera Distributed Hadoop (CDH) Installation and Configuration on Virtual Box

On a Hadoop-based Analytics Service System

Fault Tolerance in Hadoop for Work Migration

Transcription:

Governors State University OPUS Open Portal to University Scholarship Capstone Projects Spring 2015 Click Stream Data Analysis Using Hadoop Krishna Chand Reddy Gaddam Governors State University Sivakrishna Thumati Governors State University Follow this and additional works at: http://opus.govst.edu/capstones Part of the Systems Architecture Commons Recommended Citation Gaddam, Krishna Chand Reddy and Thumati, Sivakrishna, "Click Stream Data Analysis Using Hadoop" (2015). Capstone Projects. Paper 101. For more information about the academic degree, extended learning, and certificate programs of Governors State University, go to http://www.govst.edu/academics/degree_programs_and_certifications/ Visit the Governors State Computer Science Department This Project Summary is brought to you for free and open access by OPUS Open Portal to University Scholarship. It has been accepted for inclusion in Capstone Projects by an authorized administrator of OPUS Open Portal to University Scholarship. For more information, please contact opus@govst.edu.

Abstract The objective of this project is to collect Click Stream data of USA Government websites which is high in volume and velocity, and store it for analysis in a cost effective manner for enhanced insight and decision making. I expect to learn how to process this data in an engineer s way. I have plenty of tools in my hand like map reduce, pig, streaming and many more. But for a given business case it is very important to know which tools should be used to achieve the objective. In brief this is what I expect to learn. The Hadoop-ecosystem, State-of-the-art in Big Data age is perfectly suitable for click stream data analysis. To achieve the objective mentioned, it is very much necessary to have scalable systems at low cost which can operate at great speeds and bring out wonderful insights. Perfect answer for this is Hadoop. Keywords: Hadoop, Click Stream, Pig, Python, Json, Mapper, Reducer, Namenode, Datanode and HDFS.

Table of Contents 1) Introduction 1 2) What is Hadoop? 1 3) Apache Pig 2 4) How to execute the Project? 3 5) Commands for Running the Project 7 6) Software Requirements 8 7) Results 8 8) References 14

1. Introduction Click Stream are records of users interaction with a website or other compute application. Each row of the Click Stream contains a timestamp and an indication of what the user did. Every click or other action is logged hence the term Click Stream. In some circumstances, what the website does is also logged. This is useful when the website does different things for different users, such as post recommendations. I have developed a Big Data approach to Click Stream analysis that allows producing aggregates for reporting as well as session statistics like User_Agent, Country_Code, Know_User, Encoding_User_Login, Referring_URL, Timestamp, Geo_Region, Geo_city_name and Time Zone. A typical approach is to load the data into a Hadoop HDFS. 2. What is Apache Hadoop? The processing of large data sets across clusters of commodity servers for Apache Hadoop open-source software project that enables the distribution. It is a very high degree of fault tolerance, designed to scale up from a single server to thousands of machines. Rather than relying on high-end hardware, the resiliency of these groups to recognize and manage failures at the application layer is the ability of the software. Economics and large-scale computing will change the dynamics of Hadoop. Its effect can be boiled down to four main features (Scalable, Flexible, Cost-Effective, Fault Torrent). The project includes these modules: Hadoop Common: The most common utilities that support the other Hadoop modules. Hadoop Distributed File System (HDFS ): A distributed file system that provides highthroughput access to application data. Hadoop Map Reduce: A YARN-based system for parallel processing of large data sets. 1 P a g e

3. Apache Pig The pig was initially developed at Yahoo! To allow people using Apache Hadoop to focus more on analyzing large data sets and spend less time having to write mapper and reducer programs. Like actual pigs, who eat almost anything, the Pig programming language is designed to handle any kind of data hence the name! Pig consists of two components: the first language itself, which is called piglatin (yes, people of different naming projects tend to have a sense Associate Del Hadoop convention naming their mood), and the second is an environment execution, where pig Latin runs programs. Think about the relationship between a Java Virtual Machine (JVM) and a Java application. In this section, we ll just refer to the entity as a whole Pig. Ease of Programming: It is trivial to achieve parallel execution of tasks simple data analysis, embarrassingly parallel. Complex tasks transformation composed of multiple interrelated data is explicitly coded as sequences of data flow, making them easier to write, understand and maintain. Optimization and opportunities: The way in which tasks are coded allows the system to optimize performance automatically, allowing the user to focus on the semantics rather than efficiency. Extensibility: Users can create their own functions to do special-purpose processing. 2 P a g e

4. How to execute the Project? Step by step explanation of the method I have used: Step 1: In the below link, click stream data for a period of 1 year is archived in numerous small files and provided. http://www.usa.gov/about/developer-resources/1usagov.shtml downloading the data from the link provided is not that simple as general file download looks. There are several thousands of files, which has click stream data for a given day. To download these files manually, would definitely take a week or more. So the best way to answer this problem is to open a connection with the website server, get all the URL s present and start downloading the data. There are many programming languages that can do this task. But I feel Java is the best as there are many already built libraries which can do this job. So we choose Java platform to get this job done and library used is Jsoup. Using this program, first we got all the links present in the given website and filtered them to get the links which have these archived data. Now iterated over all the links and downloaded files to local disk. It took one entire day to download data from all the archived data links provided in the website. Step 2: As there are numerous files, we unzipped all the files on Linux platform and then linked together in a sequence in to a single file. Step 3: Now we have to load this data on to HDFS. Step 4: Data provided is in JSON Format. And In this project our interest is to find the top 10 websites per country and per month. So the fields we require would be only URL, month and country. So pre-processing this data and extract the required fields is pretty much important as this would decrease the processing time and storage on Hadoop. Since this data is already loaded on to Hadoop, now we can use the map reduce model to get the required fields. And what we foresee is there is no need of reducer for this data pre-processing operation. So it is enough to have identity reducer to store the output onto the HDFS. For this operation, we could have used Pig inbuilt JsonReader function to extract the required fields, but this function is provided from pig 1.0 version, but we have an old version, so only we could not use pig for this operation. But using pig inbuilt function would have saved us a lot of time. 3 P a g e

Another option we have is to write a UDF and register it, but in general on Hadoop Jython should be installed to register UDF, since we do not have Jython and installing that would might unstabilize the existing environment. So we did not go for that. Java can be used for this, but Java is not suitable for the data pre-processing as there would be separate libraries built for json reading, which should be added to classpath and it adds more complexity to the existing map reduce model. Finally, we are left with Hadoop streaming. In this case we can use any language which can read from standard input and write to standard output. So we have options like python, Perl, c, c++ and many more, but we chose python, as by default it is present in Linux environment. And python is very good for data processing. In mapper phase, python will read each line from standard input, decode the JSON format and store it in a dictionary which is very similar to map (key-value) in Java. Now required fields are URL, country and month, getting the URL and country is simple. But getting month from time stamp is a bit complex, in which we need to decode it to human readable format and then store month in a separate variable. Now emit these values from the mapper. After this they undergo shuffle and sort phase, followed by reducer which writes the output to HDFS, here we use an identity reducer since their aggregation is required. This step is the most important step which discards all the unnecessary data and only picks the required fields. Step 5: Data now has only three tab separated fields. Now process this data and find: 1. The top 10 most popular sites in terms of clicks 2. The top-10 most popular sites for each country, and 3. The top-10 most popular sites for each month. To find the top 10 most popular sites in terms of clicks, using Java will take at least 200 lines of code, and need many hours of testing on Hadoop platform. To avoid all these it is better to use high level interfaces built on Hadoop. We have two options Hive and Pig. We chose pig, which is procedural and has an option of storing results and various points. Following six lines of code will give the top 10 most popular sites in terms of clicks. Clicks = LOAD 'MiniProject7/output14/part-00000' USING PigStorage (' ') AS (url: char array, country: char array, month: int); Load data with fields as url, country and month. grpd = GROUP clicks BY url; Now group them by URL. 4 P a g e

cnt = for each grpd generate group, COUNT(clicks) as URLCount; Find out the count in each group. dorder = order cnt by url desc; Arrange them in descending order. top10 = limit dorder 10; Consider only top ten values. STORE top10 INTO 'top10urls'; Store the top ten URL. Now to find the top ten URL in each country and per each month, pig alone cannot achieve this. So for grouping data pig is used. grpcountryurl = GROUP clicks BY (country, url); Group the data by country and URL. countryurlcount = FOREACH grpcountryurl GENERATE FLATTEN (group) AS (country, url), COUNT (clicks) AS Country_url_count; Now count the url in each country. STORE countryurlcount INTO 'countryurlcount'; Store this data back to Hadoop. After Data is processed into {Country, URL, and Count} Format, the rest of the work in finding the top URLs per Country or Month is done through map-reduce. We have created a project named Project7 in eclipse and wrote the following classes for processing the data into top 10 URL per Country or top 10 URL per Month, CountryURLCount CountryURLMapper CountryURLReducer MonthURLCount MonthURLMapper 5 P a g e

MonthURLReducer URLCount CountryURLCount is the main class to be run for map-reduce job of finding top10 URLs per country. In it Mapper is set to CountryURLMapper and Reducer is set to CountryURLReducer. Job is configured. CountryURLMapper is the mapper class about the job of finding top10 URLS per Country. In it, we read data in the format {Country, URL, Count} as line and split the line with a tab as the separator. Mapper casts the data into the Country as Mapper Output Key and URLCount as Mapper output value. CountryURLReducer is the reducer class on the job of finding top10urls per Country. The input key is the country which comes as a sorted key value from the shuffle and sort mechanism of Map-Reduce and input value is the iterator containing URLCount Objects. In reducer we then collect all the URLs and their counts per country in Reducer. We then perform sorting of the data and then collect top 10 URLs per Country. We write the result in context with key as Country and value as URL into a separate file. The output folder for this Reducer is countryurloutput. In that folder one can find the results for top10 URLs per Country. MonthURLCount is the main class to be run for map-reduce job of finding top10 URLs per month. In it Mapper is set to MonthURLMapper and Reducer is set to MonthURLReducer. Job is configured. MonthURLMapper is the mapper class about the job of finding top10 URLS per Month. In it, we read data in the format {Month, URL, Count} as line and split the line with a tab as the separator. Mapper casts the data into the month as a Mapper output key and URLCount as Mapper output value. MonthURLReducer is the reducer class on the job of finding top10urls per Month. The input key is the Month which comes as a sorted key value from the shuffle and sort mechanism of Map-Reduce and input value is the iterator containing URLCount Objects. In reducer we then collect all the URLs and their counts per Month in Reducer. We then perform sorting of the data and then collect top 10 URLs per Month. We write the result in context with key as Month and value as URL into a separate file. The output folder for this Reducer is MonthUrlOutput. In that folder one can find the results for top10 URLs per Month. URLCount is a custom class to store the information of URL and its count. This is used as output value in both CountryURLMapper and MonthURLMapper. As a mapper output value it must implement Writable Interface. Since we are doing sorting of objects of URLCount, URLCount must also implement Comparable Interface. It is required that all Writable implementations must have a default constructor so that the Map Reduce framework can instantiate them, then populate their fields by calling readfields (). We must also override methods like hashcode (), equals () and ToString from Java. Lang. Object 6 P a g e

6. Commands for Running the Project Command for copying data to HDFS: hadoop fs -put usagov.json usagov.json Command for streaming the data and convert to json format: Hadoop jar /usr/lib/hadoop-0. 20-mapreduce/contrib/streaming/Hadoop-streaming. jar -file home/cloudera/desktop/project7/jsonreader.py -mapper /home/cloudera/desktop /Project7/jsonReader.py -reducer org.apache.hadoop.mapred.lib.identityreducer -input usagov.json -output LargeFile/ Command for running the pig: For Top 10 URLs: clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray, country, :chararray,month:int); grpd = GROUP clicks BY url; cnt = foreach grpd generate group, COUNT(clicks) as urlcount; dorder = order cnt by urlcount desc; top10 = limit dorder 10; STORE top10 INTO 'top10urls'; For Month list: pig -x mapred month.pig clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray,country :chararray,month:int); cntmonthlyurl = GROUP clicks BY (month, url); MonthlyUrlCount = FOREACH cntmonthlyurl GENERATE FLATTEN (group) AS (month, URL), COUNT (clicks) AS month_url_count; STORE MonthlyUrlCount INTO 'MonthlyUrlCount'; For Country: pig -x mapred Country.pig clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray, country :chararray, month:int); grpcountryurl = GROUP clicks BY (country,url); countryurlcount = FOREACH grpcountryurl GENERATE FLATTEN(group) AS (country,url),count(clicks) AS Country_url_count; STORE countryurlcount INTO 'countryurlcount'; 7 P a g e

7. Software requirements Operating System : Cloudera Technology : Hadoop, Pig, Python Web Technologies : Json 8. Results for Project Cluster Summary of Hadoop File System: 8 P a g e

Downloading Data from http://www.usa.gov/about/developer-resources/1usagov.shtml The best way to get this data from this URL is open a connection with website server get all the URL s present and start downloading data by using Java platform. Data downloaded in zip format and then extracted and Linux platform gunzip command. So data looks in below format of the list of files. 9 P a g e

After Running the below all scripts the Namenode format, shown as below: 10 P a g e

Top 10 URLS in terms of Number of Clicks The pig code to get Top 10 URL s: clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray,country:chararray,month:int); grpd = GROUP clicks BY url; cnt = foreach grpd generate group, COUNT(clicks) as urlcount; dorder = order cnt by urlcount desc; top10 = limit dorder 10; STORE top10 INTO 'top10urls'; After running above script the output shown as in below for top 10 URL s clicked mostly. 11 P a g e

Results - TOP 10 URLS per Country The Pig code for Top 10 URL s for each country: pig -x mapred Country.pig clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray,country:chararray,month:int); grpcountryurl = GROUP clicks BY (country,url); countryurlcount = FOREACH grpcountryurl GENERATE FLATTEN(group) AS (country,url),count(clicks) AS Country_url_count; STORE countryurlcount INTO 'countryurlcount'; After running above script the output shown as in below for top 10 URL s for each country. 12 P a g e

Results - TOP URLS per Month Pig code for Top URL s per Month: pig -x mapred month.pig clicks = LOAD 'LargeFile/part-00000' USING PigStorage(' ') AS (url:chararray,country:chararray,month:int); cntmonthlyurl = GROUP clicks BY (month, url); MonthlyUrlCount = FOREACH cntmonthlyurl GENERATE FLATTEN(group) AS (month, url),count(clicks) AS month_url_count; STORE MonthlyUrlCount INTO 'MonthlyUrlCount'; After running above script the output shown as in below for top URL s per month. 13 P a g e

9. Reference http://hadoop.apache.org/ http://www.cloudera.com/content/cloudera/en/about/hadoop-and-big-data.html http://www.cloudera.com/content/cloudera/en/about/hadoop-and-big-data.html http://www-01.ibm.com/software/data/infosphere/hadoop http://www.usa.gov/about/developer-resources/1usagov.shtml 14 P a g e