question

brendan avatar image
brendan asked

Scheduled task to drive a PvP system

Question from a developer:

Would it be possible to use an hourly scheduled task to read all players from a segment (around 10K), match them up, and do an update to player data for each?

tasks
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

It sounds like you would be running a scheduled task against a segment, and taking a couple of actions per player (one read, and one write), which is certainly within scope of a triggered Cloud Script handler, but the processing time is going to depend upon the total number of players you're trying to get through. So while this should work fine in a segment of 10K users, as you start to scale up the user base, that time is going to grow - to the point where it could take more than an hour, depending on your service tier.

8 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

info-7 avatar image info-7 commented ·

Thank you Brendan,

So as long as there is only 1 Scheduled Task running at the same time, the Cloud Script won't timeout and can make infinite amount of internal getData updateData calls?

Also I was wondering how many memory can we allocate inside a Cloud Script?

I'm thinking in creating batches of users to keep the computation time small

0 Likes 0 ·
brendan avatar image brendan info-7 commented ·

No, what I was saying was that Cloud Script handlers triggered via PlayStream (including Tasks) are more limited in terms of total runtime, not less. You can find the limit for Cloud Scripts running from PlayStream triggers on the limits page for your title.

So you would realistically need to process players one at a time, not try to load all of your users at once.

0 Likes 0 ·
info-7 avatar image info-7 brendan commented ·

I have a solution that reduces the http requests by 4, so instead of making 1 read and 1 write per player, I could store the elo in a statistic in order to retrive it with the GetPlayersInSegment() in my own server, match them by myself and then make 1 CloudScript call with the 2 player parameters, that will load their data, simulate the fight and store the result.

Does the normal api call request limit (15) apply to this behaviour?

0 Likes 0 ·
Show more comments
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.