[ 
https://issues.apache.org/jira/browse/HDFS-11280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16867717#comment-16867717
 ] 

Sebastien Barnoud commented on HDFS-11280:
------------------------------------------

This patch doesn't work as the connection is a local variable.
{code:java}
$ strace -T -tt -f /usr/bin/hdfs dfs -Djavax.net.debug=all -put -f dummy.txt 
swebhdfs://<my cluster>:50470/user/seb/test_from_prod/$(hostname) 2>&1 | grep 
"sin_port=htons(50470)" 
[pid 62905] 14:51:34.917426 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16) = -1 EINPROGRESS 
(Operation now in progress) <0.000101>
[pid 62905] 14:51:35.107079 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 62905] 14:51:35.340149 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 62905] 14:51:35.411417 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 62905] 14:51:35.477833 connect(388, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 62905] 14:51:35.571895 connect(388, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16) = -1 EINPROGRESS 
(Operation now in progress) <0.000127>
[pid 62905] 14:51:35.719054 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 62905] 14:51:35.770048 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 63108] 14:51:35.821029 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[pid 63108] 14:51:35.895525 connect(386, {sa_family=AF_INET, 
sin_port=htons(50470), sin_addr=inet_addr("184.6.241.2")}, 16 <unfinished ...>
[bash-4.2.46][j:0|h:4914|?:0][2019-06-19 14:51:35][dtlprd05@nazare:~/test-hdfs]
${code}
As you you can see, 10 physical connect for a single put of one file of 10 
bytes ...

The same issue for HDFS.

> Allow WebHDFS to reuse HTTP connections to NN
> ---------------------------------------------
>
>                 Key: HDFS-11280
>                 URL: https://issues.apache.org/jira/browse/HDFS-11280
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs
>    Affects Versions: 2.7.3, 2.6.5, 3.0.0-alpha1
>            Reporter: Zheng Shao
>            Assignee: Zheng Shao
>            Priority: Major
>             Fix For: 2.8.0, 2.7.4, 3.0.0-alpha2
>
>         Attachments: HDFS-11280.for.2.7.and.below.patch, 
> HDFS-11280.for.2.8.and.beyond.2.patch, HDFS-11280.for.2.8.and.beyond.3.patch, 
> HDFS-11280.for.2.8.and.beyond.4.patch, HDFS-11280.for.2.8.and.beyond.5.patch, 
> HDFS-11280.for.2.8.and.beyond.patch
>
>
> WebHDFSClient calls "conn.disconnect()", which disconnects from the NameNode. 
>  When we use webhdfs as the source in distcp, this used up all ephemeral 
> ports on the client side since all closed connections continue to occupy the 
> port with TIME_WAIT status for some time.
> According to http://tinyurl.com/java7-http-keepalive, we should call 
> conn.getInputStream().close() instead to make sure the connection is kept 
> alive.  This will get rid of the ephemeral port problem.
> Manual steps used to verify the bug fix:
> 1. Build original hadoop jar.
> 2. Try out distcp from webhdfs as source, and "netstat -n | grep TIME_WAIT | 
> grep -c 50070" on the local machine shows a big number (100s).
> 3. Build hadoop jar with this diff.
> 4. Try out distcp from webhdfs as source, and "netstat -n | grep TIME_WAIT | 
> grep -c 50070" on the local machine shows 0.
> 5. The explanation:  distcp's client side does a lot of directory scanning, 
> which would create and close a lot of connections to the namenode HTTP port.
> Reference:
> 2.7 and below: 
> https://github.com/apache/hadoop/blob/branch-2.6/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java#L743
> 2.8 and above: 
> https://github.com/apache/hadoop/blob/branch-2.8/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java#L898



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to