Skip to content

Commit 3af19da

Browse files
committed
dv-0 disabled keep alive connections
1 parent 85e24e8 commit 3af19da

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/service-library/src/servicelib/fastapi/client_session.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
from fastapi import FastAPI
33

44

5-
def setup_client_session(app: FastAPI) -> None:
5+
def setup_client_session(app: FastAPI, *, max_keepalive_connections: int = 20) -> None:
66
async def on_startup() -> None:
7-
session = httpx.AsyncClient(transport=httpx.AsyncHTTPTransport(http2=True))
7+
session = httpx.AsyncClient(
8+
transport=httpx.AsyncHTTPTransport(http2=True),
9+
limits=httpx.Limits(max_keepalive_connections=max_keepalive_connections),
10+
)
811
app.state.aiohttp_client_session = session
912

1013
async def on_shutdown() -> None:

services/director/src/simcore_service_director/core/application.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ def create_app(settings: ApplicationSettings) -> FastAPI:
5353
if app.state.settings.DIRECTOR_TRACING:
5454
initialize_tracing(app, app.state.settings.DIRECTOR_TRACING, APP_NAME)
5555

56-
# replace by httpx client
57-
setup_client_session(app)
56+
setup_client_session(
57+
app,
58+
max_keepalive_connections=settings.DIRECTOR_REGISTRY_CLIENT_MAX_KEEPALIVE_CONNECTIONS,
59+
)
5860
setup_registry(app)
5961

6062
setup_instrumentation(app)

services/director/src/simcore_service_director/core/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
112112
),
113113
)
114114

115+
DIRECTOR_REGISTRY_CLIENT_MAX_KEEPALIVE_CONNECTIONS: PositiveInt = 0
115116
DIRECTOR_REGISTRY_CLIENT_MAX_CONCURRENT_CALLS: PositiveInt = 20
116117
DIRECTOR_REGISTRY_CLIENT_MAX_NUMBER_OF_RETRIEVED_OBJECTS: PositiveInt = 30
117118

0 commit comments

Comments
 (0)