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.
For example:
query_sequence=set([3,8,12,21,37])
check_result_sequence=set([13,18,22,31,47])
server_traffic=query_sequence.union(check_result_sequence)
But their union (server_traffic) is not random , since
check_result_sequence=query_sequence+10
P.S.: Generating time-points with more granularity might help with reducing probability of collisions (as mentioned in the comment). As regards randomness of the union of two sequences, I dont see any satisfactory solution. What I finally decided to do was
check_result_sequence=query_sequence+10+( 5*random.random())
This adds a random "jitter" to the responses sequence, and so should help with reducing correlation between the two sequences.