Replace httpx with request for sync version
- Related implementation https://github.com/ably/ably-python/pull/200/files
- This is due to the fact that, httpx causes performance issues when hitting limit of 100k requests/minute.
- Link to internal discussion ~~> https://ably~~real-time.slack.com/archives/C030C5YLY/p1698238346488369?thread_ts=1697535419.670029&cid=C030C5YLY
➤ Automation for Jira commented:
The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3914
TODO
- [ ] 1. Reproduce the issue using load testing on a dedicated server.
- [ ] 2. If reproduced, then make a change to switch to a different library.
@owenpearson has an idea about how to reproduce the issue and do the load testing.
Some more findings ->
- Current SDK uses
httpxversion as 0.24.1 which has dependency onhttpcoreuses -> 0.17.3 - Latest version of
httpxis0.25.2, it useshttpcore-> 1.0.2 - Some critical bugfixes has been addressed in latest version of
httpx. - While running tests make sure we run it on both older and newer versions of
httpx.
One of the related fix seems to be -> https://github.com/encode/httpcore/pull/823
The current SDK only supports httpx to be used in http2 mode -> https://github.com/ably/ably-python/blob/10cb4a08c64f915a2878ffd1139b08a50811124d/ably/http/http.py#L132.
There is still an active issue for http2 -> https://github.com/encode/httpcore/issues/775 that talks about gracefully closing the connection. Fix is already done for http1.1.
NEW TODO
- [ ] 1. Reproduce the issue using load testing on a dedicated server.
- [ ]
httpx-> 0.24.1 and http2 ( use current SDK as is ! ) - [ ]httpx-> 0.24.1 and http1.1 - [ ]httpx-> 0.25.2 and http2 - [ ]httpx-> 0.25.2 and http1.1 - [ ] 2. If still facing the issue, then make a change to requests library that uses http
1.1rather thanhttp2😒
I don't know whether it could help your case, but you may consider taking a look at Niquests instead of downgrading to requests. Your feedback would be interesting. Would be happy to get this project where you aim to reach.
@Ousret Thanks for the suggestion !
Seems we can use https://locust.io/ as a tool for load testing.
https://medium.com/@yusufenes3494/how-to-build-your-own-load-test-a-step-by-step-guide-1a8367f7f6a2
Seems locusts by default uses python-requests for executing test against given server https://docs.locust.io/en/stable/increase-performance.html. No wonder, python-requests is stable and doesn't cause issue on high throughput.
Need to check if we can configure other client like httpx instead of default python-requests
One of the way is to clone python-locust project and modify https://github.com/locustio/locust/blob/master/locust/clients.py file to use httpx client instead of python-requests.
This will help us to use all features of locust client like result tracking, without writing explicit code for the same.