Skip to content

Commit

Permalink
[API] Increase http connection pools maxsize to be equal to number of…
Browse files Browse the repository at this point in the history
… workers (#1811)
  • Loading branch information
Hedingber committed Mar 13, 2022
1 parent 41157dc commit 3129e5e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions mlrun/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ async def startup_event():
version=mlrun.utils.version.Version().get(),
)
loop = asyncio.get_running_loop()
max_workers = config.httpdb.max_workers or 64
loop.set_default_executor(
concurrent.futures.ThreadPoolExecutor(max_workers=max_workers)
concurrent.futures.ThreadPoolExecutor(
max_workers=int(config.httpdb.max_workers)
)
)

initialize_logs_dir()
Expand Down
3 changes: 2 additions & 1 deletion mlrun/api/utils/auth/providers/opa.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Provider(
def __init__(self) -> None:
super().__init__()
http_adapter = requests.adapters.HTTPAdapter(
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1)
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1),
pool_maxsize=int(mlrun.mlconf.httpdb.max_workers),
)
self._session = requests.Session()
self._session.mount("http://", http_adapter)
Expand Down
3 changes: 2 additions & 1 deletion mlrun/api/utils/clients/iguazio.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Client(
def __init__(self) -> None:
super().__init__()
http_adapter = requests.adapters.HTTPAdapter(
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1)
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1),
pool_maxsize=int(mlrun.mlconf.httpdb.max_workers),
)
self._session = requests.Session()
self._session.mount("http://", http_adapter)
Expand Down
3 changes: 2 additions & 1 deletion mlrun/api/utils/clients/nuclio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Client(
def __init__(self) -> None:
super().__init__()
http_adapter = requests.adapters.HTTPAdapter(
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1)
max_retries=urllib3.util.retry.Retry(total=3, backoff_factor=1),
pool_maxsize=int(mlrun.mlconf.httpdb.max_workers),
)
self._session = requests.Session()
self._session.mount("http://", http_adapter)
Expand Down
2 changes: 1 addition & 1 deletion mlrun/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"data_volume": "",
"real_path": "",
"db_type": "sqldb",
"max_workers": "",
"max_workers": 64,
# See mlrun.api.schemas.APIStates for options
"state": "online",
"db": {
Expand Down

0 comments on commit 3129e5e

Please sign in to comment.