-
Notifications
You must be signed in to change notification settings - Fork 185
router: bound inference request body size and HTTP listener connections #1477
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
Open
vivek-gite
wants to merge
4
commits into
volcano-sh:main
Choose a base branch
from
vivek-gite:feat/1475-router-requests-limits
base: main
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
68db7d5
feat(router): add request and connection limits for kthenaRouter
vivek-gite 745fc80
Merge branch 'main' into feat/1475-router-requests-limits
vivek-gite 9ff7b23
Merge branch 'main' into feat/1475-router-requests-limits
vivek-gite 55506f3
Merge branch 'main' into feat/1475-router-requests-limits
vivek-gite 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -122,6 +122,22 @@ networking: | |
| # -- Drain timeout for kthena-router graceful shutdown. | ||
| # -- This should be less than terminationGracePeriodSeconds. | ||
| drainTimeout: 5m | ||
| # requestLimits bounds the request size and connection lifetime accepted by | ||
| # the router listeners. No write deadline is applied, so streaming inference | ||
| # responses are unaffected. | ||
| requestLimits: | ||
| # -- Largest inference request body accepted, in bytes.<br/> | ||
| # A larger request is rejected with HTTP 413 before it is buffered.<br/> | ||
| # Set to `0` to disable the limit. | ||
| maxRequestBodyBytes: 33554432 | ||
| # -- Maximum time a client may take to send the complete request headers.<br/> | ||
| # Bounds slow-header clients holding connections open. | ||
| readHeaderTimeout: 10s | ||
| # -- Maximum time an idle keep-alive connection is kept open between requests. | ||
| idleTimeout: 120s | ||
| # -- Largest request header block accepted, in bytes.<br/> | ||
| # A larger header block is rejected with HTTP 431. | ||
| maxHeaderBytes: 1048576 | ||
|
Member
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. There is a default 1MB in golang http package |
||
|
|
||
| global: | ||
| # -- Certificate Management Mode.<br/> | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -92,6 +92,7 @@ func (s *Server) startRouter(ctx context.Context, router *router.Router, store d | |
| readyCheck: s.HasSynced, | ||
| activeRequests: router.ActiveRequestCount, | ||
| drainTimeout: s.drainTimeout, | ||
| limits: s.limits, | ||
| startLog: fmt.Sprintf("Starting default server on port %s", s.Port), | ||
| shutdownStartLog: "Shutting down default HTTP server ...", | ||
| shutdownDoneLog: "Default HTTP server exited", | ||
|
|
@@ -205,6 +206,7 @@ type listenerConfig struct { | |
| readyCheck func() bool | ||
| activeRequests func() int64 | ||
| drainTimeout time.Duration | ||
| limits serverLimits | ||
| // Gateway mode (non-nil => use gateway branch). | ||
| gateway *listenerGatewayConfig | ||
| startLog string | ||
|
|
@@ -214,6 +216,19 @@ type listenerConfig struct { | |
| logListenErr func(err error) | ||
| } | ||
|
|
||
| // newHTTPServer builds a listener HTTP server with the connection-level bounds | ||
| // applied. WriteTimeout is intentionally left unset so that long-running | ||
| // streaming inference responses are not truncated. | ||
| func newHTTPServer(addr string, handler http.Handler, limits serverLimits) *http.Server { | ||
|
vivek-gite marked this conversation as resolved.
|
||
| return &http.Server{ | ||
| Addr: addr, | ||
| Handler: handler, | ||
| ReadHeaderTimeout: limits.readHeaderTimeout, | ||
| IdleTimeout: limits.idleTimeout, | ||
| MaxHeaderBytes: limits.maxHeaderBytes, | ||
|
Member
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. I think we can define constant timeout unless there is a must to configure |
||
| } | ||
| } | ||
|
|
||
| // startListener: build Gin, listen, graceful shutdown on ctx. | ||
| func startListener(ctx context.Context, cfg listenerConfig) *http.Server { | ||
| engine := gin.New() | ||
|
|
@@ -277,10 +292,7 @@ func startListener(ctx context.Context, cfg listenerConfig) *http.Server { | |
| } else { | ||
| klog.Fatal("startListener: invalid listenerConfig (need gateway or defaultRouter+readyCheck)") | ||
| } | ||
| srv := &http.Server{ | ||
| Addr: cfg.addr, | ||
| Handler: engine.Handler(), | ||
| } | ||
| srv := newHTTPServer(cfg.addr, engine.Handler(), cfg.limits) | ||
|
|
||
| go func() { | ||
| klog.Info(cfg.startLog) | ||
|
|
@@ -525,6 +537,7 @@ func (lm *ListenerManager) addListenerToPort(port int32, config ListenerConfig, | |
| gateway: &listenerGatewayConfig{lm: lm, port: port}, | ||
| activeRequests: lm.router.ActiveRequestCount, | ||
| drainTimeout: lm.server.drainTimeout, | ||
| limits: lm.server.limits, | ||
| startLog: fmt.Sprintf("Starting Gateway listener server on port %d", port), | ||
| shutdownStartLog: fmt.Sprintf("Shutting down Gateway listener server on port %d ...", port), | ||
| shutdownDoneLog: "", | ||
|
|
||
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.
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.
a comment, how many MB
and same apply to below header.