Discussion:
[Freeipa-devel] [freeipa PR#624][opened] Use connection keep-alive
tiran
2017-03-20 07:49:28 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Author: tiran
Title: #624: Use connection keep-alive
Action: opened

PR body:
"""
Do not forcefully close the connection after every request. This enables
HTTP connection keep-alive, also known as persistent TCP and TLS/SSL
connection. Keep-alive speed up consecutive HTTP requests by 15% (for
local, low-latency network connections to a fast server) to multiple
times (high latency connections or remote peers).

pache has a default keep alive timeout of 5 seconds. That's too low for
interactive commands, e.g. password prompts. 30 seconds sounds like a
good compromise.

https://pagure.io/freeipa/issue/6641
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/624/head:pr624
git checkout pr624
tomaskrizek
2017-03-20 11:33:27 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

tomaskrizek commented:
"""
I examined this in wireshark. Without this patch, `ipa vault-add` would establish 7 TCP connections to apache, while it establishes only 3 with this patch. I wasn't able to track down where are the 2 rogue connections opened and why. The situation is similar for other commands.

The question is whether this improvement is good enough or whether we want to optimize the RPC to actually use just a single connection.

Also, please follow the development process next time and assign yourself to the ticket when you start working on it, so other don't have to invest time into solving the same issue.
"""

See the full comment at https://github.com/freeipa/freeipa/pull/624#issuecomment-287735158
tomaskrizek
2017-03-20 15:37:24 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

tomaskrizek commented:
"""
The extra connections seem to come from the internals of `httplib` library. If the hostname resolves to both IPv4 and IPv6 address, one connection is established to IPv4 and two to IPv6. I wasn't able to find the reason for this, but it doesn't seem to be related to our code.

```
connect(4, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("10.0.0.1")}, 16) = 0
connect(4, {sa_family=AF_INET6, sin6_port=htons(443), inet_pton(AF_INET6, "dead:beef::cafe", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = 0
connect(4, {sa_family=AF_INET6, sin6_port=htons(443), inet_pton(AF_INET6, "dead:beef::cafe", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = 0
```
"""

See the full comment at https://github.com/freeipa/freeipa/pull/624#issuecomment-287798248
tomaskrizek
2017-03-20 15:42:33 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

Label: +ack
tiran
2017-03-20 15:47:13 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

tiran commented:
"""
This behavior could be caused by https://github.com/python/cpython/blob/master/Lib/socket.py#L688 . What's ```socket.getaddrinfo(host, 443, 0, socket.SOCK_STREAM)``` for your host?
"""

See the full comment at https://github.com/freeipa/freeipa/pull/624#issuecomment-287801541
tomaskrizek
2017-03-20 16:38:28 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

tomaskrizek commented:
"""
@tiran I checked that code as well, `getaddrinfo` returns both IPv6 and IPv4. That could explain two connections, but I'm not sure where the third one comes from.
"""

See the full comment at https://github.com/freeipa/freeipa/pull/624#issuecomment-287818799
tomaskrizek
2017-03-20 18:25:58 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

Label: +pushed
tomaskrizek
2017-03-20 18:26:02 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Title: #624: Use connection keep-alive

tomaskrizek commented:
"""
master:

* 7beb6d1cad7e2200208cb14be6c823a89abf0dc3 Use connection keep-alive
* b2bdd2e1a912573ae4a3e8e5f40831a800d972f7 Add debug logging for keep-alive
* 7f567286f6b89f3e981af02913e833d3e8ed5064 Increase Apache HTTPD's default keep alive timeout
ipa-4-5:

* 25cf4a2e76ff976fe15029f9da7e4e3555f203d4 Use connection keep-alive
* f78439439c3c2ef6491fd5275de9d40b4b40a9b7 Add debug logging for keep-alive
* 4b426fbfa2dc83f1f43abbc2b9396bd9f1b07f74 Increase Apache HTTPD's default keep alive timeout
"""

See the full comment at https://github.com/freeipa/freeipa/pull/624#issuecomment-287853534
tomaskrizek
2017-03-20 18:26:05 UTC
Permalink
URL: https://github.com/freeipa/freeipa/pull/624
Author: tiran
Title: #624: Use connection keep-alive
Action: closed

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/624/head:pr624
git checkout pr624

Loading...