Revert "[Serve] Set controller and HTTP proxy num_cpus=0 by default (#15000)" (#15091)

This reverts commit 39aa01fc2c.
This commit is contained in:
architkulkarni 2021-04-02 13:01:57 -07:00 committed by GitHub
parent ecb94b3fe9
commit d8f8583e80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 6 additions and 39 deletions

View file

@ -651,7 +651,6 @@ def start(
http_port: int = DEFAULT_HTTP_PORT,
http_middlewares: List[Any] = [],
http_options: Optional[Union[dict, HTTPOptions]] = None,
dedicated_cpu: bool = False,
) -> Client:
"""Initialize a serve instance.
@ -676,7 +675,7 @@ def start(
this to "0.0.0.0".
- port(int): Port for HTTP server. Defaults to 8000.
- middlewares(list): A list of Starlette middlewares that will be
applied to the HTTP servers in the cluster. Defaults to [].
applied to the HTTP servers in the cluster.
- location(str, serve.config.DeploymentMode): The deployment
location of HTTP servers:
@ -685,10 +684,6 @@ def start(
on. This is the default.
- "EveryNode": start one HTTP server per node.
- "NoServer" or None: disable HTTP server.
- num_cpus (int): The number of CPU cores to reserve for each
internal Serve HTTP proxy actor. Defaults to 0.
dedicated_cpu (bool): Whether to reserve a CPU core for the internal
Serve controller actor. Defaults to False.
"""
if ((http_host != DEFAULT_HTTP_HOST) or (http_port != DEFAULT_HTTP_PORT)
or (len(http_middlewares) != 0)):
@ -733,7 +728,6 @@ def start(
host=http_host, port=http_port, middlewares=http_middlewares)
controller = ServeController.options(
num_cpus=(1 if dedicated_cpu else 0),
name=controller_name,
lifetime="detached" if detached else None,
max_restarts=-1,

View file

@ -244,7 +244,6 @@ class HTTPOptions(pydantic.BaseModel):
port: int = DEFAULT_HTTP_PORT
middlewares: List[Any] = []
location: Optional[DeploymentMode] = DeploymentMode.HeadOnly
num_cpus: int = 0
@validator("location", always=True)
def location_backfill_no_server(cls, v, values):

View file

@ -38,7 +38,7 @@ CHECKPOINT_KEY = "serve-controller-checkpoint"
CONTROL_LOOP_PERIOD_S = 0.1
@ray.remote(num_cpus=0)
@ray.remote
class ServeController:
"""Responsible for managing the state of the serving system.

View file

@ -2,7 +2,7 @@ import ray
from ray import serve
import requests
ray.init()
ray.init(num_cpus=4)
serve.start()

View file

@ -2,7 +2,7 @@ import ray
from ray import serve
import requests
ray.init()
ray.init(num_cpus=4)
serve.start()

View file

@ -164,7 +164,7 @@ class HTTPProxy:
await self.router(scope, receive, send)
@ray.remote(num_cpus=0)
@ray.remote
class HTTPProxyActor:
def __init__(self,
host: str,

View file

@ -69,7 +69,6 @@ class HTTPState:
name, node_id, self._config.host,
self._config.port))
proxy = HTTPProxyActor.options(
num_cpus=self._config.num_cpus,
name=name,
lifetime="detached" if self._detached else None,
max_concurrency=ASYNC_CONCURRENCY,

View file

@ -15,7 +15,6 @@ from ray.serve.constants import SERVE_PROXY_NAME
from ray.serve.exceptions import RayServeException
from ray.serve.utils import (block_until_http_ready, get_all_node_ids,
format_actor_name)
from ray.serve.config import HTTPOptions
from ray.test_utils import wait_for_condition
from ray._private.services import new_port
@ -122,30 +121,6 @@ def test_connect(detached, ray_shutdown):
assert "backend-ception" in serve.list_backends().keys()
@pytest.mark.skipif(sys.platform == "win32", reason="Failing on Windows")
@pytest.mark.parametrize("controller_cpu", [True, False])
@pytest.mark.parametrize("num_proxy_cpus", [0, 1, 2])
def test_dedicated_cpu(controller_cpu, num_proxy_cpus, ray_cluster):
cluster = ray_cluster
num_cluster_cpus = 8
head_node = cluster.add_node(num_cpus=num_cluster_cpus)
ray.init(head_node.address)
wait_for_condition(
lambda: ray.cluster_resources().get("CPU") == num_cluster_cpus)
num_cpus_used = int(controller_cpu) + num_proxy_cpus
serve.start(
dedicated_cpu=controller_cpu,
http_options=HTTPOptions(num_cpus=num_proxy_cpus))
available_cpus = num_cluster_cpus - num_cpus_used
wait_for_condition(
lambda: (ray.available_resources().get("CPU") == available_cpus))
serve.shutdown()
ray.shutdown()
@pytest.mark.skipif(
not hasattr(socket, "SO_REUSEPORT"),
reason=("Port sharing only works on newer verion of Linux. "
@ -329,7 +304,7 @@ def test_http_head_only(ray_cluster):
r["CPU"]
for r in ray.state.state._available_resources_per_node().values()
}
assert cpu_per_nodes == {4, 4}
assert cpu_per_nodes == {2, 4}
if __name__ == "__main__":