Commit d33efd5
[Model Monitoring] Fix event loop blocking during model endpoint creation (ML-11826) (#9186)
## Summary
Fix event loop blocking during model endpoint creation by using
`run_in_threadpool` to wrap synchronous DB operations.
## Changes Made
- Wrap `run_function_with_new_db_session` call in `run_in_threadpool` in
`_create_model_endpoint_limited`
- Add `await` keyword for the async operation
- Add explanatory comment
## Why This Change
When deploying a serving function with many models (e.g., 5000), the
synchronous DB operations for creating model endpoints would block the
async event loop. This prevented the API server from handling other
requests and could cause timeouts.
Using `run_in_threadpool` moves the synchronous DB work to a thread
pool, keeping the event loop responsive while still processing the model
endpoint creation.
## Testing
- Ran `test_app_flow[True-True]` system test successfully
- Deployed serving function with 5000 models - completed in ~7 minutes
with API remaining responsive
## Reference
- Jira: ML-11826
Co-authored-by: Alex Toker <[email protected]>1 parent 0be1248 commit d33efd5
1 file changed
+5
-2
lines changedLines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1985 | 1985 | | |
1986 | 1986 | | |
1987 | 1987 | | |
1988 | | - | |
1989 | | - | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
1990 | 1993 | | |
1991 | 1994 | | |
1992 | 1995 | | |
| |||
0 commit comments