question

MoonHeonYoung avatar image
MoonHeonYoung asked

about huge works

Hi

Scenario I want:

I have 18 segments.

Based on "rank" statistic, bronze 123, silver 123 etc.. Total of 18 segments.

(eg, bronze 1000~1100 statistic filter)

Every Sunday night, I run the cloud code for each segment. (scheduled task recurring)

Each segment performs a different function.

(Bronze segment of 1100 subtract 100 points, and bronze reward is paid.

And silver is subtract by 200pts and silver reward is paid)

In order to implement the above function, I thought of two ways.

1. After creating "18 scheduled tasks", execute the cloud function for each segment.

2. After creating "only one Scheduled task", call serverAPI.GetPlayersInSegment 18 times in one function.

Then, for each segment, "for" statement executes to get all players in each segment.

(If there are more than 10,000 players, it will be complicated to consider paging as well.)

above

#1 is (i think) good idea but there is a high probability that system will be limited to 25 task limits.

#2 is (i think) to be expensive if the server API is executed with each "for statement" for more than 10,000 players in one cloud function.

In other words, after getting 10,000 players(assumption) for each segment, "updateStatistic" and "grantToItem" functions are called per player.

Since two apis are called per player, a total of tens of thousands of calls will be made.

Is this a better way than using the 18 tasks above? What is the way I should do it?

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

·
Citrus Yan avatar image
Citrus Yan answered

#2 most likely will timeout given the number of players it needs to process, therefore, #1 is preferred. And, yes, the total number of Scheduled Tasks is limited to 25 per title and is not susceptible to changes. For that you might want to reduce the number of scheduled tasks as much as possible, for instance, instead of using 18 segments for each rank range, have the cloud function determine which rank range the player falls in and grant the corresponding reward. In other words, leave most of the logics in cloud function.

10 |1200

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

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.