Closed ggnaegi closed 7 months ago
@ggnaegi Wow! So great thing... π You are real coding locomotive, Gui! π
FYI... Delivery after #1724 , so these both PRs cannot be in the same release because of Prod testing.
Guys, Let's return to this awesome PR after Nov'23 release.. π β
@raman-m @RaynaldM I'm writing the test cases at the minute. No worries guys! I realized we can still simplify the logic, since the Downstreamroute is an immutable, no need to use the timeout as key parameter, the object reference is good enough. We might have problems in the future if allowing dynamic configuration though (1: empty the pool, then 2: load the new configuration).
@raman-m @RaynaldM I'm writing the test cases at the minute. No worries guys! I realized we can still simplify the logic, since the Downstreamroute is an immutable, no need to use the timeout as key parameter, the object reference is good enough. We might have problems in the future if allowing dynamic configuration though (1: empty the pool, then 2: load the new configuration).
By the way, why not use the Record type instead?
@raman-m @RaynaldM I'm writing the test cases at the minute. No worries guys! I realized we can still simplify the logic, since the Downstreamroute is an immutable, no need to use the timeout as key parameter, the object reference is good enough. We might have problems in the future if allowing dynamic configuration though (1: empty the pool, then 2: load the new configuration).
By the way, why not use the Record type instead?
It is a good idea
:+1:
Hello @raman-m and @RaynaldM I'm providing some benchmarks, it seems the memory leak has been addressed
Please, resolve the conflict! π
@ggnaegi As you may know, I've attached #695 ... Is it right? Do you think that #695 will also be fixed by this PR?
The 695 quote:
I couldn't find any configuration setting to enable request or response streaming.
What about this?
Ready for code review @RaynaldM FYI
@raman-m I think, it's the request mapper implementation that solved the issue #695 (we were copying the full request body to a memory stream). Now, with the http client pool we avoid using the http client full buffering, but as others wrote, the performance improvement is minimal. There was another flaw, reading body content to generate cache keys, but this issue has been addressed in https://github.com/ThreeMammals/Ocelot/pull/1849
Ready for delivery! βοΈ
@raman-m @RaynaldM I would like to add a few test cases, ok?
@ggnaegi commented on Jan 9
Need to review once again? I will review before the merge definitely! π Let us know when ready to review plz!
Pray π to GitHub Bot which can remove current approvals when you push more commits! π
@raman-m could we push this to the november release? I think it's high priority.
@raman-m so, I have added a memory usage acceptance test in ContentTests. I have tried it with the current develop, and we can see a memory increase of about the payload size. In this PR, it is kept within a range of +/- 10 Mb
@raman-m but we should be careful and foresee some field tests when merged to develop, since the refactoring is quite aggressive....
@raman-m but we should be careful and foresee some field tests when merged to develop, since the refactoring is quite aggressive....
@ggnaegi Yes, it is. Sorry, I don't understand... What are "some field tests"?
Merging was done by you a couple of hours ago. I'll just press the button, there will be no merge conflicts with develop branch too. So, what's the rest of work?
@raman-m but we should be careful and foresee some field tests when merged to develop, since the refactoring is quite aggressive....
@ggnaegi Yes, it is. Sorry, I don't understand... What are "some field tests"?
Merging from develop was done by you a couple of hours ago. I'll just press the button, there will be no merge conflicts.
@raman-m I mean, wait on feedbacks from @RaynaldM and others before moving to release and create the packages ;-)
Ha, making packages... No! I see you are so hot to release π€£ There is the rest of 2 other features in the milestone. Ok, make sense to wait for Ray's feedback...
Ready to merge! βοΈ
@ggnaegi @RaynaldM Let me know if you agree with merging.
Hey guys, just asking. When will this be released ? Would need that for my project π
Hey guys, just asking. When will this be released ? Would need that for my project π
Hello, we have validated the behavior on production environments. It's looking good. we will finalize the release process in the next few days.
@IamMartinPeek Soon... It will be released, I hope, on Monday, Feb 12...
Closes #356 #695 #1924
356
695
1924
After some checks, it seems impossible to use
HttpClientFactory
in the solution. There are several reasons for this:HttpMessageHandler
can potentially be unique for each route. In the case of a "Named"HttpClient
, it's possible to useConfigurePrimaryHttpMessageHandler
, but this method will only be invoked the first timeHttpClientFactory.CreateClient("Named")
is called. In our case, this would mean that we are configuring as many "Named" clients as there are routes. This is not quite what we are looking for.HttpMessageInvoker
is potentially less resource-intensive thanHttpClient
. Of course,HttpMessageInvoker
is not returned byHttpClientFactory
and worse, if we force the cast, then we could face major performance problems. See: https://github.com/microsoft/reverse-proxy/issues/458I conclude that we must implement our own pool mechanism... Thus, I propose a first draft of a solution using solutions borrowed from StackExchange and Microsoft. It will obviously have to be tested in detail, but it serves as a basis for discussion.
Proposed Changes
HttpMessageInvoker
instead ofHttpClient
SocketsHttpHandler
, introducing a new parameterPooledConnectionLifetime
inHttpHandlerOptions
IMessageInvokerPool
, the pool of message invokers, inspired by StackExchange implementationHttpClientBuilder
,HttpClientWrapper
and others)I will provide Acceptance and Unit tests later. You should @raman-m, @RaynaldM have a look at this draft. Thanks
Table 1: Performance with current http client
Table 2: Performance with the custom message invoker pool