Skip to content

--inactive-conn-cleanup-timeout #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2619,6 +2619,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT]
[--tunnel-ssh-key-passphrase TUNNEL_SSH_KEY_PASSPHRASE]
[--tunnel-remote-port TUNNEL_REMOTE_PORT] [--threadless]
[--threaded] [--num-workers NUM_WORKERS] [--enable-events]
[--inactive-conn-cleanup-timeout INACTIVE_CONN_CLEANUP_TIMEOUT]
[--enable-proxy-protocol] [--enable-conn-pool] [--key-file KEY_FILE]
[--cert-file CERT_FILE] [--client-recvbuf-size CLIENT_RECVBUF_SIZE]
[--server-recvbuf-size SERVER_RECVBUF_SIZE]
Expand Down Expand Up @@ -2682,6 +2683,16 @@ options:
--enable-events Default: False. Enables core to dispatch lifecycle
events. Plugins can be used to subscribe for core
events.
--inactive-conn-cleanup-timeout INACTIVE_CONN_CLEANUP_TIMEOUT
Time after which inactive works must be cleaned up.
Increase this value if your backend services are slow
to response or when proxy.py is handling a high
volume. When running proxy.py on Google Cloud (GCP)
you may see 'backend_connection_closed_before_data_sen
t_to_client', with curl clients you may see 'Empty
reply from server' error when '--inactive-conn-
cleanup-timeout' value is low for your use-case.
Default 1 seconds
--enable-proxy-protocol
Default: False. If used, will enable proxy protocol.
Only version 1 is currently supported.
Expand Down
17 changes: 16 additions & 1 deletion proxy/core/work/threadless.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
cast,
)

from ...common.flag import flags as proxy_flags
from ...common.types import Readables, Writables, SelectableEvents
from ...common.logger import Logger
from ...common.constants import (
Expand All @@ -37,6 +38,20 @@
logger = logging.getLogger(__name__)


proxy_flags.add_argument(
'--inactive-conn-cleanup-timeout',
default=DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT,
help='Time after which inactive works must be cleaned up. '
+ 'Increase this value if your backend services are slow to response '
+ 'or when proxy.py is handling a high volume. When running proxy.py on Google Cloud (GCP) '
+ "you may see 'backend_connection_closed_before_data_sent_to_client', with curl clients "
+ "you may see 'Empty reply from server' error when '--inactive-conn-cleanup-timeout' "
+ 'value is low for your use-case. Default {0} seconds'.format(
DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT,
),
)


class Threadless(ABC, Generic[T]):
"""Work executor base class.

Expand Down Expand Up @@ -87,7 +102,7 @@ def __init__(
SelectableEvents,
] = {}
self.wait_timeout: float = DEFAULT_WAIT_FOR_TASKS_TIMEOUT
self.cleanup_inactive_timeout: float = DEFAULT_INACTIVE_CONN_CLEANUP_TIMEOUT
self.cleanup_inactive_timeout: float = self.flags.inactive_conn_cleanup_timeout
self._total: int = 0
# When put at the top, causes circular import error
# since integrated ssh tunnel was introduced.
Expand Down
Loading