-
Notifications
You must be signed in to change notification settings - Fork 91
perf(gateway): reverse proxy throughput optimizations #825
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
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
18f1b1c
perf(gateway): set TCP_NODELAY on inbound and upstream sockets
kvinwang 251cc2a
perf(gateway): raise default proxy buffer_size to 64 KiB
kvinwang a5230e6
perf(gateway): install rustls session ticketer for TLS 1.3 resumption
kvinwang b895265
perf(gateway): move per-connection proxy logs from info to debug
kvinwang 2b4254c
perf(gateway): add opt-in splice(2) zero-copy relay for TLS passthrough
kvinwang 67091f9
perf(gateway): add opt-in kernel TLS offload for the terminate path
kvinwang 222d4af
perf(gateway): offload to kTLS only after a traffic threshold
kvinwang a76d6ee
perf(gateway): add opt-in thread-per-core proxy with SO_REUSEPORT
kvinwang d23bc68
perf(gateway): reuse splice pipes from a per-thread pool
kvinwang 9eceb4a
perf(gateway): skip the JoinSet when only one upstream candidate exists
kvinwang 4458186
fix(gateway): recycle splice pipes from both directions
kvinwang 3235eeb
perf(gateway): engage splice only after a traffic threshold
kvinwang 95314d9
perf(gateway): raise the listen backlog and use one bind path
kvinwang 45adb53
fix(gateway): log peer disconnects at debug, not error
kvinwang 6b48d0e
perf(gateway): enable thread_per_core by default, with a SO_REUSEPORT…
kvinwang 7bbd588
perf(gateway): drop the per-operation timers and BiLock from the TCP …
kvinwang afffef3
perf(gateway): try the splice syscall before waiting for readiness
kvinwang b5b66ad
refactor(gateway): bind the reuseport group in one place, in order
kvinwang 37c07d9
perf(gateway): hand new connections to a less loaded core
kvinwang 74bb791
chore(gateway): drop two helpers left unused by the rebalance and buf…
kvinwang 7ed96e8
fix(gateway): register a handed-over connection with the target core'…
kvinwang 8264d40
perf(gateway): scale the rebalance threshold with load instead of usi…
kvinwang 35dcf3e
perf(gateway): rebalance connections across cores by default
kvinwang f380d53
feat(gateway): gate splice and kTLS on elapsed time as well as bytes
kvinwang 7144825
feat(gateway): let idle splice relays park their pipe in the pool
kvinwang 8cc2378
docs(gateway): record the measured gate and pipe-release numbers
kvinwang 6a7fbcf
docs(gateway): replace the small-scale gate numbers with 50k-connecti…
kvinwang 9d5729f
docs(gateway): close the bulk-regression question for idle pipe release
kvinwang e42c8a9
fix(gateway): probe for the TLS ULP before trusting the kTLS config
kvinwang 7b5ba58
feat(gateway): report the effective kTLS and splice state
kvinwang c02d77a
build(gateway): vendor ktls 6.0.2 with the musl fix
kvinwang 7563a8e
fix(gateway): satisfy the CI clippy lint set
kvinwang 3089307
fix(gateway): terminate the vendored ktls licence files with a newline
kvinwang 37a06da
fix(gateway): keep the vendored ktls out of the workspace members
kvinwang 2a09444
fix(gateway): keep relaying after a half-close instead of dropping th…
kvinwang 6597097
fix(gateway): bound the handoff queue and stop claiming failures are …
kvinwang 83a24ab
fix(gateway): document buffer_size's cost and refuse ciphertext at kT…
kvinwang 4e2e780
fix(serde-duration): return errors for bad units instead of panicking
kvinwang b1e0f9b
fix(gateway): enforce timeouts.idle on the spliced and kTLS relay paths
kvinwang e7df1cb
fix(gateway): warn when connection_rebalance cannot take effect
kvinwang 15cd8e1
test(gateway): add proxy data-path integration tests and run them in CI
kvinwang ded4a00
style(gateway): satisfy the repo's python and shell linters in the pr…
kvinwang 3a9b6f3
feat(os): enable kernel TLS in the guest kernel, both backends
kvinwang d411372
fix(gateway): do not let a kTLS close_notify discard the in-flight re…
kvinwang e33d477
fix(gateway): make the SNI sniff remainder impossible to drop silently
kvinwang 6d67a51
style(gateway): document the half-close TLS client's public methods
kvinwang 1e0710e
Potential fix for pull request finding 'CodeQL / Workflow does not co…
kvinwang 8e22368
fix(gateway): keep the idle watchdog on after a half-close
kvinwang 153206f
fix(gateway): watch the drain's writes too, not just its reads
kvinwang 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # SPDX-FileCopyrightText: © 2026 Phala Network <dstack@phala.network> | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: Gateway proxy tests | ||
|
|
||
| # The gateway's proxy data path has two opt-in optimisations (`tcp_splice`, | ||
| # `ktls`) whose behaviour depends on kernel capabilities and on a per-connection | ||
| # gate. Unit tests cover the relay functions; this runs a real gateway process | ||
| # and asserts on what actually reaches the wire. | ||
| on: | ||
| push: | ||
| branches: [ master, next, dev-* ] | ||
| paths: | ||
| - 'dstack/gateway/**' | ||
| - 'dstack/vendor/ktls/**' | ||
| - '.github/workflows/gateway-proxy-tests.yml' | ||
| pull_request: | ||
| branches: [ master, next, dev-* ] | ||
| paths: | ||
| - 'dstack/gateway/**' | ||
| - 'dstack/vendor/ktls/**' | ||
| - '.github/workflows/gateway-proxy-tests.yml' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| proxy-integration: | ||
| runs-on: ${{ vars.CI_RUNNER || 'ubuntu-latest' }} | ||
| # Each of the ~25 arms restarts the gateway, and the idle-timeout arms wait | ||
| # out a real timeout, so this is minutes rather than seconds. | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Install Rust | ||
| uses: dtolnay/rust-toolchain@1.92.0 | ||
|
|
||
| - name: Cache cargo | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| dstack/target | ||
| key: gateway-proxy-${{ runner.os }}-${{ hashFiles('dstack/Cargo.lock') }} | ||
| restore-keys: gateway-proxy-${{ runner.os }}- | ||
|
|
||
| - name: Build the gateway | ||
| working-directory: dstack | ||
| run: cargo build --release -p dstack-gateway | ||
|
|
||
| - name: Record kernel capabilities | ||
| # The suite adapts to what the kernel offers, so the log needs to say | ||
| # what it had: a run that skipped kTLS looks the same as one that | ||
| # covered it otherwise. | ||
| run: | | ||
| echo "kernel: $(uname -r)" | ||
| sudo modprobe tls 2>&1 || echo "no TLS ULP available" | ||
| echo "tls module loaded: $(lsmod | grep -c '^tls ' || true)" | ||
| grep -B2 -A3 'gcm(aes)' /proc/crypto | grep -E '^(driver|priority)' \ | ||
| | paste - - | sort -u || true | ||
|
|
||
| - name: Proxy integration tests | ||
| working-directory: dstack/gateway/test-run | ||
| env: | ||
| GATEWAY_BIN: ${{ github.workspace }}/dstack/target/release/dstack-gateway | ||
| run: ./test_proxy.sh | ||
|
|
||
| - name: Upload logs on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: gateway-proxy-test-logs | ||
| path: /tmp/dstack-gw-proxy-test.*/logs/ | ||
| if-no-files-found: ignore | ||
| retention-days: 7 | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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.
Uh oh!
There was an error while loading. Please reload this page.