[FIX] service.server: bump up socket timeout to 2s

Rev. 8245c1d1d8 introduced a timeout to
avoid lockup situations with wkhtmltopdf's requests on servers with low
numbers of free HTTP workers.

The initial timeout of 500ms was chosen based on average network
latency, but turned out to cause spurious disconnections on congested
networks combined with slow links.

Bumping up the timeout to 2s seems to be a better sweet spot, causing
less spurious disconnections while still recovering reasonably fast from
the wkhtmltopdf lockup situation.

See also these discussions:
 - 8245c1d1d8 (commitcomment-22904347)
 - PR #12356
 - Issue #2114

Closes #17998
This commit is contained in:
Jairo Llopis 2017-07-04 11:18:48 +02:00 committed by Olivier Dony
parent a38544f63f
commit ecc093033d
No known key found for this signature in database
GPG Key ID: CD556E25E8A6D0D4
1 changed files with 1 additions and 1 deletions

View File

@ -777,7 +777,7 @@ class WorkerHTTP(Worker):
""" HTTP Request workers """
def process_request(self, client, addr):
client.setblocking(1)
client.settimeout(0.5)
client.settimeout(2)
client.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
# Prevent fd inherientence close_on_exec
flags = fcntl.fcntl(client, fcntl.F_GETFD) | fcntl.FD_CLOEXEC