TOOL WIKI · RUNTIME & DEPLOYMENT
Ray Serve
Builds and scales model-serving applications on Ray.
Jump to a section 10 sections
EXAMPLE USE CASE
Expose a lookup through a serving replica
A developer needs a concrete execution environment for a background task, browser operation or service, with a visible terminal result.
- Input
- A bound deployment and an order_id query parameter.
- Expected output
- A JSON status from the live replica.
- Success check: The bound deployment serves packed from its replica.
- Try a failure: A replica crash or missing endpoint must not be confused with a not_found business result.
Example scope: Actual Ray Serve HTTP baseline; the application is a fixture before adding a model.
Official reference · Ray Serve
Set the allowed runtime, network access, credentials, and maximum duration.
inputTo 02 · Ray ServeComposing and operating inference services for an agent backend. Measure queueing, concurrency, and resource use under realistic traffic.
processTo 03 · Worker environmentRun only the workload and dependencies required for the task.
Check permissions at each resource service and reconcile uncertain writes.
Inspect files, records, and task-level acceptance criteria.
outputTo 06 · LifecycleRetain required artifacts, release temporary compute, and expire task credentials.
Result or stopping point
Composing and operating inference services for an agent backend. Measure queueing, concurrency, and resource use under realistic traffic.
When to consider it
- Composing and operating inference services for an agent backend.
A design decision to make
- Measure queueing, concurrency, and resource use under realistic traffic.
Prerequisites and setup
- A Python version supported by the current Ray release, with Python 3.11 as a common compatible choice. The local runtime starts worker processes.
python3 -m venv .venv
source .venv/bin/activate
pip install "ray[serve]"Try a small integration
app.py
from ray import serve
from starlette.requests import Request
@serve.deployment(num_replicas=1)
class OrderLookup:
async def __call__(self, request: Request):
order_id = request.query_params.get("order_id","")
return {"order_id":order_id,"status":{"A104":"packed"}.get(order_id,"not_found")}
app = OrderLookup.bind()Run and check the result
serve run app:app
# In a second terminal:
curl --fail "http://127.0.0.1:8000/?order_id=A104"- The bound deployment serves packed from its replica.
- This local fixture tests service routing; model loading, batching and GPU allocation are separate deployment decisions.
Common failures
- A worker accepting a job does not establish completion. Inspect the task result, failure and retry history.
- Do not expose a development control plane or unauthenticated execution endpoint publicly.
Production decisions
- Use bounded CPU/memory/time, restricted filesystem mounts and network access, short-lived secrets and per-user isolation.
- Preserve run/operation identifiers, cancellation and terminal states. Retryable remote writes need provider idempotency or reconciliation.
- Protect the Ray control plane and dashboard. Benchmark batching, backpressure, cold starts and autoscaling before allocating a shared model cluster.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.