What's a memory-efficient way to compute 10 requests per second based on timestamps of the incoming data for the last 60 seconds?
I have the following 10-digit, Unix timestamps:
1458573970
1458573970
1458573970
1458573971
1458573972
1458573971
1458573973
1458573975
1458573980
We have about 9 requests in a timespan of 10 seconds. I have to keep lag in consideration, as some of the incoming timestamps can be out of order by plus/minus a second.
Eventually there will be a cutoff of 60 seconds, so I want to keep track of the 60 second cutoff for every 10 requests per seconds. (So I need to determine if I continuously get 10 requests per second on average for the last 60 seconds.)
I saw the answer to this question Calculating number of messages per second in a rolling window? but the answer seems to be based off immediate data, and most of the answers don't take a historical timestamp into account.
I thought about doing something like this, but I don't quite have a solution formed.