I am wanting to issue http requests in parallel and here is how my code (skeleton) looks like when using ray:
@ray.remote
def issue_request(user_id):
r = requests.post(url , json, headers)
ray.get([issue_request.remote(id_token[user_id]) for _ in range(500)])
This is running much slower as compared to the following:
def issue_request(user_id):
r = requests.post(url , json, headers)
jobs = []
for i in range(500):
process = multiprocessing.Process(target=issue_request,
args=(admin_id))
jobs.append(process)
for j in jobs:
j.start()
# Ensure all of the processes have finished
for j in jobs:
j.join()
The machine has two cores and it seems that ray only starts two processes to handle the 500 requests. Can someone please tell me how to tell ray to start 1 worker/process per request?