You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Microsoft.Extensions.Http.Resilience 8.0.1" adds 1.2 MBytes of packages #4937
This is just my two cents and I might be talking out of my hat, so please, no one get offended.
I was using "Microsoft.Extensions.Http.Resilience 8.0.1" to simply add standard resilience to HttpClient calls, then I've realized that the package is adding 1.2 MBytes of dlls to the project.
I think this is totally unaceptable to simpy add a standard resilience to the HttpClient calls. I think the key problem is: We need to add resilience to HttpClient calls: N retries with some delay, then OK or FAIL, that's it.
My believe is that the ASP.NET team is doing a big effort to achieve NativeAOT but I don't think this package is helping to achieve that goal.
Hey @barruka, you are right that Microsoft.Extensions.Http.Resilience adds a bunch of dependencies. The good thing is that all these (up to the Polly itself) are trimming-friendly. So if you care about the publish size, I recommend to enable native AOT.
I did some tests just to see how some HTTP features affect the package size:
And output executable was generated by calling dotnet publish command. So if you want to cut the assembly size to minimum, while still keeping the resilience, you might want to use the ResilienceHandler and define your own resilience pipeline with retries. Over raw HttpClient this adds around 700KB of size. You can also use raw Polly without ResilienceHandler, but that only saves about 50KB, so I would go with ResilienceHandler. All other types are trimmed out.
FYI, we recommend AddStandardResilienceHandler as a go-to resilience solution, because it has everything set-up by default (logging, telemetry, pipeline of strategies), but as you see you have plenty of options to setup-the resilience.
Activity
martintmk commentedon Feb 14, 2024
Hey @barruka, you are right that
Microsoft.Extensions.Http.Resilienceadds a bunch of dependencies. The good thing is that all these (up to the Polly itself) are trimming-friendly. So if you care about the publish size, I recommend to enable native AOT.I did some tests just to see how some HTTP features affect the package size:
Hello World Console - 1.2MB
HTTP Client - 5.1MB
HTTP Client with
ResilienceHandler- 5.8MBHTTP Client with
ResilienceHandlerand standard resilience - 6.32 MBThis sample illustrates how to create "standard resilience" without the DI.
HTTP Client with raw resilience - 5.745 MB
HTTP Client with standard resilience - 7.2 MB
My
csprojis:And output executable was generated by calling
dotnet publishcommand. So if you want to cut the assembly size to minimum, while still keeping the resilience, you might want to use theResilienceHandlerand define your own resilience pipeline with retries. Over raw HttpClient this adds around700KBof size. You can also use raw Polly withoutResilienceHandler, but that only saves about50KB, so I would go withResilienceHandler. All other types are trimmed out.FYI, we recommend
AddStandardResilienceHandleras a go-to resilience solution, because it has everything set-up by default (logging, telemetry, pipeline of strategies), but as you see you have plenty of options to setup-the resilience.