Skip to content
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

utils: let http client can reuse connections #6914

Merged
merged 2 commits into from Aug 9, 2023

Conversation

nolouch
Copy link
Contributor

@nolouch nolouch commented Aug 8, 2023

What problem does this PR solve?

Issue Number: Close #6913

What is changed and how does it work?

utils: let HTTP client can reuse connections

Check List

Tests

  • Manual test

Before:

image
image

pd-0(follower):

image

pd-1(leader):

image

After:

image
image

pd-1(follower):

image

pd-2(leader):

image

Release note

None.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 8, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HuSharp
  • lhy1024

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Merging #6914 (d139862) into master (a605e11) will increase coverage by 0.14%.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6914      +/-   ##
==========================================
+ Coverage   74.23%   74.37%   +0.14%     
==========================================
  Files         427      427              
  Lines       45127    45140      +13     
==========================================
+ Hits        33500    33573      +73     
+ Misses       8672     8628      -44     
+ Partials     2955     2939      -16     
Flag Coverage Δ
unittests 74.37% <100.00%> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@@ -433,12 +433,16 @@ func CreateClients(tlsConfig *tls.Config, acUrls []url.URL) (*clientv3.Client, *

// createHTTPClient creates a http client with the given tls config.
func createHTTPClient(tlsConfig *tls.Config) *http.Client {
return &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need DisableKeepAlives?

Copy link
Contributor Author

@nolouch nolouch Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, otherwise cannot reuse.

Signed-off-by: nolouch <nolouch@gmail.com>
TLSClientConfig: tlsConfig,
},
}
// FIXME: Currently, there is no timeout set for certain requests, such as GetRegions,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DisableKeepalive is in many releases, do we need to pick this pr for the older versions?

Copy link
Contributor Author

@nolouch nolouch Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be some reason to open DisableKeepalive in the old version like some places may not close resp.Body, that's cause the connect cannot reuse and then need to establish a new connection. before, DisableKeepalive can make connect close faster to reduce connection leaks issues.

I think the problem does not exist now, let's only pick to the recent version first.

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 8, 2023
Copy link
Member

@HuSharp HuSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 9, 2023
@bufferflies
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 9, 2023

@bufferflies: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 9, 2023

This pull request has been accepted and is ready to merge.

Commit hash: d139862

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Aug 9, 2023
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Aug 9, 2023

@nolouch: Your PR was out of date, I have automatically updated it for you.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot bot merged commit d4138c8 into tikv:master Aug 9, 2023
22 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #6916.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Aug 9, 2023
close tikv#6913

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #6917.

@nolouch nolouch deleted the fix-http branch August 9, 2023 02:42
ti-chi-bot bot pushed a commit that referenced this pull request Aug 9, 2023
close #6913

utils: let HTTP client can reuse connections

Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: nolouch <nolouch@gmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Aug 9, 2023
close #6913

utils: let HTTP client can reuse connections

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: nolouch <nolouch@gmail.com>

Co-authored-by: ShuNing <nolouch@gmail.com>
Co-authored-by: nolouch <nolouch@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-6.5 needs-cherry-pick-release-7.1 release-note-none size/S Denotes a PR that changes 10-29 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Too Many Handshakes when redirect requests consume many CPU
6 participants