I'm trying to request some data from an api using python!
Here's the code I am using:
import concurrent.futures
import requests
def my_function(url):
response = requests.get(url)
with open("data.csv", "a+") as f:
f.write(response+'\n')
with concurrent.futures.ThreadPoolExecutor() as executer:
for i in range(9120000000, 9130000000):
try:
url = f"https://mysite.test/api/v1/{str(i)}"
executer.submit(my_function, url)
except:
"There was an error!"
Now here are my questions:
1- The code I'm currently using is going to open up 10,000,000 threads at the same time?is that even possible?
2- If so, then is this considered a ddos attack on that server?
3- Is there a way to subset that range into smaller ranges, lets say, 200-interval based ranges?
4- Is there a better way to do this?
This script is going to be deployed on heroku servers. According to the heroku documentations a free dyno could support no more than 256 threads.
Any help and/or suggestions would be greatly appreciated!