Repository navigation
[serve] Add gRPC support to haproxy - #63735
Conversation
support for haproxy grpc known limitations: * streaming (to be implemented) * metrics (to be implemented) * healthz response is changed such that the response object is None. The message is in the grpc call details instead of the response now (because of haproxy limitations). The status code is unchanged (still `OK` on healthy and `UNAVAILABLE` otherwise). * ListApplications request is forwarded to the serve proxy, so it does not work if serve proxy is down. --------- Signed-off-by: akyang-anyscale <[email protected]>
Make haproxy http2 tuning parameters adjustable via env var --------- Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces gRPC support for HAProxy in Ray Serve, adding HTTP/2 tuning flags, a gRPC frontend, and health check configurations. Feedback on the changes highlights three key improvements: adding the missing check parameter to gRPC backend servers to enable active health checking, handling empty backend scenarios in the gRPC healthz template to avoid confusing NOT_FOUND errors, and initializing self._grpc_fallback_target in __init__ to prevent potential AttributeErrors.
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6f53f98. Configure here.
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
Signed-off-by: akyang-anyscale <[email protected]>
## Why HAProxy proxies gRPC end to end over HTTP/2. The gRPC frontend `bind` and the backend `server` lines both carry `proto h2`, so HAProxy decodes and forwards HTTP/2 streams, including client-streaming and bidirectional streaming, without any extra handling. gRPC-over-HAProxy support landed in #63735, and the streaming cases were skipped at that time as a scope cut rather than because of a real limitation. ## What changed 1. Remove the `skipif(RAY_SERVE_ENABLE_HA_PROXY, reason="HAProxy does not support streaming.")` markers from the 13 gRPC streaming tests in `test_grpc.py`. 2. Run the `Streaming` method assertion unconditionally in `test_serving_grpc_requests` (`test_grpc.py`) and `test_serving_request_through_grpc_proxy` (`test_cli_4.py`). Each previously gated that assertion behind an inline conditional (`if not RAY_SERVE_ENABLE_HA_PROXY` and `if not RAY_SERVE_ENABLE_DIRECT_INGRESS`). HAProxy forces `RAY_SERVE_ENABLE_DIRECT_INGRESS` on (`constants.py`), so both conditions were false under HAProxy and the assertion never ran there. Also drops the now-unused `RAY_SERVE_ENABLE_HA_PROXY` import in `test_grpc.py`. The `serve: HAProxy tests` CI step runs the full serve suite under `RAY_SERVE_ENABLE_HA_PROXY=1`, so these all execute there now instead of being skipped. ## Testing Ran under the bundled HAProxy 2.8.25 with `RAY_SERVE_ENABLE_HA_PROXY=1 RAY_SERVE_ENABLE_DIRECT_INGRESS=0`: ``` python -m pytest python/ray/serve/tests/test_grpc.py -k streaming # 20 passed, 23 deselected python -m pytest \ python/ray/serve/tests/test_grpc.py::test_serving_grpc_requests \ python/ray/serve/tests/test_cli_4.py::test_serving_request_through_grpc_proxy # 2 passed ``` Streaming coverage now exercised under HAProxy: client and bidirectional streaming, the grpc-context variants, timeout, cancellation, backpressure, mid-stream client errors, and the server-streaming `Streaming` method in the gRPC and CLI end-to-end tests. ## Not a duplicate No open PR or issue targets gRPC streaming under HAProxy (checked `gh pr list` and `gh issue list` on ray-project/ray). --------- Signed-off-by: Seiji Eicher <[email protected]>
## Why HAProxy proxies gRPC end to end over HTTP/2. The gRPC frontend `bind` and the backend `server` lines both carry `proto h2`, so HAProxy decodes and forwards HTTP/2 streams, including client-streaming and bidirectional streaming, without any extra handling. gRPC-over-HAProxy support landed in ray-project#63735, and the streaming cases were skipped at that time as a scope cut rather than because of a real limitation. ## What changed 1. Remove the `skipif(RAY_SERVE_ENABLE_HA_PROXY, reason="HAProxy does not support streaming.")` markers from the 13 gRPC streaming tests in `test_grpc.py`. 2. Run the `Streaming` method assertion unconditionally in `test_serving_grpc_requests` (`test_grpc.py`) and `test_serving_request_through_grpc_proxy` (`test_cli_4.py`). Each previously gated that assertion behind an inline conditional (`if not RAY_SERVE_ENABLE_HA_PROXY` and `if not RAY_SERVE_ENABLE_DIRECT_INGRESS`). HAProxy forces `RAY_SERVE_ENABLE_DIRECT_INGRESS` on (`constants.py`), so both conditions were false under HAProxy and the assertion never ran there. Also drops the now-unused `RAY_SERVE_ENABLE_HA_PROXY` import in `test_grpc.py`. The `serve: HAProxy tests` CI step runs the full serve suite under `RAY_SERVE_ENABLE_HA_PROXY=1`, so these all execute there now instead of being skipped. ## Testing Ran under the bundled HAProxy 2.8.25 with `RAY_SERVE_ENABLE_HA_PROXY=1 RAY_SERVE_ENABLE_DIRECT_INGRESS=0`: ``` python -m pytest python/ray/serve/tests/test_grpc.py -k streaming # 20 passed, 23 deselected python -m pytest \ python/ray/serve/tests/test_grpc.py::test_serving_grpc_requests \ python/ray/serve/tests/test_cli_4.py::test_serving_request_through_grpc_proxy # 2 passed ``` Streaming coverage now exercised under HAProxy: client and bidirectional streaming, the grpc-context variants, timeout, cancellation, backpressure, mid-stream client errors, and the server-streaming `Streaming` method in the gRPC and CLI end-to-end tests. ## Not a duplicate No open PR or issue targets gRPC streaming under HAProxy (checked `gh pr list` and `gh issue list` on ray-project/ray). --------- Signed-off-by: Seiji Eicher <[email protected]>
Signed-off-by: 400Ping <[email protected]>
## Why HAProxy proxies gRPC end to end over HTTP/2. The gRPC frontend `bind` and the backend `server` lines both carry `proto h2`, so HAProxy decodes and forwards HTTP/2 streams, including client-streaming and bidirectional streaming, without any extra handling. gRPC-over-HAProxy support landed in ray-project#63735, and the streaming cases were skipped at that time as a scope cut rather than because of a real limitation. ## What changed 1. Remove the `skipif(RAY_SERVE_ENABLE_HA_PROXY, reason="HAProxy does not support streaming.")` markers from the 13 gRPC streaming tests in `test_grpc.py`. 2. Run the `Streaming` method assertion unconditionally in `test_serving_grpc_requests` (`test_grpc.py`) and `test_serving_request_through_grpc_proxy` (`test_cli_4.py`). Each previously gated that assertion behind an inline conditional (`if not RAY_SERVE_ENABLE_HA_PROXY` and `if not RAY_SERVE_ENABLE_DIRECT_INGRESS`). HAProxy forces `RAY_SERVE_ENABLE_DIRECT_INGRESS` on (`constants.py`), so both conditions were false under HAProxy and the assertion never ran there. Also drops the now-unused `RAY_SERVE_ENABLE_HA_PROXY` import in `test_grpc.py`. The `serve: HAProxy tests` CI step runs the full serve suite under `RAY_SERVE_ENABLE_HA_PROXY=1`, so these all execute there now instead of being skipped. ## Testing Ran under the bundled HAProxy 2.8.25 with `RAY_SERVE_ENABLE_HA_PROXY=1 RAY_SERVE_ENABLE_DIRECT_INGRESS=0`: ``` python -m pytest python/ray/serve/tests/test_grpc.py -k streaming # 20 passed, 23 deselected python -m pytest \ python/ray/serve/tests/test_grpc.py::test_serving_grpc_requests \ python/ray/serve/tests/test_cli_4.py::test_serving_request_through_grpc_proxy # 2 passed ``` Streaming coverage now exercised under HAProxy: client and bidirectional streaming, the grpc-context variants, timeout, cancellation, backpressure, mid-stream client errors, and the server-streaming `Streaming` method in the gRPC and CLI end-to-end tests. ## Not a duplicate No open PR or issue targets gRPC streaming under HAProxy (checked `gh pr list` and `gh issue list` on ray-project/ray). --------- Signed-off-by: Seiji Eicher <[email protected]> Signed-off-by: 400Ping <[email protected]>
## Why HAProxy proxies gRPC end to end over HTTP/2. The gRPC frontend `bind` and the backend `server` lines both carry `proto h2`, so HAProxy decodes and forwards HTTP/2 streams, including client-streaming and bidirectional streaming, without any extra handling. gRPC-over-HAProxy support landed in ray-project#63735, and the streaming cases were skipped at that time as a scope cut rather than because of a real limitation. ## What changed 1. Remove the `skipif(RAY_SERVE_ENABLE_HA_PROXY, reason="HAProxy does not support streaming.")` markers from the 13 gRPC streaming tests in `test_grpc.py`. 2. Run the `Streaming` method assertion unconditionally in `test_serving_grpc_requests` (`test_grpc.py`) and `test_serving_request_through_grpc_proxy` (`test_cli_4.py`). Each previously gated that assertion behind an inline conditional (`if not RAY_SERVE_ENABLE_HA_PROXY` and `if not RAY_SERVE_ENABLE_DIRECT_INGRESS`). HAProxy forces `RAY_SERVE_ENABLE_DIRECT_INGRESS` on (`constants.py`), so both conditions were false under HAProxy and the assertion never ran there. Also drops the now-unused `RAY_SERVE_ENABLE_HA_PROXY` import in `test_grpc.py`. The `serve: HAProxy tests` CI step runs the full serve suite under `RAY_SERVE_ENABLE_HA_PROXY=1`, so these all execute there now instead of being skipped. ## Testing Ran under the bundled HAProxy 2.8.25 with `RAY_SERVE_ENABLE_HA_PROXY=1 RAY_SERVE_ENABLE_DIRECT_INGRESS=0`: ``` python -m pytest python/ray/serve/tests/test_grpc.py -k streaming # 20 passed, 23 deselected python -m pytest \ python/ray/serve/tests/test_grpc.py::test_serving_grpc_requests \ python/ray/serve/tests/test_cli_4.py::test_serving_request_through_grpc_proxy # 2 passed ``` Streaming coverage now exercised under HAProxy: client and bidirectional streaming, the grpc-context variants, timeout, cancellation, backpressure, mid-stream client errors, and the server-streaming `Streaming` method in the gRPC and CLI end-to-end tests. ## Not a duplicate No open PR or issue targets gRPC streaming under HAProxy (checked `gh pr list` and `gh issue list` on ray-project/ray). --------- Signed-off-by: Seiji Eicher <[email protected]>
…ptimized variant HAProxy now proxies gRPC (ray-project#63735), so the aws.haproxy variant of pytest_serve_throughput_optimized_microbenchmarks no longer needs to skip --run-grpc. Drop its script override so it inherits --run-all. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: akyang-anyscale <[email protected]>
…ptimized variant (#66771) ## Description The `aws.haproxy` variant of `pytest_serve_throughput_optimized_microbenchmarks` overrode the script to skip `--run-grpc`, because HAProxy did not proxy gRPC when the variant was added (#63386). HAProxy has proxied gRPC since #63735, so this PR removes the override. The variant now inherits the base `--run-all` script and runs the gRPC latency and throughput benchmarks the same way the non-HAProxy variant does. **Latency** | Scenario | p50 | p90 | p95 | p99 | |---|---:|---:|---:|---:| | http | 0.808204 | 0.861002 | 0.884248 | 0.965185 | | http_1mb | 0.916350 | 0.960832 | 0.979879 | 1.035858 | | http_10mb | 2.923250 | 3.028106 | 3.064171 | 3.147383 | | http_streaming | 10606.518767 | 10727.092702 | 10782.166075 | 10793.441756 | | http_intermediate_streaming | 11520.631168 | 11709.328922 | 11783.598146 | 11794.278803 | | grpc | 0.329592 | 0.359457 | 0.374129 | 0.419050 | | grpc_1mb | 2.914066 | 3.262638 | 3.301536 | 3.536366 | | grpc_10mb | 28.468160 | 29.396314 | 29.621062 | 33.389895 | | handle | 0.496363 | 0.535661 | 0.563960 | 0.684138 | | handle_1mb | 1.240247 | 1.785575 | 2.186740 | 2.772050 | | handle_10mb | 20.357473 | 24.710342 | 26.734965 | 34.078222 | | handle_choose_dispatch | 1.365623 | 1.479252 | 1.537067 | 1.765258 | | handle_streaming | 11385.084532 | 11440.792105 | 11521.717464 | 11530.988577 | **Throughput** | Scenario | Average | Standard deviation | Rate | |---|---:|---:|---| | http | 3170.64 | 71.61 | RPS | | http_model_comp | 1532.82 | 10.25 | RPS | | http_100_max_ongoing_requests | 3179.71 | 73.90 | RPS | | http_model_comp_100_max_ongoing_requests | 1849.08 | 23.66 | RPS | | http_800_max_ongoing_requests | 2445.74 | 54.76 | RPS | | http_model_comp_800_max_ongoing_requests | 1567.39 | 22.87 | RPS | | http_streaming | 46990.46 | 436.22 | TPS | | http_intermediate_streaming | 12994.40 | 152.01 | TPS | | grpc | 4476.50 | 40.00 | RPS | | grpc_model_comp | 1791.69 | 11.26 | RPS | | grpc_100_max_ongoing_requests | 4498.49 | 41.80 | RPS | | grpc_model_comp_100_max_ongoing_requests | 1840.62 | 11.83 | RPS | | grpc_800_max_ongoing_requests | 4622.03 | 58.40 | RPS | | grpc_model_comp_800_max_ongoing_requests | 1841.71 | 18.64 | RPS | | handle | 3504.46 | 46.10 | RPS | | handle_model_comp | 1020.17 | 25.20 | RPS | | handle_100_max_ongoing_requests | 3539.55 | 41.45 | RPS | | handle_model_comp_100_max_ongoing_requests | 1691.89 | 9.40 | RPS | | handle_800_max_ongoing_requests | 3470.64 | 44.36 | RPS | | handle_model_comp_800_max_ongoing_requests | 1633.69 | 10.54 | RPS | | handle_streaming | 13147.51 | 57.50 | TPS | Signed-off-by: akyang-anyscale <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>

This PR implements gRPC service support for HAProxy.
Basic functionality
proto h2HAProxyManager, we now just add them to the haproxy config in their own grpc backendsapplicationheader in the request. if there's only one app, then just always map to that backendHealth Checks
List Applications
HAProxy serving check
Tuning flags