All Products
Search
Document Center

E-MapReduce:HDFS optimization

Last Updated:Mar 26, 2026

Use the following recommendations to tune Hadoop Distributed File System (HDFS) in E-MapReduce (EMR) for better performance and cluster stability. Each section explains the root cause of a common issue and how to address it.

Control the number of small files

The HDFS NameNode keeps metadata for every file in memory. When a large number of small files accumulate, the NameNode hits a memory bottleneck even if total disk capacity is not exhausted.

Merge existing small files into fewer, larger files to reduce NameNode memory pressure.

Limit files per directory

Spark, YARN, and other services can continuously write files to the same HDFS directory. HDFS enforces a maximum number of files per directory, and exceeding the limit causes job failures.

Plan your data layout in advance — classify files by time period or business type so no single directory grows unbounded. Set dfs.namenode.fs-limits.max-directory-items to define the limit. A value of 1,000,000 works well for most workloads.

To add the parameter:

  1. In the EMR console, go to the HDFS service page and click the Configure tab.

  2. Click the hdfs-site tab.

  3. Click Add Configuration Item, add dfs.namenode.fs-limits.max-directory-items, and set the value.

  4. Click Save.

For detailed steps, see Manage configuration items.

Tolerate failed DataNode volumes

By default, if multiple data storage volumes are configured for a DataNode and one of the volumes fails, the DataNode stops providing services. By default, at least one available volume is configured.

Raising the threshold lets a DataNode continue operating as long as the number of failed volumes stays within the configured limit (dfs.datanode.failed.volumes.tolerated = 0 by default).

To change the threshold:

  1. In the EMR console, go to the HDFS service page and click the Configure tab.

  2. Search for dfs.datanode.failed.volumes.tolerated and update the value.

Parameter Default value Description
dfs.datanode.failed.volumes.tolerated 0 Maximum number of failed data volumes a DataNode tolerates before stopping services.
Note

If a DataNode has a failed disk and no other node can take over its workload, temporarily increase this value so the DataNode can keep serving data while you repair the disk.

Balance DataNode capacity

Adding DataNodes to an EMR cluster can leave data unevenly distributed across nodes, causing some DataNodes to become overloaded. Run the HDFS balancer to redistribute data.

Note

The balancer consumes network bandwidth on DataNodes. Run it during off-peak hours.

Run the balancer

  1. Log in to a node in your cluster.

  2. (Optional) Set the balancer's maximum bandwidth:

    hdfs dfsadmin -setBalancerBandwidth <bandwidth in bytes per second>

    Choose a value based on cluster load:

    Cluster state Recommended value Equivalent
    Heavy load 20971520 20 MB/s
    Normal 209715200 200 MB/s
    Idle 1073741824 1 GB/s
  3. Switch to the hdfs user and start the balancer:

    su hdfs
    /opt/apps/HDFS/hdfs-current/sbin/start-balancer.sh -threshold 10

    The -threshold 10 flag means the cluster is considered balanced when no DataNode's disk usage deviates from the cluster average by more than 10%.

  4. Monitor progress in the balancer log:

    tail -f /var/log/emr/hadoop-hdfs/hadoop-hdfs-balancer-master-1-1.c-xxx.log

    Replace hadoop-hdfs-balancer-master-1-1.c-xxx with the actual log file name on your cluster.

The balancer has finished when the log output contains Successfully.