Ensure a single Faraday client is used per Client#137
Open
redox wants to merge 6 commits intotreasure-data:masterfrom
Open
Ensure a single Faraday client is used per Client#137redox wants to merge 6 commits intotreasure-data:masterfrom
redox wants to merge 6 commits intotreasure-data:masterfrom
Conversation
For now, each `start`, `resume` or `kill` query would instantiate a new `Faraday` client by calling `Trino::Client.faraday_client` at the query level. This PR refactors the logic of the `Trino::Client` to ensure a single `Faraday` client is used per instance of `Trino::Client` and set all the query (and user) specific HTTP headers at query time. This avoids the need to reconnect to the Trino server dealing with all the SSL handshake processing time at each query + allow the usage of [faraday-net_http_persistent](https://github.com/lostisland/faraday-net_http_persistent) to benefit from HTTP keep-alive. While the benefit of saving a few ms at each Trino statement query might not be that visible for the "long running queries" use-cases (where the actual Trino query anyway takes up to a few seconds to answer), we've seen large improvements for use-cases where the queries are taking a few dozens of ms.
1c08bf4 to
58561ed
Compare
Collaborator
|
@redox Thanks for your contribution. Could you check and fix the errors reported on GitHub Actions? |
Author
Yeah not sure why this started complaining but I'm adding the |
Collaborator
|
Could you reformat files with the command below? |
Author
Gosh of course! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
This PR ensures a single
FaradayHTTP client is used perTrino::Clientinstance.Overview
For now, each
start,resumeorkillquery would instantiate a newFaradayclient by callingTrino::Client.faraday_clientat the query level.This PR refactors the logic of the
Trino::Clientto ensure a singleFaradayclient is used per instance ofTrino::Clientand set all the query (and user) specific HTTP headers at query time. This avoids the need to reconnect to the Trino server dealing with all the SSL handshake processing time at each query + allow the usage of faraday-net_http_persistent to benefit from HTTP keep-alive.While the benefit of saving a few ms at each Trino statement query might not be that visible for the "long running queries" use-cases (where the actual Trino query anyway takes up to a few seconds to answer), we've seen large improvements for use-cases where the queries are taking a few dozens of ms.
Checklist