How to find optimal number of mappers when running Sqoop import and export?

15,605

This is taken from Apache Sqoop Cookbook by O'Reilly Media, and seems to be the most logical answer.

The optimal number of mappers depends on many variables: you need to take into account your database type, the hardware that is used for your database server, and the impact to other requests that your database needs to serve. There is no optimal number of mappers that works for all scenarios. Instead, you’re encouraged to experiment to find the optimal degree of parallelism for your environment and use case. It’s a good idea to start with a small number of mappers, slowly ramping up, rather than to start with a large number of mappers, working your way down.

Share:
15,605
Bohdan
Author by

Bohdan

That's me. ;)

Updated on June 19, 2022

Comments

  • Bohdan
    Bohdan almost 2 years

    I'm using Sqoop version 1.4.2 and Oracle database.

    When running Sqoop command. For example like this:

    ./sqoop import                               \
        --fs <name node>                         \
        --jt <job tracker>                       \
        --connect <JDBC string>                  \
        --username <user> --password <password>  \
        --table <table> --split-by <cool column> \
        --target-dir <where>                     \
        --verbose --m 2
    

    We can specify --m - how many parallel tasks do we want Sqoop to run (also they might be accessing Database at same time). Same option is available for ./sqoop export <...>

    Is there some heuristic (probably based on size of data) which will help to guess what is optimal number of task to use?

    Thank you!

  • Engineiro
    Engineiro almost 11 years
    If you are going to downvote, please leave me constructive criticism so that I may improve my answer.
  • Bohdan
    Bohdan almost 11 years
    Thats answer to different question. I did not downvote it. But problem with sqoop is that it's hitting dabase by each mapper. So if I have 30 machines with lets sat 2 mapper rep each and I use -m 60 database will be very unhappy with it :)
  • Engineiro
    Engineiro almost 11 years
    You wouldn't set it to 60. You would set it to 2... since this setting would apply to each machine in your cluster. So each machine would be using two mappers for a total of 60 mappers deployed depending if the sqoop api takes this as a suggestion or hard setting.
  • Dave Morris
    Dave Morris about 9 years
    @Engineiro, are you sure that this setting applies to each data node in the cluster? We just tried an example on a 7 node cluster with mappers set to 15, but we ended up with 15 files, not 105 files (7 * 15).
  • Engineiro
    Engineiro about 9 years
    Nope got that completely wrong: sqoop.apache.org/docs/1.4.5/SqoopUserGuide.html "7.2.4. Controlling Parallelism" We don't control how many mappers each machine run just how many mappers we deploy total. Thanks for questioning @DaveMorris