ray.serve.start#

ray.serve.start(detached: bool = False, http_options: Optional[Union[dict, ray.serve.config.HTTPOptions]] = None, dedicated_cpu: bool = False, **kwargs) ray.serve._private.client.ServeControllerClient[source]#

Initialize a serve instance.

By default, the instance will be scoped to the lifetime of the returned Client object (or when the script exits). If detached is set to True, the instance will instead persist until serve.shutdown() is called. This is only relevant if connecting to a long-running Ray cluster (e.g., with ray.init(address=”auto”) or ray.init(“ray://<remote_addr>”)).

Parameters
  • detached – Whether not the instance should be detached from this script. If set, the instance will live on the Ray cluster until it is explicitly stopped with serve.shutdown().

  • http_options (Optional[Dict, serve.HTTPOptions]) –

    Configuration options for HTTP proxy. You can pass in a dictionary or HTTPOptions object with fields:

    • host: Host for HTTP servers to listen on. Defaults to “127.0.0.1”. To expose Serve publicly, you probably want to set this to “0.0.0.0”.

    • port: Port for HTTP server. Defaults to 8000.

    • root_path: Root path to mount the serve application (for example, “/serve”). All deployment routes will be prefixed with this path. Defaults to “”.

    • middlewares: A list of Starlette middlewares that will be applied to the HTTP servers in the cluster. Defaults to [].

    • location(str, serve.config.DeploymentMode): The deployment location of HTTP servers:

      • ”HeadOnly”: start one HTTP server on the head node. Serve assumes the head node is the node you executed serve.start on. This is the default.

      • ”EveryNode”: start one HTTP server per node.

      • ”NoServer” or None: disable HTTP server.

    • num_cpus: The number of CPU cores to reserve for each internal Serve HTTP proxy actor. Defaults to 0.

  • dedicated_cpu – Whether to reserve a CPU core for the internal Serve controller actor. Defaults to False.

Warning

DEPRECATED: This API is deprecated and may be removed in future Ray releases. See https://docs.ray.io/en/latest/serve/index.html for more information.