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

Feature: support HostClient.MaxGreedyConns #1655

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

bingoohuang
Copy link

support HostClient.MaxGreedyConns to create new connections in greedy instead reusing until the MaxGreedyConns value

…ons in greedy instead reusing until the MaxGreedyConns value
@erikdubbelboer
Copy link
Collaborator

Can you explain the use case for this? And can you add a test to make sure it works and will keep working correctly in the future.

@bingoohuang
Copy link
Author

We use fasthttp client to a target server, and we want to known to how many connections can be established in max to the remote https server, without considering the request-response processing performance. The current fasthttp HostClient's implementation will try to reuse the existing idle connections at first, which is not easy for us to achieve the above scenario.

I will try to add a test case to this MaxGreedyConns. Thanks.

@erikdubbelboer
Copy link
Collaborator

If you want to know how many connections you can open why not just use net and open TCP sockets without sending anything? Why do you need fasthttp for this?

@bingoohuang
Copy link
Author

Can you explain the use case for this? And can you add a test to make sure it works and will keep working correctly in the future.

a test case added.

@bingoohuang
Copy link
Author

If you want to know how many connections you can open why not just use net and open TCP sockets without sending anything? Why do you need fasthttp for this?

In simple, it is as you said.

But in fact, I used fasthttp as the base http client library. In my program, I setup a customized http session to specified server, which means there is still some session setup post-processing after http/https connection established. This works well for a long time until recent days, the customer want to know how many this specified sessions can be setup in max, and then this pull request came out to find the answer in a easy way.

@erikdubbelboer
Copy link
Collaborator

Did you find the limit already? I'm wondering how useful it is to merge this into fasthttp (which already has a really big API service) when it seems like no-one else needed this feature so far. Maybe it's best to keep this pull request open for a while and see if other people would also be interested.

@@ -77,6 +77,12 @@ type Request struct {
// By default redirect path values are normalized, i.e.
// extra slashes are removed, special characters are encoded.
DisableRedirectPathNormalizing bool

// UsingProxy 是否使用代理
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the non-english comments?

// UsingProxy 是否使用代理
UsingProxy bool

// ConnAcquiredCallback 连接获取后回调,用于获取连接信息(例如 *tls.Conn 中的证书信息等)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants