-
Notifications
You must be signed in to change notification settings - Fork 7.2k
[Serve] Add HAProxy support for Ray Serve #60586
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
Draft
eicherseiji
wants to merge
8
commits into
ray-project:master
Choose a base branch
from
eicherseiji:serve-haproxy-port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e533fa9
[Serve] Add HAProxy support for Ray Serve
eicherseiji 60f7ab1
Add missing DRAINING_MESSAGE constant and BUILD targets for HAProxy t…
eicherseiji 764dd04
Update BUILD files for HAProxy tests
eicherseiji 856d1eb
Add missing NO_ROUTES_MESSAGE and NO_REPLICAS_MESSAGE constants
eicherseiji 9d7a87e
Fix HAProxyManager not being used when RAY_SERVE_ENABLE_HAPROXY=1
eicherseiji 20b6005
Add HAProxy to Dockerfile and _dump_ingress_cache_for_testing method
eicherseiji 338fa19
Install HAProxy in serve CI build image
eicherseiji 35de30c
Build HAProxy 2.8.12 from source in serve CI image
eicherseiji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -236,6 +236,9 @@ | |||||||||||||||||||||
| # rechecking whether the proxy actor is drained or not. | ||||||||||||||||||||||
| PROXY_DRAIN_CHECK_PERIOD_S = 5 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Message returned by proxy health check when draining. | ||||||||||||||||||||||
| DRAINING_MESSAGE = "This node is being drained." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| #: Number of times in a row that a replica must fail the health check before | ||||||||||||||||||||||
| #: being marked unhealthy. | ||||||||||||||||||||||
| REPLICA_HEALTH_CHECK_UNHEALTHY_THRESHOLD = 3 | ||||||||||||||||||||||
|
|
@@ -570,6 +573,12 @@ | |||||||||||||||||||||
| # The message to return when the replica is healthy. | ||||||||||||||||||||||
| HEALTHY_MESSAGE = "success" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # The message to return when the route table is not populated yet. | ||||||||||||||||||||||
| NO_ROUTES_MESSAGE = "Route table is not populated yet." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # The message to return when no replicas are available yet. | ||||||||||||||||||||||
| NO_REPLICAS_MESSAGE = "No replicas are available yet." | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Feature flag to enable a limited form of direct ingress where ingress applications | ||||||||||||||||||||||
| # listen on port 8000 (HTTP) and 9000 (gRPC). No proxies will be started. | ||||||||||||||||||||||
| RAY_SERVE_ENABLE_DIRECT_INGRESS = ( | ||||||||||||||||||||||
|
|
@@ -656,3 +665,66 @@ | |||||||||||||||||||||
| 5000, # 5s | ||||||||||||||||||||||
| 10000, # 10s | ||||||||||||||||||||||
| ] | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Feature flag to use HAProxy | ||||||||||||||||||||||
| RAY_SERVE_ENABLE_HAPROXY = os.environ.get("RAY_SERVE_ENABLE_HAPROXY", "0") == "1" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # HAProxy configuration defaults | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_MAXCONN = int(os.environ.get("RAY_SERVE_HAPROXY_MAXCONN", "20000")) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_NBTHREAD = int(os.environ.get("RAY_SERVE_HAPROXY_NBTHREAD", "4")) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_CONFIG_FILE_LOC = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_CONFIG_FILE_LOC", "/tmp/haproxy-serve/haproxy.cfg" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_SOCKET_PATH = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_SOCKET_PATH", "/tmp/haproxy-serve/admin.sock" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_ENABLE_HAPROXY_OPTIMIZED_CONFIG = ( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_ENABLE_HAPROXY_OPTIMIZED_CONFIG", "1") == "1" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_SERVER_STATE_BASE = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_SERVER_STATE_BASE", "/tmp/haproxy-serve" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_SERVER_STATE_FILE = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_SERVER_STATE_FILE", "/tmp/haproxy-serve/server-state" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HARD_STOP_AFTER_S = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_HARD_STOP_AFTER_S", "120") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_METRICS_PORT = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_METRICS_PORT", "9101") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_SYSLOG_PORT = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_SYSLOG_PORT", "514") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_TIMEOUT_SERVER_S = ( | ||||||||||||||||||||||
| int(os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_SERVER_S")) | ||||||||||||||||||||||
| if os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_SERVER_S") | ||||||||||||||||||||||
| else None | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_TIMEOUT_CONNECT_S = ( | ||||||||||||||||||||||
| int(os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_CONNECT_S")) | ||||||||||||||||||||||
| if os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_CONNECT_S") | ||||||||||||||||||||||
| else None | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
Comment on lines
+704
to
+708
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code calls
Suggested change
|
||||||||||||||||||||||
| RAY_SERVE_HAPROXY_TIMEOUT_CLIENT_S = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_CLIENT_S", "3600") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HEALTH_CHECK_FALL = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_HEALTH_CHECK_FALL", "2") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HEALTH_CHECK_RISE = int( | ||||||||||||||||||||||
| os.environ.get("RAY_SERVE_HAPROXY_HEALTH_CHECK_RISE", "2") | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HEALTH_CHECK_INTER = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_HEALTH_CHECK_INTER", "5s" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HEALTH_CHECK_FASTINTER = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_HEALTH_CHECK_FASTINTER", "250ms" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| RAY_SERVE_HAPROXY_HEALTH_CHECK_DOWNINTER = os.environ.get( | ||||||||||||||||||||||
| "RAY_SERVE_HAPROXY_HEALTH_CHECK_DOWNINTER", "250ms" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Direct ingress must be enabled if HAProxy is enabled | ||||||||||||||||||||||
| if RAY_SERVE_ENABLE_HAPROXY: | ||||||||||||||||||||||
| RAY_SERVE_ENABLE_DIRECT_INGRESS = True | ||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code calls
os.environ.get("RAY_SERVE_HAPROXY_TIMEOUT_SERVER_S")twice, which is inefficient. You can use the walrus operator:=to store the result of the first call and reuse it, making the code more efficient and readable.