Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-8768

Improve bulk load performance by moving key value construction from map phase to reduce phase.



    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.98.0, 0.95.2
    • mapreduce, Performance
    • None
    • Reviewed


      ImportTSV bulkloading approach uses MapReduce framework. Existing mapper and reducer classes used by ImportTSV are TsvImporterMapper.java and PutSortReducer.java. ImportTSV tool parses the tab(by default) seperated values from the input files and Mapper class generates the PUT objects for each row using the Key value pairs created from the parsed text. PutSortReducer then uses the partions based on the regions and sorts the Put objects for each region.

      Overheads we can see in the above approach:
      1) keyvalue construction for each parsed value in the line adding extra data like rowkey,columnfamily,qualifier which will increase around 5x extra data to be shuffled in reduce phase.
      We can calculate data size to shuffled as below

       Data to be shuffled = nl*nt*(rl+cfl+cql+vall+tsl+30)

      If we move keyvalue construction to reduce phase we datasize to be shuffle will be which is very less compared to above.

       Data to be shuffled = nl*nt*vall

      nl - Number of lines in the raw file
      nt - Number of tabs or columns including row key.
      rl - row length which will be different for each line.
      cfl - column family length which will be different for each family
      cql - qualifier length
      tsl - timestamp length.
      vall- each parsed value length.
      30 bytes for kv size,number of families etc.

      2) In mapper side we are creating put objects by adding all keyvalues constructed for each line and in reducer we will again collect keyvalues from put and sort them.
      Instead we can directly create and sort keyvalues in reducer.

      We can improve bulk load performance by moving the key value construction from mapper to reducer so that Mapper just sends the raw text for each row to the Reducer. Reducer then parses the records for rows and create and sort the key value pairs before writing to HFiles.
      The above suggestions will improve map phase performance by avoiding keyvalue construction and reduce phase performance by avoiding excess data to be shuffled.


        1. HBASE-8768_v4.patch
          21 kB
        2. HBASE-8768_v3.patch
          21 kB
        3. HBASE-8768_v2.patch
          21 kB
        4. HBase_Bulkload_Performance_Improvement.pdf
          659 kB



            rajesh23 rajeshbabu
            rajesh23 rajeshbabu
            0 Vote for this issue
            16 Start watching this issue