-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Discuss the longevity of the httpclient handler #42219
Comments
@karelz ? |
@EngRajabi where is the default coming from? Is it from Thanks! |
I mean when different programmers use httpclientfactory in different projects. And add in startup. services.AddHttpClient("extendedhandlerlifetime") .SetHandlerLifetime(TimeSpan.FromMinutes(5)); |
@EngRajabi what kind of decrease in program performance do you / they see in such case? (comparing 2 min vs. 30 min) In general, I don't have strong opinion on what the timeout should be. In .NET Core 2.1, we need to keep it smaller, otherwise it will prevent reaction to DNS changes, which is a problem. That should be the only platform with such problem to my knowledge. |
By performance reduction I mean building the handler in times of very high app traffic.
|
Tagging subscribers to this area: @dotnet/ncl |
I think the issue here is every 2 minutes a new handler will be created, which means requests on the new handler will need to:
There will be a brief period of high latency as the new handler and its connections are established. Does a 2 minute start time make sense with |
I think DNS changes are the main reason for not making the default unlimited. From the SetHandlerLifetime doc comments: "Some handlers also keep connections open indefinitely which can prevent the handler from reacting to DNS changes. The value of should be chosen with an understanding of the application's requirement to respond to changes in the network environment" |
SocketsHttpHandler itself is going to close out connections by default after two minutes of inactivity on a given connection. That setting can be changed on the handler, though, as can a max lifetime for a connection, e.g. such that the connection won't be reused for new requests after X period of time (which defaults to infinite). |
Exactly, I mean, is 2 minutes enough for all this work ?? |
That may depend on your particular situation @EngRajabi . Do you have environment when DNS rapidly changes - and old nodes are still up but refusing to serve content? If not, I think it would be quite safe to bump up various limits. Depending on your OS and setting TLS may use TLS session resumption - that is significantly cheaper than full handshake. But for most people, the port reuse is more important. |
Discuss the longevity of the httpclient handler. #70770
Currently the life of the httpclient handler is 2 minutes. Given that 99% of packages do not change the default lifespan and we use them in our projects. And that new architectures based on micro-services have advanced. Wouldn't it be better to extend Handler's default lifespan to improve system performance?
Any program you want can change the lifespan to suit your needs, but we can extend this default to improve performance.
The text was updated successfully, but these errors were encountered: