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
|
@redox Thanks for your contribution. Could you check and fix the errors reported on GitHub Actions? |
Yeah not sure why this started complaining but I'm adding the |
|
Could you reformat files with the command below? |
Gosh of course! |
|
Hi @redox, thank you for the original proposal and implementation. Since this PR has not been updated for over a year, I opened #168 with a fresh implementation based on the same approach, updated for the current codebase. I also added more extensive test coverage. I referenced this PR and credited your original work in the description of #168. @yuokada, would it be okay to continue the discussion and review in #168? |
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