I'm using Python coroutine library gevent and monkey patch to increase the concurrency of http requests. But I noticed the elapsed time of the responses increased while the concurrency increased. Below the sample code:
import gevent
from gevent import monkey
import requests
monkey.patch_all(thread=False)
def action():
resp = requests.get("https://www.google.com")
if resp.status_code == 200:
print resp.elapsed.total_seconds()
jobs = []
for i in range(100):
jobs.append(gevent.spawn(action))
gevent.joinall(jobs)
When 10 greenlets were spawned, the elapsed time was around 0.9 seconds, but when the greenlets number was increased to 100, the elapsed time was around 1.6 ~ 2.0 seconds. Why this happened?