Skip to content
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

[Serve] Allow multiple HTTP servers. #9523

Merged
merged 19 commits into from
Jul 24, 2020
Merged
Prev Previous commit
Next Next commit
Rename
  • Loading branch information
simon-mo committed Jul 23, 2020
commit 392f520192b10d61510e8a22fbeb2c1d7f2ac005
5 changes: 2 additions & 3 deletions ci/long_running_tests/workloads/serve_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def __init__(self, kill_period_s=1):

def _get_all_serve_actors(self):
master = serve.api._get_controller()
[router] = ray.get(master.get_router.remote())
[http_proxy] = ray.get(master.get_http_proxy.remote())
all_handles = [master, router, http_proxy]
routers = ray.get(master.get_router.remote())
all_handles = routers + [master]
worker_handle_dict = ray.get(master.get_all_worker_handles.remote())
for _, replica_dict in worker_handle_dict.items():
all_handles.extend(list(replica_dict.values()))
Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def get_handle(endpoint_name,
assert endpoint_name in ray.get(controller.get_all_endpoints.remote())

return RayServeHandle(
ray.get(controller.get_http_proxy.remote())[0],
ray.get(controller.get_router.remote())[0],
endpoint_name,
relative_slo_ms,
absolute_slo_ms,
Expand Down
4 changes: 2 additions & 2 deletions python/ray/serve/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _get_or_start_routers(self, host, port):
host, port, instance_name=self.instance_name)
self.routers.append(router)

def get_http_proxy(self):
def get_router(self):
"""Returns a handle to the HTTP proxy managed by this actor."""
return self.routers

Expand All @@ -188,7 +188,7 @@ async def broadcast_routers(
object_refs = [apply(router) for router in self.routers]
await asyncio.gather(*object_refs)

def get_http_proxy_config(self):
def get_router_config(self):
"""Called by the HTTP proxy on startup to fetch required state."""
return self.routes

Expand Down
2 changes: 1 addition & 1 deletion python/ray/serve/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def fetch_config_from_controller(self, instance_name=None):
assert ray.is_initialized()
controller = serve.api._get_controller()

self.route_table = await controller.get_http_proxy_config.remote()
self.route_table = await controller.get_router_config.remote()

# The exporter is required to return results for /-/metrics endpoint.
[self.metric_exporter] = await controller.get_metric_exporter.remote()
Expand Down
9 changes: 5 additions & 4 deletions python/ray/serve/tests/test_failure.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ def function():
assert response.text == "hello3"


def _kill_http_proxy():
[http_proxy] = ray.get(serve.api._get_controller().get_http_proxy.remote())
ray.kill(http_proxy, no_restart=False)
def _kill_routers():
routers = ray.get(serve.api._get_controller().get_router.remote())
for router in routers:
ray.kill(router, no_restart=False)


def test_http_proxy_failure(serve_instance):
Expand All @@ -96,7 +97,7 @@ def function():
response = request_with_retries("/proxy_failure", timeout=30)
assert response.text == "hello1"

_kill_http_proxy()
_kill_routers()

def function():
return "hello2"
Expand Down