hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitry Potapov (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HTTPCORE-377) Allow to enable SO_LINGER option with zero timeout
Date Tue, 22 Apr 2014 13:14:16 GMT

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

Dmitry Potapov commented on HTTPCORE-377:
-----------------------------------------

Since HTTP delineates message bodies, HTTP clients doesn't require SO_LINGER with non-zero
timeout. When HTTP client closes connection, not only the request is completely sent to server,
but the response is completely read, there is no data in underlying socket anymore, so it
can be discarded with RST.

I'm using SO_LINGER with HttpClient because otherwise in case of problems on server all my
sockets will fall into TIME_WAIT states, and further processing will stop. With non-zero SO_LINGER
I'll spend too much time for expired connections closing. I've done some load-testing on simple
proxy with HttpClient with slow backend. With 1 second SO_LINGER maximum rps of successfully
requests was 250, with 0 second SO_LINGER maximum rps was 2500.

I'm using non-zero SO_LINGER on server side, because I want to get client some time to read
last response chunk from socket, but I wish to control the maximum socket lifetime, in case
of broken client.

> Allow to enable SO_LINGER option with zero timeout
> --------------------------------------------------
>
>                 Key: HTTPCORE-377
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-377
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore, HttpCore NIO
>    Affects Versions: 4.3.2
>            Reporter: Dmitry Potapov
>            Priority: Minor
>         Attachments: httpcore-enable-linger.patch
>
>
> According to http://docs.oracle.com/javase/8/docs/api/java/net/StandardSocketOptions.html#SO_LINGER
linger option is disabled by default. Currently if SocketConfig.soLinger is set to zero (default
value is -1), then Socket.setSoLinger(false, 0) will be called, so linger will be disabled,
which is undesirable. My suggestion is interpret zero soLinger value as Socket.setSoLinger(true,
0).
> I understand that this change will break backward compatibility of config interpretation,
but can we have this in 4.4?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message