Skip to content

Update celery forwarder to use greenlets instead of processes #689

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ line-length = 100

ignore = ["E501"]
exclude = ["gen", "alembic"]

[lint.per-file-ignores]
"model-engine/model_engine_server/inference/forwarding/celery_forwarder.py" = ["E402"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from gevent import monkey

monkey.patch_all()

import argparse
import json
from datetime import datetime, timedelta
Expand Down Expand Up @@ -177,12 +181,7 @@ def start_celery_service(
concurrency=concurrency,
loglevel="INFO",
optimization="fair",
# Don't use pool="solo" so we can send multiple concurrent requests over
# Historically, pool="solo" argument fixes the known issues of celery and some of the libraries.
# Particularly asyncio and torchvision transformers. This isn't relevant since celery-forwarder
# is quite lightweight
# TODO: we should probably use eventlet or gevent for the pool, since
# the forwarder is nearly the most extreme example of IO bound.
pool="gevent",
)
worker.start()

Expand Down
1 change: 1 addition & 0 deletions model-engine/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ddtrace==1.8.3
deprecation~=2.1
docker~=5.0
fastapi~=0.110.0
gevent~=24.11.1
gitdb2~=2.0
gunicorn~=20.0
httptools==0.5.0
Expand Down
14 changes: 12 additions & 2 deletions model-engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ frozenlist==1.3.3
# aiosignal
fsspec==2023.10.0
# via huggingface-hub
gevent==24.11.1
# via -r model-engine/requirements.in
gitdb==4.0.10
# via gitpython
gitdb2==2.0.6
Expand All @@ -175,8 +177,10 @@ gitpython==3.1.41
# via -r model-engine/requirements.in
google-auth==2.21.0
# via kubernetes
greenlet==2.0.2
# via sqlalchemy
greenlet==3.1.1
# via
# gevent
# sqlalchemy
gunicorn==20.1.0
# via -r model-engine/requirements.in
h11==0.14.0
Expand Down Expand Up @@ -569,10 +573,16 @@ yarl==1.9.2
# aiohttp
zipp==3.16.0
# via importlib-metadata
zope-event==5.0
# via gevent
zope-interface==7.2
# via gevent

# The following packages are considered to be unsafe in a requirements file:
setuptools==69.0.3
# via
# gunicorn
# kubernetes
# kubernetes-asyncio
# zope-event
# zope-interface