Show HN: Dead easy Python for executing many HTTP requests asynchronously
github.com
github.com
It has been tested in the wild with more than 10 million requests. Automatically handles errors and executes retries.
Also provides helper functions for executing embarrassingly parallel async coroutines.
It was pretty remarkable to go from 32 cores being maxed for 100 concurrent workers to... A 10-15% usage spike on a 4 core XPS :)
Our typical CRUD Spring backends can handle ~15,000 requests a second with no optimization.
I appreciate all the effort that's gone into making Python faster but I think it's still the wrong tool for the job at this point if heavy load is involved
There is a space for go and other languages, but also for libraries like these.
Is vanilla Python networking is still dog slow, on the order of 1k requests per second per core on mid-range consumer hardware no matter how you wire it all together?
Here's a complete, similar example from the Python docs: https://docs.python.org/3/library/concurrent.futures.html#th....
Granted that example is more lines of code than the README for this library. But the core of it is fairly straightforward:
rsps = []
with concurrent.futures.ThreadPoolExecutor(max_workers=N) as executor:
futures = [executor.submit(requests.get, url) for url in urls]
for future in concurrent.futures.as_completed(futures):
rsps.append(future.result)Also `many-requests` has further logic to deal with retries and bad responses.
But I think requests already handles retries on its own.
I haven't done the same experiment with async-io but it would be quite easy using this package `many-requests`
What is the current best practice way to parallelize reading many parquet files on S3 using pyarrow? Deep down, it's just lots of HTTP requests.
That installation creates a folder named many_requests inside the site-packages directory on your PYTHON_PATH. It uses underscore rather than hyphen because modules/packages must be legal Python names. A hyphen would be parsed as subtraction.
And inversely, PyPI normalizes the package name (the name you give to `pip install`) to use hyphens instead of underscores. https://www.python.org/dev/peps/pep-0503/#normalized-names