-
Notifications
You must be signed in to change notification settings - Fork 563
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
axios vs undici with ProxyAgent #3915
Comments
I don't think the proxy agent was every optimized, thanks for the call. Can you help assembling a benchmark everyone can reproduce? Otherwise it would be really hard to optimize. Note that your undici call has a significant memory leak. You are not consuming the body, preventing the sockets to be reused. You should try:
|
@mcollina thanks for quick response! I created a reproducible environment for this issue, you can find a code here: yerlantemir@9820786. With the following setup, I am constantly getting worse results with undici Would love to hear your thoughts on this |
you have an error with axios in the last example, because of this, it sends requests through the default agent, and not the one specified you also have a restriction on agent connections, but requests are still sent one at a time and not immediately to all possible connections const makeAxiosRequest = async () => {
await axios.get(serverUrl + '/hello?foo=bar', {
httpsAgent: axiosHttpsProxyAgent,
httpAgent: axiosHttpsProxyAgent // +++
});
}
|
If you use all 100 agent connections, then undici will be 2 times faster |
Thanks @PandaWorker! |
@PandaWorker Thanks for your help. I couldn't make 2x faster, but at least it's not losing to axios on performance. On the production environment, axios is still a little bit faster(10-20%). Currently I am trying to replicate this environment and find out the issues, will be back if I find something useful. |
Hi team,
First of all, thank you for amazing work than you have done so far! I hope this bug is happening because of my misuse and would love to contribute if there are some problems with the library.
Bug Description
When using undici with ProxyAgent, request performance is significantly slower compared to axios with https-proxy-agent for parallel requests through a proxy server.
Reproducible By
Expected Behavior
Replacing axios with undici should maintain or improve performance.
Logs & Screenshots
You can find the test script here: https://jumpshare.com/v/0ol3h5KZePayCSY46GY1?b=DJylk9UBBfNgJiz93jg4
Environment
MacOs Sonoma 14.3
node v20.13.0
Additional context
We are running a service that sends ~1000s of requests each minute to the third party service through proxy server. Currently, we are using axios with https-proxy-agent and are exploring undici for potential performance improvements and the ability to add retry logic. Could you please help identify what might be causing this issue? Is there a specific way undici should be configured in this case, or could this be related to a bottleneck in the library?
The text was updated successfully, but these errors were encountered: