[ 
https://issues.apache.org/jira/browse/HDFS-4253?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Isaacson updated HDFS-4253:
--------------------------------

    Attachment: hdfs4253-3.txt

bq. Instead of generating random numbers, put all datanodes in an array, 
shuffle it and use the index. Then, there is no collisions.

That seems like more code for little benefit, but OK.  Here's the incremental 
diff:
{code}
@@ -831,8 +831,14 @@ public void pseudoSortByDistance( Node reader, Node[] 
nodes ) {
     final Node rdr = reader;
     final HashMap<Node, Integer> shuffle = new HashMap<Node, 
Integer>(nodes.length);
 
+    // Fisher-Yates shuffle, 
http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
+    Node [] nodeshuffle = Arrays.copyOf(nodes, nodes.length);
+    for (int i = nodes.length - 1; i > 0; i--) {
+      int j = r.nextInt(i + 1);
+      swap(nodeshuffle, i, j);
+    }
     for (int i = 0; i < nodes.length; i++) {
-      shuffle.put(nodes[i], r.nextInt());
+      shuffle.put(nodeshuffle[i], i);
     }
{code}
                
> block replica reads get hot-spots due to NetworkTopology#pseudoSortByDistance
> -----------------------------------------------------------------------------
>
>                 Key: HDFS-4253
>                 URL: https://issues.apache.org/jira/browse/HDFS-4253
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 3.0.0, 2.0.2-alpha
>            Reporter: Andy Isaacson
>            Assignee: Andy Isaacson
>         Attachments: hdfs4253-1.txt, hdfs4253-2.txt, hdfs4253-3.txt, 
> hdfs4253.txt
>
>
> When many nodes (10) read from the same block simultaneously, we get 
> asymmetric distribution of read load.  This can result in slow block reads 
> when one replica is serving most of the readers and the other replicas are 
> idle.  The busy DN bottlenecks on its network link.
> This is especially visible with large block sizes and high replica counts (I 
> reproduced the problem with {{-Ddfs.block.size=4294967296}} and replication 
> 5), but the same behavior happens on a small scale with normal-sized blocks 
> and replication=3.
> The root of the problem is in {{NetworkTopology#pseudoSortByDistance}} which 
> explicitly does not try to spread traffic among replicas in a given rack -- 
> it only randomizes usage for off-rack replicas.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to