I am extending an existing application with additional scripting that will be running very frequent calculations. I'd like to describe in loose terms my application's specifics and see if you can help me determine an efficient way to do this within a stated time limit.
My application will ping an API every second - or at worst, every few seconds - and return a large JSON dataset with thousands of data points. Once returned, I need to iterate over this captured data and run some addition calculations on the provided data followed by a division operation (almost like an averaging operation), then store the result in a database, and if a particular condition is met I'll also be triggering an alert of sorts. Once this cycle is done, the next API call will be made to capture the next set of data.
However, the next set of data will be extremely similar to the first, only incrementally bigger - an additional 1 (or more seconds) of data will be appended to the data set. Basically, every time the script is run (at least until the end of the day), the data set will be 1 (or more) seconds larger than the previous, but the historical data is "set in stone" and won't change, so each call is 99% similar to the one before it, save for the new time-series data.
The alert trigger, if applicable during a given "run", needs to be kicked off before the next firing of the above script.
Now, take that process, and multiply it by about 10,000. I will be running this script on around 10,000 different data sets in parallel every second (or every few seconds at worst).
---
My initial question is: since the dataset is very similar on each firing of the script, save for the last 1 or more seconds that include the latest data, would it be better to store the returned API called data locally and on every subsequent iteration, only fetch the latest data from the API and combine it with the stored data in the DB? I know the answer to this likely is based on "how fast" the API is - it's pretty fast.
I'm willing to deploy whatever VPS resources are needed for this - I use Digital Ocean so I'm trying to determine whether I need a CPU optimized VPS, a Memory optimized VPS, or just maximize for everything.
---
Any help is appreciated!
My application will ping an API every second - or at worst, every few seconds - and return a large JSON dataset with thousands of data points. Once returned, I need to iterate over this captured data and run some addition calculations on the provided data followed by a division operation (almost like an averaging operation), then store the result in a database, and if a particular condition is met I'll also be triggering an alert of sorts. Once this cycle is done, the next API call will be made to capture the next set of data.
However, the next set of data will be extremely similar to the first, only incrementally bigger - an additional 1 (or more seconds) of data will be appended to the data set. Basically, every time the script is run (at least until the end of the day), the data set will be 1 (or more) seconds larger than the previous, but the historical data is "set in stone" and won't change, so each call is 99% similar to the one before it, save for the new time-series data.
The alert trigger, if applicable during a given "run", needs to be kicked off before the next firing of the above script.
Now, take that process, and multiply it by about 10,000. I will be running this script on around 10,000 different data sets in parallel every second (or every few seconds at worst).
---
My initial question is: since the dataset is very similar on each firing of the script, save for the last 1 or more seconds that include the latest data, would it be better to store the returned API called data locally and on every subsequent iteration, only fetch the latest data from the API and combine it with the stored data in the DB? I know the answer to this likely is based on "how fast" the API is - it's pretty fast.
I'm willing to deploy whatever VPS resources are needed for this - I use Digital Ocean so I'm trying to determine whether I need a CPU optimized VPS, a Memory optimized VPS, or just maximize for everything.
---
Any help is appreciated!