I have few ideas how I can break my logic before hitting single request time limit but I'm not sure if this solution is best.
I have guessing game where players during single day tries guess some number. At the end of day i fire my script which must iterate over all estimations, calculate player score post it to leaderboard and do other fancy things.
Right now I just every minute check that is something to do (dedicated collection with tasks to speed up queering remaining tasks), if it is I perform my task for example calculate score for all estimations. But I don't know how many iterations will be performed so I check how many time consume previous iteration and break loop if previous iteration multiplied by some constants (for example 2) is bigger than remaining time - pseudo code in attachment.
Do you have any other better solution for this problem?
What exactly are you running here ? Ideally you don't want your script execution to be getting anywhere near 30 seconds where possible. What kind of task are you trying to run here ?