vendredi 7 décembre 2018

python create random list of numbers along with a fixed increment

I have a long-running (several hours) script that periodically sends queries to a server. The server is very sensitive to load, so the queries are sparse (not more than 1 every 3 minutes).

The server will always take exactly 10 minutes to process the query. So I can check the result of query 1 any time after 10 minutes of sending it.

So there are two types of operations, "sending query" and "checking result of query". I want all operations to happen at random intervals (subject to the constraint than there are at least 3 minutes between adjacent operations)

Following the advice in this answer (https://stackoverflow.com/a/51918697/10690958) , I can generate a time-series of integers such that there is a gap of at least 3 between them. Lets all be series 1.

I can also generate a similar time-series of status checking queries (3 minutes between them). Lets call this series 2.

Now series 1 is randomly spaced. Series 2 is also randomly spaced. But there is a correlation between series 1 and 2 ,i.e. "response time"="query time"+10 minutes.

This the union of series 1 and 2 wont be random. Furthermore there is a (very small) possiblility of collision. For example, query 2 might be going out exactly when one is checking the result of query 1.

Is there a way to make union of the two sequences also perfectly random , as well as avoid the possibility of collisions. Ideally all traffic to the server (whether query or status check) should be at perfectly random intervals/

I realize that the title is not very descriptive, but could not figure out a better way to describe the situation. Please edit if you think you have a better description.




Aucun commentaire:

Enregistrer un commentaire