wc-api-python icon indicating copy to clipboard operation
wc-api-python copied to clipboard

[Slow performance] - two seconds for each call

Open marcofucito opened this issue 4 years ago • 7 comments

Hi, In my tests, each wcapi call takes about 2 seconds, regardless of the content of the call. If I do a get of a single product or a get of 100 products, it always takes about 2 seconds.

Two seconds for an operation on 100 products can be an acceptable time, however it is far too long for an operation on only one product.

The fact that the long execution time does not depend on the type of call, makes me rule out a problem on my server, and makes me think that most of the time is used to "establish the connection" and not to "execute the query".

Can i do something to speed up the process?

Thanks

marcofucito avatar Oct 14 '21 17:10 marcofucito

I am too having the same problem. Have anyone found a solution to this?

ahmedselim2017 avatar Dec 14 '21 12:12 ahmedselim2017

Same problem here :

[2022-04-11 18:07:06,549] - [DEBUG] - Starting new HTTPS connection (1): blabla.co:443
[2022-04-11 18:07:08,123] - [DEBUG] - https://blabla.co:443 "GET /wp-json/wc/v3/products?&page=2&per_page=100 HTTP/1.1" 200 None
[2022-04-11 18:07:08,232] - [DEBUG] - Starting new HTTPS connection (1): blabla.co:443
[2022-04-11 18:07:09,743] - [DEBUG] - https://blabla.co:443 "GET /wp-json/wc/v3/products?&page=3&per_page=100 HTTP/1.1" 200 None

It's because of the handshake at each request. I don't know if there is a solution for this.

For the requests package there is a session() parameter, so the handshake is done once. I don't find the same thing for wc-api.

chichi13 avatar Apr 11 '22 16:04 chichi13

I hope @claudiosanches will check this to add requests.session() in api.py for faster performance

chichi13 avatar Apr 13 '22 13:04 chichi13

some news regarding this feature? related to https://github.com/woocommerce/woocommerce/issues/26029#issuecomment-1197084730 ??? probably

javix64 avatar Jul 27 '22 17:07 javix64

some news regarding this feature? related to woocommerce/woocommerce#26029 (comment) ??? probably

I don't think the related issue is the same problem as this issue. This issue seems to be a session issue in the wc-api-python code. The handshake is made for each request and not only once. The related issue seems to be related to woocommerce API directly and not to the python package.

But I would love to hear from the developer on this issue.

chichi13 avatar Jul 31 '22 14:07 chichi13

If you are still looking for a solution, since the repo is not maintained, I have forked the project to add the Session + Retry here : https://github.com/chichi13/wc-api-python-unofficial

chichi13 avatar Sep 17 '22 13:09 chichi13

If you are still looking for a solution, since the repo is not maintained, I have forked the project to add the Session + Retry here : https://github.com/chichi13/wc-api-python-unofficial

LOL. Timing. I just raised a trivial PR for this. Your branch adds retry, and updates deps and more, so enhances this library even further. Thanks.

rooprob avatar Sep 18 '22 21:09 rooprob