afterclick
728 × 90

Engineering

Mr. Jerb: how TellApart launched mrjob jobs on Hadoop streaming

A Python module, a test, and a shell script with the mapper’s path hard-coded into it. That was the price of adding one mapper to a Hadoop streaming job at TellApart before mrjob, according to a June 2011 post by engineer Ned Rockson. Each piece called the code a slightly different way, and a job with a reduce phase doubled the work. He admitted the overhead was almost enough to make him avoid writing jobs that needed a reducer at all.

The post was about how the company got that cost down, first with Yelp’s open-source mrjob library and then with a thin launcher of its own called MrJerb.

What mrjob fixed

Hadoop streaming lets any program act as a mapper or reducer, as long as it reads lines on standard input and writes key-value lines to standard output. That is flexible and miserable. Your Python code ends up parsing tab-separated text by hand, and the job’s shape lives in a shell command full of -mapper, -reducer and -file flags.

mrjob, released by Yelp in 2010, hid all of that. A job became a Python class whose mapper and reducer methods are generators that yield key-value pairs. The library handles serialisation between steps, packages your code, and runs the same class locally, on a Hadoop cluster or on Amazon Elastic MapReduce depending on a runner flag. The canonical example is still the clearest:

from mrjob.job import MRJob


class MRWordCount(MRJob):

    def mapper(self, _, line):
        for word in line.split():
            yield word.lower(), 1

    def reducer(self, word, counts):
        yield word, sum(counts)


if __name__ == '__main__':
    MRWordCount.run()

Run it with python word_count.py input.txt to test on a laptop, or add -r emr or -r hadoop to send the same code to a cluster. Rockson’s summary of the effect was that writing a streaming job became about as easy as writing a Python generator, which is accurate.

Why TellApart still wanted a launcher

mrjob solved most of the problem, but TellApart’s engineers preferred to start jobs with command-line parameters that matched the conventions of the rest of their codebase, rather than mrjob’s configuration style. MrJerb was the wrapper that made that work. With it, launching a job came down to writing a generator or two and calling the launcher.

The post listed the chores MrJerb took over:

  • Adding JAR files and custom partitioners to a job.
  • Setting the equivalent of mrjob’s --python-archive option, which was due in mrjob 0.2.7.
  • Setting the output protocol and job attributes such as the name and the number of reduce tasks.
  • Choosing cleanup options for temporary files.
  • Optionally deleting the output path before the job ran.

The last item sounds minor. It is not. Hadoop refuses to write to an existing output directory, and every engineer who ran batch jobs in that era has re-launched a failed job only to watch it die again in the first second for that reason.

Rockson also left a practical warning: use mrjob 0.2.2 or later, or expect to lose hair over hadoop_extra_args. MrJerb was published on GitHub next to the company’s other Hadoop utilities.

There is a pattern in TellApart’s open-source output from those years. The same itch (remove the glue code between a function and the thing that runs it) produced commandr, the decorator that turns a function into a command-line tool. MrJerb applied it to Hadoop.

Where mrjob fit in TellApart’s data stack

mrjob was one tool among several. For heavier pipelines the company leaned on Java and Cascading: the HBase log processing system described in early 2011 used Cascading with Thrift, and the later Tyra feature pipeline for training user models was written in Java on Cascading and run on Elastic MapReduce. Python streaming jobs suited the quick analyses and one-off reports, where development speed mattered more than raw throughput.

That split was common, and sensible. Hadoop streaming carries a real overhead per record, since every line crosses a process boundary as text. For a job that runs once to answer a question, nobody cares. For a pipeline that runs every day over billions of events, it adds up.

What replaced mrjob

Very little new work starts on mrjob today. Development slowed years ago, and the MapReduce model it wrapped has largely given way to engines that keep data in memory between steps.

For Python batch jobs in 2026, a team would reach for PySpark first, especially on a managed platform such as Databricks or Amazon EMR, which now runs Spark far more often than classic MapReduce. For data that fits on one large machine, Polars or DuckDB often finishes faster than any cluster job would have, with no cluster to run. Apache Beam covers teams that want the same code for batch and streaming. And Ray handles Python-heavy workloads that do not fit the dataframe model.

If you do inherit mrjob code, the port is usually mechanical: a mapper becomes a flatMap, a reducer becomes a reduceByKey or a grouped aggregation, and the generator style carries over almost unchanged. The hard part is never the code. It is finding every shell script, cron entry and launcher, MrJerb-style or homemade, that quietly depends on the old job’s command-line flags.

Questions readers ask

Why delete the output path before launching a Hadoop job?

Hadoop refuses to write to an output directory that already exists. If a job fails partway and leaves its output behind, launching it again makes it die in the first second for that reason. MrJerb could optionally remove the output path before the job ran, which spared engineers that repeated failure when re-running batch jobs. It was one of several chores the launcher took off their hands.

Which mrjob version should be used with hadoop_extra_args?

Ned Rockson's warning was to use mrjob 0.2.2 or later, or expect to lose hair over hadoop_extra_args. He also noted that the python-archive option was due in mrjob 0.2.7, and MrJerb set the equivalent for engineers in the meantime. MrJerb itself was published on GitHub next to TellApart's other Hadoop utilities.

How hard is it to port an mrjob job to PySpark?

Usually mechanical. A mapper becomes a flatMap, a reducer becomes a reduceByKey or a grouped aggregation, and the generator style carries over almost unchanged. The real effort goes into tracking down every shell script, cron entry and launcher that quietly depends on the old job's command-line flags. For data that fits on one large machine, Polars or DuckDB may finish faster than any cluster job.

Why did TellApart use Java and Cascading for some pipelines instead of Python streaming?

Hadoop streaming adds overhead to every record, because each line passes between processes as text. For a job that runs once to answer a question, that cost hardly matters, which is why Python streaming suited quick analyses and one-off reports. For a pipeline running daily over billions of events it adds up, so the heavier systems, such as the HBase log processing and the Tyra feature pipeline, used Java and Cascading.