Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Tuomas Karmakallio · Jan 08, 2020 at 07:35 AM · CloudScriptlimits

Best Practice for dealing with anomalous Automation cloud script timeout error

Every night, I run a script which zeroes out daily rewards from active players. During christmas, the script ( which usually takes 40ms to complete ) errored out for 750 users, apparently going over the 1 second time limit.

The question is, how should this be handled? I have found the documentation related to catching the error, but there is no clear example for forcing a retry. I also considered sending an email alert, but I don't really want to get 750 emails in my inbox.

Comment

People who like this

0 Show 1
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tuomas Karmakallio · Feb 13, 2020 at 03:10 PM 0
Share
EDIT : Spoke too soon, investigating

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by SethDu · Jan 09, 2020 at 02:30 AM

What's the title ID? The execution time limit to Cloud Script should be 4.5 seconds for essential tier Titles and can be extended in paid tier.

To be honest, the design nature of PlayFab determines that there can be very few of failure cases when executing scheduled tasks and it can be caused by many factors. As long as it only occupies very little proportion, it should be normal. We will suggest developer to provide a support channel to players to submit issues for manual fixes.

There are many solutions, for example, collecting the reported PlayFab ID and add tags for them so that they will be categorized into the same segments. After some time (you can inform the players that the fix will come with next update), manually run the task again.

Another method (personally preferred) is to use PlayFab Explorer(located at [Game Manager] -> [Data] -> [Explorer]) to directly list the player IDs via advanced query in Kusto language. Filter the results for player_triggered_action_executed_cloudscript events. Please check "Publish results as PlayStream Event" for sceduled tasks.

Comment

People who like this

0 Show 5 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tuomas Karmakallio · Jan 09, 2020 at 11:26 PM 0
Share

Thank you.

The tagging into a group method sounds like a good way to catch it.
Perhaps run a checker script an hour later.

I am considering creating a player for the server to use as a data interface with the automated scripts : so if something errors out, it can set a flag on the serverData player.
Then, if I run a cloudscript on the single serverData player, I could get a single email alerting me of a problem.

Using internal titledata seems like what I want to access but to run Automated scripts one must always have a segment of players.

Is creating a serverPlayer for this purpose common practice?

avatar image SethDu ♦ Tuomas Karmakallio · Jan 10, 2020 at 02:37 AM 1
Share

This work around seems to be feasible. However, It will be more reasonable to configure a Rule in the Game Manager, to monitor the event "player_triggered_action_executed_cloudscript", where error message is contained in the context(set it as a filter). Then execute Cloud Script function or anything else you want.

Actively triggering things is always more efficient than passively and periodically running a checking task.

avatar image Tuomas Karmakallio SethDu ♦ · Jan 10, 2020 at 07:50 AM 0
Share

Great, thanks again. I'll proceed with this advice.

avatar image Tuomas Karmakallio · Jan 09, 2020 at 11:29 PM 0
Share

Title Id : 2B87

avatar image Tuomas Karmakallio · Jan 22, 2020 at 08:27 AM 0
Share

Side note : automation script time limit is 1 second.

avatar image

Answer by Tuomas Karmakallio · Jan 21, 2020 at 09:21 PM

Once more to clarify, I have an automated script that normally takes 30 millisecs to complete, it modifies a couple of playerdata variables for active players segment, and every so often some of them go over the title_exceeded_limit of 1 second.

I would prefer not to have the server mess with this, just handle it all in Playfab.

So, this seems to be the plan:

  1. catch error in script 1 to custom title event
  2. create rule to react to that event
  3. that rule calls cloudscript 2
  4. script 2 needs to aggregate the playerId somewhere - titleData?
  5. schedule cloudscript 3 to run a couple of hours later and process any slowpokes caught in the net

what if script 3 errors out as well though? Keep looping, 1, 2, 4 hour intervals

It seems pretty complex to do something that seems to be a commonplace occurence?

Comment

People who like this

0 Show 3 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu ♦ · Jan 22, 2020 at 07:58 AM 0
Share

Normally, we won't recommend any backup plans for any scheduled tasks failure. It will be more efficient to handle this failure by players submitting a report for manual fixes. If there are massive issues for a task, you may submit a support ticket so that corresponding team will help you to identify the issue. The backup plans for scheduled task will not be effective as itself has the possibility to fail meanwhile, it is resource-wasting to implement another backup plan for a backup plan.

When you meet small parts of failure in a scheduled task very frequently. You should consider if the CCU has been increased and if the former functions can handle requests with the frequency increases. The APIs called in a Cloud Script function will still be counted in the Title Limits.

avatar image Tuomas Karmakallio SethDu ♦ · Jan 22, 2020 at 08:08 AM 0
Share

I beg to disagree. The script is light : it normally takes 30 milliseconds, and it is filtered to active player segment ( < 1000 per title currently ). We do not cause a heavy load, all our Limits are well within bounds. The failure is intermittent, but happens too often for comfort ( maybe once a week ).

handlers.resetDaily = function (args, context) {
    var request = {
        PlayFabId: currentPlayerId,
        Data: {
            playerDailyCoins: "0",
            playerRedeemLink: "",
            playerGoldenTicketRedeemLink: "",
            playerGiftCard: "",
            playerGiftCardLink: "",
        }
    }
    server.UpdateUserData(request);
}

A failure of the script causes the player's client to see a prize they should not be getting ( and which they cannot redeem ), resulting in a bad user experience. Relying on a user email and manual adjustment of the playerData is quite the opposite of efficiency.

P.S. using an abbreviation like CCU is ambiguous. A search for CCU in docs results in 0 hits.

avatar image SethDu ♦ Tuomas Karmakallio · Jan 22, 2020 at 08:57 AM 1
Share

Thanks for the additional details. I will dig into this and discuss with the team.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Was the "CloudScript execution API requests issued" limit raised to 15? 1 Answer

    [CloudScript] Playfab Account Initialization 1 Answer

    Cloud Script execution API requests issued limit for standard tier(new plan) ? 1 Answer

    Does using Http in CloudScript count toward the API limit? 1 Answer

    Execute cloud script -function parameter 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges