I have about 140,000 one time API calls I need to do, the problem is that they all take about 15 seconds. This would take about 25 days to do successively, however, I’d like to get it done faster.
I’m planning on dumping the data returned into a MySQL database using a JSON parser and a function that takes the parsed data. I am familiar with Python and PHP.
What is the best way (as in, fastest and simplest to implement) to do a number of API calls concurrently and have the returned items parsed into a DB?
Probably you’ll have to try multithreading / multiprocessing.
This will only help if multiple parallel calls are allowed by the API (and if the machine where the API is run is fast enough to process more than one call at a time).
If the bottleneck is not your own CPU, you can simply use the
threadingmodule, asmultiprocessingwon’t have any more improvements.As unchecked code, you could try:
The main ideas in this code: