Big Data Infrastructure Week 2: MapReduce Algorithm Design (1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0.

Slides:



Advertisements
Similar presentations
Hadoop Programming. Overview MapReduce Types Input Formats Output Formats Serialization Job g/apache/hadoop/mapreduce/package-
Advertisements

The map and reduce functions in MapReduce are easy to test in isolation, which is a consequence of their functional style. For known inputs, they produce.
MAP REDUCE PROGRAMMING Dr G Sudha Sadasivam. Map - reduce sort/merge based distributed processing Best for batch- oriented processing Sort/merge is primitive.
Intro to Map-Reduce Feb 21, map-reduce? A programming model or abstraction. A novel way of thinking about designing a solution to certain problems…
Mapreduce and Hadoop Introduce Mapreduce and Hadoop
MapReduce in Action Team 306 Led by Chen Lin College of Information Science and Technology.
Cloud Computing Lecture #3 More MapReduce Jimmy Lin The iSchool University of Maryland Wednesday, September 10, 2008 This work is licensed under a Creative.
CS246 TA Session: Hadoop Tutorial Peyman kazemian 1/11/2011.
Intro to Map-Reduce Feb 4, map-reduce? A programming model or abstraction. A novel way of thinking about designing a solution to certain problems…
Hadoop: Nuts and Bolts Data-Intensive Information Processing Applications ― Session #2 Jimmy Lin University of Maryland Tuesday, February 2, 2010 This.
Lecture 3 – Hadoop Technical Introduction CSE 490H.
Jimmy Lin The iSchool University of Maryland Wednesday, April 15, 2009
Data-Intensive Text Processing with MapReduce Jimmy Lin The iSchool University of Maryland Sunday, May 31, 2009 This work is licensed under a Creative.
CS 425 / ECE 428 Distributed Systems Fall 2014 Indranil Gupta (Indy) Lecture 3: Mapreduce and Hadoop All slides © IG.
L22: SC Report, Map Reduce November 23, Map Reduce What is MapReduce? Example computing environment How it works Fault Tolerance Debugging Performance.
MapReduce and Data Management Based on slides from Jimmy Lin’s lecture slides ( (licensed.
Introduction to Google MapReduce WING Group Meeting 13 Oct 2006 Hendra Setiawan.
Hadoop, Hadoop, Hadoop!!! Jerome Mitchell Indiana University.
Big Data Analytics with R and Hadoop
大规模数据处理 / 云计算 Lecture 3 – Hadoop Environment 彭波 北京大学信息科学技术学院 4/23/2011 This work is licensed under a Creative Commons.
Inter-process Communication in Hadoop
MapReduce Programming Yue-Shan Chang. split 0 split 1 split 2 split 3 split 4 worker Master User Program output file 0 output file 1 (1) fork (2) assign.
Advanced Topics: MapReduce ECE 454 Computer Systems Programming Topics: Reductions Implemented in Distributed Frameworks Distributed Key-Value Stores Hadoop.
MapReduce April 2012 Extract from various presentations: Sudarshan, Chungnam, Teradata Aster, …
Map Reduce and Hadoop S. Sudarshan, IIT Bombay
CS525: Special Topics in DBs Large-Scale Data Management Hadoop/MapReduce Computing Paradigm Spring 2013 WPI, Mohamed Eltabakh 1.
MapReduce: Simplified Data Processing on Large Clusters Jeffrey Dean and Sanjay Ghemawat.
MapReduce: Hadoop Implementation. Outline MapReduce overview Applications of MapReduce Hadoop overview.
Hadoop/MapReduce Computing Paradigm 1 Shirish Agale.
Introduction to Hadoop and HDFS
HAMS Technologies 1
大规模数据处理 / 云计算 Lecture 5 – Hadoop Runtime 彭波 北京大学信息科学技术学院 7/23/2013 This work is licensed under a Creative Commons.
MapReduce How to painlessly process terabytes of data.
MapReduce M/R slides adapted from those of Jeff Dean’s.
CPS216: Advanced Database Systems (Data-intensive Computing Systems) Introduction to MapReduce and Hadoop Shivnath Babu.
MapReduce Kristof Bamps Wouter Deroey. Outline Problem overview MapReduce o overview o implementation o refinements o conclusion.
Tutorial: Big Data Algorithms and Applications Under Hadoop KUNPENG ZHANG SIDDHARTHA BHATTACHARYYA
大规模数据处理 / 云计算 Lecture 5 – Mapreduce Algorithm Design 彭波 北京大学信息科学技术学院 7/19/2011 This work is licensed under a Creative.
O’Reilly – Hadoop: The Definitive Guide Ch.7 MapReduce Types and Formats 29 July 2010 Taikyoung Kim.
MapReduce Theory and Practice 彭波 北京大学信息科学技术学院 7/15/2010 Some Slides borrow from Jimmy Lin and.
MapReduce Algorithm Design Based on Jimmy Lin’s slides
Before we start, please download: VirtualBox: – The Hortonworks Data Platform: –
By Jeff Dean & Sanjay Ghemawat Google Inc. OSDI 2004 Presented by : Mohit Deopujari.
CS525: Big Data Analytics MapReduce Computing Paradigm & Apache Hadoop Open Source Fall 2013 Elke A. Rundensteiner 1.
IBM Research ® © 2007 IBM Corporation Introduction to Map-Reduce and Join Processing.
大规模数据处理 / 云计算 Lecture 3 – Mapreduce Algorithm Design 闫宏飞 北京大学信息科学技术学院 7/16/2013 This work is licensed under a Creative.
C-Store: MapReduce Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY May. 22, 2009.
Team3: Xiaokui Shu, Ron Cohen CS5604 at Virginia Tech December 6, 2010.
Cloud Computing Mapreduce (2) Keke Chen. Outline  Hadoop streaming example  Hadoop java API Framework important APIs  Mini-project.
Hadoop/MapReduce Computing Paradigm 1 CS525: Special Topics in DBs Large-Scale Data Management Presented By Kelly Technologies
Big Data Infrastructure Week 2: MapReduce Algorithm Design (2/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0.
Big Data Infrastructure Week 3: From MapReduce to Spark (2/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0.
Data-Intensive Computing with MapReduce Jimmy Lin University of Maryland Thursday, January 31, 2013 Session 2: Hadoop Nuts and Bolts This work is licensed.
Next Generation of Apache Hadoop MapReduce Owen
INTRODUCTION TO HADOOP. OUTLINE  What is Hadoop  The core of Hadoop  Structure of Hadoop Distributed File System  Structure of MapReduce Framework.
BIG DATA/ Hadoop Interview Questions.
COMP7330/7336 Advanced Parallel and Distributed Computing MapReduce - Introduction Dr. Xiao Qin Auburn University
Implementation of Classifier Tool in Twister Magesh khanna Vadivelu Shivaraman Janakiraman.
Introduction to Google MapReduce
MapReduce Types, Formats and Features
MapReduce Computing Paradigm Basics Fall 2013 Elke A. Rundensteiner
Distributed Systems CS
Hadoop MapReduce Types
MapReduce Algorithm Design Adapted from Jimmy Lin’s slides.
Data processing with Hadoop
Distributed Systems CS
Lecture 3 – Hadoop Technical Introduction
MAPREDUCE TYPES, FORMATS AND FEATURES
MapReduce: Simplified Data Processing on Large Clusters
Map Reduce, Types, Formats and Features
Presentation transcript:

Big Data Infrastructure Week 2: MapReduce Algorithm Design (1/2) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States See for details CS 489/698 Big Data Infrastructure (Winter 2016) Jimmy Lin David R. Cheriton School of Computer Science University of Waterloo January 12, 2016 These slides are available at

Source: Wikipedia (The Scream)

Source: Wikipedia (Clouds) Aside: Cloud Computing

The best thing since sliced bread? Before clouds… Grids Connection machine Vector supercomputers … Cloud computing means many different things: Big data Rebranding of web 2.0 Utility computing Everything as a service

Rebranding of web 2.0 Rich, interactive web applications Clouds refer to the servers that run them AJAX as the de facto standard (for better or worse) Examples: Facebook, YouTube, Gmail, … “The network is the computer”: take two User data is stored “in the clouds” Rise of the tablets, smartphones, etc. (“thin client”) Browser is the OS

Source: Wikipedia (Electricity meter)

Utility Computing What? Computing resources as a metered service (“pay as you go”) Ability to dynamically provision virtual machines Why? Cost: capital vs. operating expenses Scalability: “infinite” capacity Elasticity: scale up or down on demand Does it make sense? Benefits to cloud users Business case for cloud providers I think there is a world market for about five computers.

Enabling Technology: Virtualization Hardware Operating System App Traditional Stack Hardware OS App Hypervisor OS Virtualized Stack Today’s buzzword: Docker

Everything as a Service Utility computing = Infrastructure as a Service (IaaS) Why buy machines when you can rent cycles? Examples: Amazon’s EC2, Rackspace Platform as a Service (PaaS) Give me nice API and take care of the maintenance, upgrades, … Example: Google App Engine, Altiscale Software as a Service (SaaS) Just run it for me! Example: Gmail, Salesforce

Who cares? A source of problems… Cloud-based services generate big data Clouds make it easier to start companies that generate big data As well as a solution… Ability to provision analytics clusters on-demand in the cloud Commoditization and democratization of big data capabilities

Source: Wikipedia (Clouds) So, what is the cloud?

What is the Matrix? Source: The Matrix - PPC Wiki - Wikia

Source: Google The datacenter is the computer!

combine ba12c9ac52bc78 partition map k1k1 k2k2 k3k3 k4k4 k5k5 k6k6 v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 ba12cc36ac52bc78 Shuffle and Sort: aggregate values by keys reduce a15b27c298 r1r1 s1s1 r2r2 s2s2 r3r3 s3s3 c2368

split 0 split 1 split 2 split 3 split 4 worker Master User Program output file 0 output file 1 (1) submit (2) schedule map (2) schedule reduce (3) read (4) local write (5) remote read (6) write Input files Map phase Intermediate files (on local disk) Reduce phase Output files Adapted from (Dean and Ghemawat, OSDI 2004)

Source: Wikipedia (Mahout) Aside, what about Spark?

MapReduce API* Mapper void setup(Mapper.Context context) Called once at the beginning of the task void map(K in key, V in value, Mapper.Context context) Called once for each key/value pair in the input split void cleanup(Mapper.Context context) Called once at the end of the task Reducer /Combiner void setup(Reducer.Context context) Called once at the start of the task void reduce(K in key, Iterable values, Reducer.Context context) Called once for each key void cleanup(Reducer.Context context) Called once at the end of the task *Note that there are two versions of the API!

MapReduce API* Partitioner int getPartition(K key, V value, int numPartitions) Get the partition number given total number of partitions Job Represents a packaged Hadoop job for submission to cluster Need to specify input and output paths Need to specify input and output formats Need to specify mapper, reducer, combiner, partitioner classes Need to specify intermediate/final key/value classes Need to specify number of reducers (but not mappers, why?) Don’t depend of defaults! *Note that there are two versions of the API!

A tale of two packages… org.apache.hadoop.mapreduc e org.apache.hadoop.mapred Source: Wikipedia (Budapest)

Data Types in Hadoop: Keys and Values WritableDefines a de/serialization protocol. Every data type in Hadoop is a Writable. WritableComprableDefines a sort order. All keys must be of this type (but not values). IntWritable LongWritable Text … Concrete classes for different data types. SequenceFiles Binary encoded of a sequence of key/value pairs

“Hello World”: Word Count Map(String docid, String text): for each word w in text: Emit(w, 1); Reduce(String term, Iterator values): int sum = 0; for each v in values: sum += v; Emit(term, sum);

“Hello World”: Word Count private static class MyMapper extends Mapper { private final static IntWritable ONE = new IntWritable(1); private final static Text WORD = new public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { String line = ((Text) value).toString(); StringTokenizer itr = new StringTokenizer(line); while (itr.hasMoreTokens()) { WORD.set(itr.nextToken()); context.write(WORD, ONE); }

“Hello World”: Word Count private static class MyReducer extends Reducer { private final static IntWritable SUM = new public void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException { Iterator iter = values.iterator(); int sum = 0; while (iter.hasNext()) { sum += iter.next().get(); } SUM.set(sum); context.write(key, SUM); }

Three Gotchas Avoid object creation if possible Reuse Writable objects, change the payload Execution framework reuses value object in reducer Passing parameters via class statics

Getting Data to Mappers and Reducers Configuration parameters Directly in the Job object for parameters “Side data” DistributedCache Mappers/reducers read from HDFS in setup method

Complex Data Types in Hadoop How do you implement complex data types? The easiest way: Encoded it as Text, e.g., (a, b) = “a:b” Use regular expressions to parse and extract data Works, but janky The hard way: Define a custom implementation of Writable(Comprable) Must implement: readFields, write, (compareTo) Computationally efficient, but slow for rapid prototyping Implement WritableComparator hook for performance Somewhere in the middle: Bespin (via lin.tl) offers JSON support and lots of useful Hadoop types

Basic Cluster Components* One of each: Namenode (NN): master node for HDFS Jobtracker (JT): master node for job submission Set of each per slave machine: Tasktracker (TT): contains multiple task slots Datanode (DN): serves HDFS data blocks * Not quite… leaving aside YARN for now

Putting everything together… datanode daemon Linux file system … tasktracker slave node datanode daemon Linux file system … tasktracker slave node datanode daemon Linux file system … tasktracker slave node namenode namenode daemon job submission node jobtracker

Anatomy of a Job MapReduce program in Hadoop = Hadoop job Jobs are divided into map and reduce tasks An instance of running a task is called a task attempt (occupies a slot) Multiple jobs can be composed into a workflow Job submission: Client (i.e., driver program) creates a job, configures it, and submits it to jobtracker That’s it! The Hadoop cluster takes over…

Anatomy of a Job Behind the scenes: Input splits are computed (on client end) Job data (jar, configuration XML) are sent to JobTracker JobTracker puts job data in shared location, enqueues tasks TaskTrackers poll for tasks Off to the races…

InputSplit Source: redrawn from a slide by Cloduera, cc-licensed InputSplit Input File InputSplit RecordReader Mapper Intermediates Mapper Intermediates Mapper Intermediates Mapper Intermediates Mapper Intermediates InputFormat

…… InputSplit Client Records Mapper RecordRead er Mapper RecordRead er Mapper RecordRead er

Source: redrawn from a slide by Cloduera, cc-licensed Mapper Partitioner Intermediates Reducer Reduce Intermediates (combiners omitted here)

Source: redrawn from a slide by Cloduera, cc-licensed Reducer Reduce Output File RecordWriter OutputFormat Output File RecordWriter Output File RecordWriter

Input and Output InputFormat: TextInputFormat KeyValueTextInputFormat SequenceFileInputFormat … OutputFormat: TextOutputFormat SequenceFileOutputFormat …

Shuffle and Sort in MapReduce Probably the most complex aspect of MapReduce execution Map side Map outputs are buffered in memory in a circular buffer When buffer reaches threshold, contents are “spilled” to disk Spills merged in a single, partitioned file (sorted within each partition): combiner runs during the merges Reduce side First, map outputs are copied over to reducer machine “Sort” is a multi-pass merge of map outputs (happens in memory and on disk): combiner runs during the merges Final merge pass goes directly into reducer

Shuffle and Sort Mapper Reducer other mappers other reducers circular buffer (in memory) spills (on disk) merged spills (on disk) intermediate files (on disk) Combiner

Hadoop Workflow Hadoop Cluster You Submit node (workspace) Getting data in? Writing code? Getting data out?

Debugging Hadoop First, take a deep breath Start small, start locally Build incrementally

Source: Wikipedia (The Scream)

Code Execution Environments Different ways to run code: Local (standalone) mode Pseudo-distributed mode Fully-distributed mode Learn what’s good for what

Hadoop Debugging Strategies Good ol’ System.out.println Learn to use the webapp to access logs Logging preferred over System.out.println Be careful how much you log! Fail on success Throw RuntimeExceptions and capture state Programming is still programming Use Hadoop as the “glue” Implement core functionality outside mappers and reducers Independently test (e.g., unit testing) Compose (tested) components in mappers and reducers

Source: Wikipedia (Japanese rock garden) Questions?