Configure and deploy Anyscale services
This page provides an overview of configuring and deploying Anyscale services.
Deploy or update an Anyscale service
You deploy or update an Anyscale service using the Anyscale CLI or SDK.
Define and provide a service config to deploy an Anyscale service, as in the following example syntax:
- CLI
- SDK
anyscale service deploy --config-file /path/to/service-config.yaml
import anyscale
from anyscale.service.models import ServiceConfig
service_config = ServiceConfig(
# Define your service configuration
)
anyscale.service.deploy(service_config)
You can optionally use flags to specify all options to deploy an Anyscale service using the CLI. This can be useful for quick iteration during development, but Anyscale recommends using service config files for production services.
What is an Anyscale service config?
An Anyscale service config is a superset of a Ray Serve config. You use service configs to define all aspects of your Anyscale service. See ServiceConfig
.
Anyscale recommends always configuring the following fields for your Anyscale services:
Field | Description |
---|---|
name | A unique name for your service. See Anyscale service name requirements. |
image_uri | The URI of the container image for your service. See What is a container image?. |
compute_config | The name of an existing compute config to use for your service.You can also provide options inline as part of your service config. See Compute configuration on Anyscale. |
cloud | The Anyscale cloud where your service deploys. Defaults to the default cloud for your Anyscale organization. |
project | The Anyscale project where your service deploys. Defaults to the default project for your Anyscale cloud. |
applications | A list of Ray Serve applications to run. You must specify at least one application. See Configure your Ray Serve applications. |
Use the following fields to configure additional settings for your Ray Serve applications. These fields are part of the Ray Serve config. See the Ray Serve config docs.
Field | Description |
---|---|
http_options | HTTP options for your cluster and application, including host and port proxy configurations and timeouts. |
grpc_options | Options to configure gRPC for your service. See Use gRPC with Anyscale services. |
logging_config | Options to configure custom logging for your Ray Serve applications. See Structured logging. |
tracing_config | Options to configure tracing for your service. See Tracing guide. |
There are many optional fields in the service config for using Ray runtime environments. These can be especially useful during development. See Runtime environments on Anyscale.
Configure your Ray Serve applications
The applications
configuration in your service config defines how Anyscale services interact with the Ray Serve applications packaged in your container image. It's possible to deploy multiple Ray Serve applications to a single Anyscale service. See Multi-application services.
Each application has one or more deployments, each of which is a Python class or function with the @serve.deployment()
decorator in your source code. You refer to deployments by name in your service config. By default, deployments use the name of the decorated Python class or function.
You can specify options for each of your deployments
in your service config or in your Ray code using the @serve.deployment()
decorator. Anyscale recommends using the service config to set deployment options for production services.
Options you set in the service config override options in your source code. This can be useful when updating services in production. See Update an Anyscale service.
Anyscale service name requirements
Anyscale service names have the following requirements:
- Names must contain only alphanumeric characters, underscores, and dashes.
- The maximum character count for a name is 57 characters.
- Anyscale service names must be unique within a project.
- Note that multiple services with the same name can coexist within an organization.
The name of your service appears in the URL you use to query the service. See Anyscale service endpoint URL.
When Anyscale deploys infrastructure for services in your cloud provider account, it uses your service name to name the resources and also adds the service name as a metadata tag.
Remove the bearer token
Anyscale doesn't recommend disabling bearer tokens for your service. You can change this setting while deploying a new version of the service.
You have the option to toggle the bearer token for individual services by providing an access configuration in the service config. By default, services deploy with a bearer token, but you can turn it off using the query_auth_token_enabled
configuration.
You can toggle the bearer token for a running service by rolling out a new version. It can take up to 5 minutes for the changes to be propagated, so exercise caution when toggling the bearer token for services in production.