In Hadoop, if we have not set number of reducers, then how many number of reducers will be created?
Like number of mappers is dependent on (total data size)/(input split size), E.g. if data size is 1 TB and input split size is 100 MB. Then number of mappers will be (1000*1000)/100 = 10000(Ten thousand).
The number of reducer is dependent on which factors ? How many reducers are created for a job?
By default the no of reducers is set to 1.
You can change it by adding a parameter
mapred.reduce.tasks
in the command line or in the Driver code or in the conf file that you pass.e.g: Command Line Argument:
bin/hadoop jar ... -Dmapred.reduce.tasks=<num reduce tasks>
or, in Driver code as:conf.setNumReduceTasks(int num);
Recommended read: https://wiki.apache.org/hadoop/HowManyMapsAndReduces
How Many Reduces? ( From official documentation)
The right number of reduces seems to be 0.95 or 1.75 multiplied by (no. of nodes) * (no. of maximum containers per node).
Increasing the number of reduces increases the framework overhead, but increases load balancing and lowers the cost of failures.
The scaling factors above are slightly less than whole numbers to reserve a few reduce slots in the framework for speculative-tasks and failed tasks.
This article covers about Mapper count too.
How Many Maps?
The right level of parallelism for maps seems to be around 10-100 maps per-node, although it has been set up to 300 maps for very cpu-light map tasks. Task setup takes a while, so it is best if the maps take at least a minute to execute.
Thus, if you expect 10TB of input data and have a blocksize of 128MB, you’ll end up with 82,000 maps, unless
Configuration.set(MRJobConfig.NUM_MAPS, int)
(which only provides a hint to the framework) is used to set it even higher.If you want to change the default value of 1 for number of reducers, you can set below property (From hadoop 2.x version) as a command line parameter
mapreduce.job.reduces
OR
you can set programmatically with
Have a look at one more related SE question: What is Ideal number of reducers on Hadoop?