by Bedon292 · 9y ago · 0 comments
I know the benchmarks cannot really be compared, since one involves a queue, and mongo, while the other does not. But, it seems like a prime use case for async.
from multiprocessing import Pool
from requests import get
urls = 1000 * ['http://localhost/hello']
def scrape(url):
return get(url).text
p = Pool(40)
results = p.map(scrape, urls)
~2.2 seconds on a dual core 2.2ghzI've used multiprocessing/threads/geven/asyncio before. And I will have a full test with these libraries.
Thanks again!
There are lots of factors involved which can completely skew benchmarks, for example, if you were scraping an average 10kb response instead of 'hello world' you would automatically be limited to 100req/s on a 10mbit pipe.
Thanks for your comment again. welcome to discuss more technical details about it.