Close Menu
    Trending
    • Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025
    • The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z
    • Musk’s X appoints ‘king of virality’ in bid to boost growth
    • Why Entrepreneurs Should Stop Obsessing Over Growth
    • Implementing IBCS rules in Power BI
    • What comes next for AI copyright lawsuits?
    • Why PDF Extraction Still Feels LikeHack
    • GenAI Will Fuel People’s Jobs, Not Replace Them. Here’s Why
    AIBS News
    • Home
    • Artificial Intelligence
    • Machine Learning
    • AI Technology
    • Data Science
    • More
      • Technology
      • Business
    AIBS News
    Home»Artificial Intelligence»MapReduce: How It Powers Scalable Data Processing
    Artificial Intelligence

    MapReduce: How It Powers Scalable Data Processing

    Team_AIBS NewsBy Team_AIBS NewsApril 22, 2025No Comments14 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    , I’ll give a short introduction to the MapReduce programming mannequin. Hopefully after studying this, you permit with a strong instinct of what MapReduce is, the function it performs in scalable information processing, and methods to acknowledge when it may be utilized to optimize a computational process.

    Contents:


    Terminology & Helpful Background:

    Under are some phrases/ideas which may be helpful to know earlier than studying the remainder of this text.


    What’s MapReduce?

    Launched by a few builders at Google within the early 2000s, MapReduce is a programming mannequin that allows large-scale information processing to be carried out in a parallel and distributed method throughout a compute cluster consisting of many commodity machines.

    The MapReduce programming mannequin is right for optimizing compute duties that may be damaged down into impartial transformations on distinct partitions of the enter information. These transformations are sometimes adopted by grouped aggregation.

    The programming mannequin breaks up the computation into the next two primitives:

    • Map: given a partition of the enter information to course of, parse the enter information for every of its particular person information. For every file, apply some user-defined information transformation to extract a set of intermediate key-value pairs.
    • Cut back: for every distinct key within the set of intermediate key-value pairs, mixture the values in some method to supply a smaller set of key-value pairs. Sometimes, the output of the cut back part is a single key-value pair for every distinct key.

    On this MapReduce framework, computation is distributed amongst a compute cluster of N machines with homogenous commodity {hardware}, the place N could also be within the a whole bunch or 1000’s, in apply. One in every of these machines is designated because the grasp, and all the opposite machines are designated as employees.

    • Grasp: handles process scheduling by assigning map and cut back duties to obtainable employees.
    • Employee: deal with the map and cut back duties it’s assigned by the grasp.
    MapReduce cluster setup. Strong arrows symbolize a fork(), and the dashed arrows symbolize process task.

    Every of the duties inside the map or cut back part could also be executed in a parallel and distributed method throughout the obtainable employees within the compute cluster. Nevertheless, the map and cut back phases are executed sequentially — that’s, all map duties should full earlier than kicking off the cut back part.

    Tough dataflow of the execution course of for a single MapReduce job.

    That each one in all probability sounds fairly summary, so let’s undergo some motivation and a concrete instance of how the MapReduce framework may be utilized to optimize widespread information processing duties.


    Motivation & Easy Instance

    The MapReduce programming mannequin is usually greatest for big batch processing duties that require executing impartial information transformations on distinct teams of the enter information, the place every group is usually recognized by a singular worth of a keyed attribute.

    You possibly can consider this framework as an extension to the split-apply-combine sample within the context of knowledge evaluation, the place map encapsulates the split-apply logic and cut back corresponds with the mix. The crucial distinction is that MapReduce may be utilized to realize parallel and distributed implementations for generic computational duties exterior of knowledge wrangling and statistical computing.

    One of many motivating information processing duties that impressed Google to create the MapReduce framework was to construct indexes for its search engine.

    We are able to categorical this process as a MapReduce job utilizing the next logic:

    • Divide the corpus to look by means of into separate partitions/paperwork.
    • Outline a map() perform to use to every doc of the corpus, which is able to emit pairs for each phrase that’s parsed within the partition.
    • For every distinct key within the set of intermediate pairs produced by the mappers, apply a user-defined cut back() perform that can mix the doc IDs related to every phrase to supply pairs.
    MapReduce workflow for developing an inverted index.

    For added examples of knowledge processing duties that match properly with the MapReduce framework, try the original paper.


    MapReduce Walkthrough

    There are quite a few different nice sources that walkthrough how the MapReduce algorithm works. Nevertheless, I don’t really feel that this text could be full with out one. After all, consult with the original paper for the “supply of fact” of how the algorithm works.

    First, some fundamental configuration is required to organize for execution of a MapReduce job.

    • Implement map() and cut back() to deal with the info transformation and aggregation logic particular to the computational process.
    • Configure the block measurement of the enter partition handed to every map process. The MapReduce library will then set up the variety of map duties accordingly, M, that shall be created and executed.
    • Configure the variety of cut back duties, R, that shall be executed. Moreover, the person could specify a deterministic partitioning perform to specify how key-value pairs are assigned to partitions. In apply, this partitioning perform is usually a hash of the important thing (i.e. hash(key) mod R).
    • Sometimes, it’s fascinating to have fine task granularity. In different phrases, M and R must be a lot bigger than the variety of machines within the compute cluster. Because the grasp node in a MapReduce cluster assigns duties to employees primarily based on availability, partitioning the processing workload into many duties decreases the probabilities that any single employee node shall be overloaded.
    MapReduce Job Execution (M = 6, R = 2).

    As soon as the required configuration steps are accomplished, the MapReduce job may be executed. The execution technique of a MapReduce job may be damaged down into the next steps:

    • Partition the enter information into M partitions, the place every partition is related to a map employee.
    • Every map employee applies the user-defined map() perform to its partition of the info. The execution of every of those map() capabilities on every map employee could also be carried out in parallel. The map() perform will parse the enter information from its information partition and extract all key-value pairs from every enter file.
    • The map employee will kind these key-value pairs in rising key order. Optionally, if there are a number of key-value pairs for a single key, the values for the important thing could also be combined right into a single key-value pair, if desired.
    • These key-value pairs are then written to R separate information saved on the native disk of the employee. Every file corresponds to a single cut back process. The places of those information are registered with the grasp.
    • When all of the map duties have completed, the grasp notifies the reducer employees the places of the intermediate information related to the cut back process.
    • Every cut back process makes use of remote procedure calls to learn the intermediate information related to the duty saved on the native disks of the mapper employees.
    • The cut back process then iterates over every of the keys within the intermediate output, after which applies the user-defined cut back() perform to every distinct key within the intermediate output, together with its related set of values.
    • As soon as all of the cut back employees have accomplished, the grasp employee notifies the person program that the MapReduce job is full. The output of the MapReduce job shall be obtainable within the R output information saved within the distributed file system. The customers could entry these information instantly, or cross them as enter information to a different MapReduce job for additional processing.

    Expressing a MapReduce Job in Code

    Now let’s take a look at how we will use the MapReduce framework to optimize a typical information engineering workload— cleansing/standardizing giant quantities of uncooked information, or the rework stage of a typical ETL workflow.

    Suppose that we’re in command of managing information associated to a person registration system. Our information schema could include the next data:

    • Identify of person
    • Date they joined
    • State of residence
    • E mail tackle

    A pattern dump of uncooked information could seem like this:

    John Doe , 04/09/25, il, [email protected]
     jane SMITH, 2025/04/08, CA, [email protected]
     JOHN  DOE, 2025-04-09, IL, [email protected]
     Mary  Jane, 09-04-2025, Ny, [email protected]
        Alice Walker, 2025.04.07, tx, [email protected]
       Bob Stone  , 04/08/2025, CA, [email protected]
     BOB  STONE , 2025/04/08, CA, [email protected]

    Earlier than making this information accessible for evaluation, we in all probability wish to rework the info to a clear, customary format.

    We’ll wish to repair the next:

    • Names and states have inconsistent case.
    • Dates differ in format.
    • Some fields include redundant whitespace.
    • There are duplicate entries for sure customers (ex: John Doe, Bob Stone).

    We might want the ultimate output to seem like this.

    alice walker,2025-04-07,TX,[email protected]
    bob stone,2025-04-08,CA,[email protected]
    jane smith,2025-04-08,CA,[email protected]
    john doe,2025-09-04,IL,[email protected]
    mary jane,2025-09-04,NY,[email protected]

    The information transformations we wish to perform are easy, and we may write a easy program that parses the uncooked information and applies the specified transformation steps to every particular person line in a serial method. Nevertheless, if we’re coping with tens of millions or billions of information, this method could also be fairly time consuming.

    As an alternative, we will use the MapReduce mannequin to use our information transformations to distinct partitions of the uncooked information, after which “mixture” these reworked outputs by discarding any duplicate entries that seem within the intermediate outcome.

    There are numerous libraries/frameworks obtainable for expressing applications as MapReduce jobs. For our instance, we’ll use the mrjob library to specific our information transformation program as a MapReduce job in python.

    mrjob simplifies the method of writing MapReduce because the developer merely wants to supply implementations for the mapper and reducer logic in a single python class. Though it’s now not beneath lively growth and will not obtain the identical stage of efficiency as different choices that permit deployment of jobs on Hadoop (as its a python wrapper across the Hadoop API), it’s a good way for anyone acquainted with python to begin studying methods to write MapReduce jobs and recognizing methods to break up computation into map and cut back duties.

    Utilizing mrjob, we will write a easy MapReduce job by subclassing the MRJob class and overriding the mapper() and reducer() strategies.

    Our mapper() will include the info transformation/cleansing logic we wish to apply to every file of enter:

    • Standardize names and states to lowercase and uppercase, respectively.
    • Standardize dates to %Y-%m-%d format.
    • Strip pointless whitespace round fields.

    After making use of these information transformations to every file, it’s potential that we could find yourself with duplicate entries for some customers. Our reducer() implementation will eradicate such duplicate entries that seem.

    from mrjob.job import MRJob
    from mrjob.step import MRStep
    from datetime import datetime
    import csv
    import re
    
    class UserDataCleaner(MRJob):
    
       def mapper(self, _, line):
           """
           Given a file of enter information (i.e. a line of csv enter),
           parse the file for  pairs and emit them.
           
           If this perform isn't applied,
           by default,  shall be emitted.
           """
           attempt:
               row = subsequent(csv.reader([line])) # returns row contents as an inventory of strings ("," delimited by default)
               
               # if row contents do not comply with schema, do not extract KV pairs
               if len(row) != 4:
                   return
               
               title, date_str, state, electronic mail = row
    
               # clear information
               title = re.sub(r's+', ' ', title).strip().decrease() # substitute 2+ whitespaces with a single house, then strip main/trailing whitespace
               state = state.strip().higher()
               electronic mail = electronic mail.strip().decrease()
               date = self.normalize_date(date_str)
    
               # emit cleaned KV pair
               if title and date and state and electronic mail:
                   yield title, (date, state, electronic mail)
           besides: 
               cross # skip unhealthy information
    
       def reducer(self, key, values):
           """
           Given a Identify and an iterator of (Date, State, E mail) values related to that key,
           return a set of (Date, State, E mail) values for that Identify.
    
           It will eradicate all duplicate  entries.
           """
           seen = set()
           for worth in values:
               worth = tuple(worth)
               if worth not in seen:
                   seen.add(worth)
                   yield key, worth
              
       def normalize_date(self, date_str):
           codecs = ["%Y-%m-%d", "%m-%d-%Y", "%d-%m-%Y", "%d/%m/%y", "%m/%d/%Y", "%Y/%m/%d", "%Y.%m.%d"]
           for fmt in codecs:
               attempt:
                   return datetime.strptime(date_str.strip(), fmt).strftime("%Y-%m-%d")
               besides ValueError:
                   proceed
           return ""
    
    
    if __name__ == '__main__':
       UserDataCleaner.run()

    This is only one instance of a easy information transformation process that may be expressed utilizing the mrjob framework. For extra complicated data-processing duties that can not be expressed with a single MapReduce job, mrjob supports this by permitting builders to write down a number of mapper() and producer() strategies, and outline a pipeline of mapper/producer steps that outcome within the desired output.

    By default, mrjob executes your job in a single course of, as this permits for pleasant growth, testing, and debugging. After all, mrjob helps the execution of MapReduce jobs on varied platforms (Hadoop, Google Dataproc, Amazon EMR). It’s good to remember that the overhead of preliminary cluster setup may be pretty vital (~5+ min, relying on the platform and varied components), however when executing MapReduce jobs on really giant datasets (10+ GB), job deployment on one in all these platforms would save vital quantities of time because the preliminary setup overhead could be pretty small relative to the execution time on a single machine.

    Take a look at the mrjob documentation if you wish to discover its capabilities additional 🙂


    MapReduce: Contributions & Present State

    MapReduce was a major contribution to the event of scalable, data-intensive functions primarily for the next two causes:

    • The authors acknowledged that primitive operations originating from practical programming, map and reduce, may be pipelined collectively to perform many Big Data duties.
    • It abstracted away the difficulties that include executing these operations on a distributed system.

    Mapreduce was not vital as a result of it launched new primitive ideas. Fairly, MapReduce was so influential as a result of it encapsulated these map and cut back primitives right into a single library, which robotically dealt with challenges that come from managing distributed techniques, equivalent to task scheduling and fault tolerance. These abstractions allowed builders with little distributed programming expertise to write down parallel applications effectively.

    There have been opponents from the database community who have been skeptical in regards to the novelty of the MapReduce framework — previous to MapReduce, there was present analysis on parallel database systems investigating methods to allow parallel and distributed execution of analytical SQL queries. Nevertheless, MapReduce is usually built-in with a distributed file system with no necessities to impose a schema on the info, and it gives builders the liberty to implement customized information processing logic (ex: machine studying workloads, picture processing, community evaluation) in map() and cut back() which may be unimaginable to specific by means of SQL queries alone. These traits allow MapReduce to orchestrate parallel and distributed execution of basic function applications, as a substitute of being restricted to declarative SQL queries.

    All that being mentioned, the MapReduce framework is now not the go-to mannequin for many fashionable large-scale information processing duties.

    It has been criticized for its considerably restrictive nature of requiring computations to be translated into map and cut back phases, and requiring intermediate information to be materialized earlier than transmitting it between mappers and reducers. Materializing intermediate outcomes could lead to I/O bottlenecks, as all mappers should full their processing earlier than the cut back part begins. Moreover, complicated information processing duties could require many MapReduce jobs to be chained collectively and executed sequentially.

    Fashionable frameworks, equivalent to Apache Spark, have prolonged upon the unique MapReduce design by choosing a extra versatile DAG execution model. This DAG execution mannequin permits your complete sequence of transformations to be optimized, in order that dependencies between levels may be acknowledged and exploited to execute information transformations in reminiscence and pipeline intermediate outcomes, when applicable.

    Nevertheless, MapReduce has had a major affect on fashionable information processing frameworks (Apache Spark, Flink, Google Cloud Dataflow) as a consequence of basic distributed programming ideas that it launched, equivalent to locality-aware scheduling, fault tolerance by re-execution, and scalability.


    Wrap Up

    In case you made it this far, thanks for studying! There was a whole lot of content material right here, so let’s rapidly flesh out what we mentioned.

    • MapReduce is a programming mannequin used to orchestrate the parallel and distributed execution of applications throughout a big compute cluster of commodity {hardware}. Builders can write parallel applications utilizing the MapReduce framework by merely defining the mapper and reducer logic particular for his or her process.
    • Duties that encompass making use of transformations on impartial partitions of the info adopted by grouped aggregation are ultimate matches to be optimized by MapReduce.
    • We walked by means of methods to categorical a typical information engineering workload as a MapReduce process utilizing the MRJob library.
    • MapReduce because it was initially designed is now not used for contemporary massive information duties, however its core parts have performed a signifcant function within the design of contemporary distributed programming frameworks.

    If there are any vital particulars in regards to the MapReduce framework which might be lacking or deserve extra consideration right here, I’d love to listen to it within the feedback. Moreover, I did my greatest to incorporate all the nice sources that I learn whereas writing this text, and I extremely advocate checking them out should you’re focused on studying additional!

    The creator has created all photos on this article.


    Sources

    MapReduce Fundamentals:

    mrjob:

    Associated Background:

    MapReduce Limitations & Extensions:



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleBuilding Medical Multi-Agent Systems with Swarms Rust: A Comprehensive Tutorial | by Kye Gomez | Apr, 2025
    Next Article How Businesses Can Actually Make an Environmental Impact
    Team_AIBS News
    • Website

    Related Posts

    Artificial Intelligence

    Implementing IBCS rules in Power BI

    July 1, 2025
    Artificial Intelligence

    Become a Better Data Scientist with These Prompt Engineering Tips and Tricks

    July 1, 2025
    Artificial Intelligence

    Lessons Learned After 6.5 Years Of Machine Learning

    July 1, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025

    I Tried Buying a Car Through Amazon: Here Are the Pros, Cons

    December 10, 2024

    Amazon and eBay to pay ‘fair share’ for e-waste recycling

    December 10, 2024

    Artificial Intelligence Concerns & Predictions For 2025

    December 10, 2024

    Barbara Corcoran: Entrepreneurs Must ‘Embrace Change’

    December 10, 2024
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    Most Popular

    What PyTorch Really Means by a Leaf Tensor and Its Grad

    June 20, 2025

    Can Machines Dream? On the Creativity of Large Language Models | by Salvatore Raieli | Jan, 2025

    February 1, 2025

    Top 10 Python Scripts to Automate Data Science Tasks | by Timothy Kimutai | Jun, 2025

    June 22, 2025
    Our Picks

    Credit Risk Scoring for BNPL Customers at Bati Bank | by Sumeya sirmula | Jul, 2025

    July 1, 2025

    The New Career Crisis: AI Is Breaking the Entry-Level Path for Gen Z

    July 1, 2025

    Musk’s X appoints ‘king of virality’ in bid to boost growth

    July 1, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Business
    • Data Science
    • Machine Learning
    • Technology
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2024 Aibsnews.comAll Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.