-
-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Support configuring proxy mode #82
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
sbernauer
wants to merge
35
commits into
main
Choose a base branch
from
feat/trino-query-events
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 25 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
c4b5139
chore: Add smoke kuttl test
sbernauer 0dc5b0c
Add kuttl test for routing
sbernauer 2b6cd8d
feat: Support receving Trino query events
sbernauer 0fd9f6c
docs
sbernauer dfb1260
Add two different proxying strategies
sbernauer aa36bd4
Merge remote-tracking branch 'origin/chore/kuttl-tests' into feat/tri…
sbernauer 0d2efdc
Add kuttl test for proxy mode
sbernauer 281c506
Some docs
sbernauer 8f4d7dc
changelog
sbernauer 88b3005
linter
sbernauer 9e9f0cf
linter
sbernauer 6caf0a6
Add a diagram
sbernauer af0d3eb
Markdown linter
sbernauer 286386b
Update docs/proxy-modes.md
sbernauer 43b3b5d
Update docs/design.md
sbernauer 0001851
Update docs/proxy-modes.md
sbernauer c3f1aec
Apply suggestions from code review
sbernauer 03e72a4
Update docs/proxy-modes.md
sbernauer 764bb5b
Reword
sbernauer c214c1b
Remove sentence from docs
sbernauer 1ad3685
Document compression layers
sbernauer 4bad5b4
Add some
sbernauer e44dd5b
Add more derives
sbernauer 918b334
Move test fixtures
sbernauer f7a3828
Update trino-lb/src/http_server/mod.rs
sbernauer 9e446b4
Apply suggestions from code review
sbernauer 90c655e
Clean up test-definition.yaml
sbernauer 0fc40c4
Apply suggestions from code review
sbernauer 05f59e3
Check in missing test files
sbernauer 0b3a6a0
Change casing
sbernauer b9ed460
Update docs/design.md
sbernauer bc0ece2
Fingers crossed :)
sbernauer ce4e3b6
fix: Remove todo!()
sbernauer 1b4657b
Rework architecture to increment at query submition and decrement at …
sbernauer 3025ea6
Support alternative hostnames for Trino clusters
sbernauer 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
trinoLb: | ||
externalAddress: https://5.250.179.64:8443 | ||
externalAddress: https://85.215.178.111:8443 | ||
tls: | ||
enabled: true | ||
certPemFile: /certificates/cert.pem | ||
keyPemFile: /certificates/key.pem | ||
certPemFile: /certificates/tls.crt | ||
keyPemFile: /certificates/tls.key | ||
persistence: | ||
redis: | ||
clusterMode: true | ||
endpoint: redis://:[email protected]:6379/ | ||
# postgres: | ||
# # helm install postgres bitnami/postgresql --version 13.2.18 --set auth.username=trino-lb,auth.password=trino-lb,auth.database=trino_lb | ||
# url: postgres://trino-lb:[email protected]/trino_lb | ||
# maxConnections: 10 | ||
proxyMode: ProxyAllCalls | ||
refreshQueryCounterInterval: 30s # It is low for testing purpose and to get frequent running queries metrics | ||
tracing: | ||
enabled: true | ||
|
@@ -56,7 +57,7 @@ | |
- name: trino-m-2 | ||
endpoint: https://trino-m-2-coordinator-default.default.svc.cluster.local:8443 | ||
credentials: *common-credentials | ||
# oidc: | ||
# maxRunningQueries: 3 | ||
# trinoClusters: | ||
# - name: trino-oidc-1 | ||
|
@@ -101,7 +102,7 @@ | |
routingFallback: m | ||
|
||
clusterAutoscaler: | ||
reconcileInterval: 1s | ||
# reconcileInterval: 1s | ||
stackable: | ||
clusters: | ||
trino-s-1: | ||
|
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Proxy mode | ||
|
||
trino-lb can be configured to either proxy all calls to the underlying Trino clusters or only the initial `POST` and instruct the client to connect directly to the Trino cluster for the subsequent polling requests. | ||
sbernauer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
It also needs to keep track of all started and finished queries on the Trino clusters, so that it can correctly calculate the number of running queries. | ||
|
||
You can configure the proxy mode using | ||
|
||
```yaml | ||
trinoLb: | ||
proxyMode: ProxyAllCalls # or ProxyFirstCall, defaults to ProxyAllCalls | ||
``` | ||
## Proxy all calls (default) | ||
In this mode, the client will make all requests through trino-lb, not only the initial `POST`. | ||
|
||
Benefits: | ||
|
||
- Counting queries can be achieved by inspecting the traffic | ||
- Trino clients do not require network access to coordinator | ||
|
||
Downsides: | ||
|
||
- Query run times can be increased in when a lot of data is transferred from the Trino coordinator to the Trino client due to network delay added by trino-lb (see the [performance research task](https://github.com/stackabletech/trino-lb/issues/72) for details) | ||
sbernauer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
## Proxy first call | ||
|
||
In this mode, the client only sends the initial `POST` to trino-lb. All following requests will be send to the Trino cluster directly. | ||
sbernauer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
As trino-lb cannot inspect the traffic in the subsequent calls, it would have no knowledge of the started and finished queries. However, an [HTTP event listener](https://trino.io/docs/current/admin/event-listeners-http.html) can be configured in Trino to inform trino-lb about all query starts and completions. | ||
|
||
Benefits: | ||
|
||
- Better performance, as there is no network delay added by trino-lb | ||
- In the future more advanced features can be built based on information from the Trino events | ||
|
||
Downsides: | ||
|
||
- It requires active configuration on the Trino side, namely setting up the HTTP event listener | ||
- Trino clients require network access to the coordinator | ||
|
||
A sample configuration in Trino can look something like the following. | ||
Please have a look at the [kuttl tests](https://github.com/stackabletech/trino-lb/tree/main/tests/templates/kuttl/) for complete examples. | ||
|
||
Please note that you cannot disable the TLS certificate check. In the example below, the secret-operator from the Stackable Data Platform is used to provision valid TLS certificates automatically. | ||
|
||
```yaml | ||
apiVersion: trino.stackable.tech/v1alpha1 | ||
kind: TrinoCluster | ||
metadata: | ||
name: my-trino | ||
spec: | ||
coordinators: | ||
configOverrides: &configOverrides | ||
config.properties: | ||
event-listener.config-files: /tmp/http-event-listener.properties | ||
podOverrides: &podOverrides | ||
spec: | ||
containers: | ||
- name: trino | ||
volumeMounts: | ||
- name: http-event-listener-config | ||
mountPath: /tmp/http-event-listener.properties | ||
subPath: http-event-listener.properties | ||
volumes: | ||
- name: http-event-listener-config | ||
configMap: | ||
name: trino-http-event-listener-config | ||
workers: | ||
configOverrides: *configOverrides | ||
podOverrides: *podOverrides | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: trino-http-event-listener-config | ||
data: | ||
http-event-listener.properties: | | ||
event-listener.name=http | ||
http-event-listener.connect-ingest-uri=https://trino-lb.trino-lb.svc.cluster.local:8443/v1/trino-event-listener | ||
http-event-listener.connect-retry-count=10 | ||
http-event-listener.http-client.trust-store-path=/stackable/server_tls/truststore.p12 | ||
http-event-listener.http-client.trust-store-password=changeit | ||
http-event-listener.log-created=true | ||
http-event-listener.log-completed=true | ||
http-event-listener.log-split=false | ||
``` |
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.