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 /
  • General Discussion /
avatar image
Question by John Peterson · Oct 24, 2017 at 11:41 PM · CloudScriptapis

Server API: calling GrantUserItems versus ModifyItemUsesRequest.

Dear PlayFab community,

If I am granting x50 of four different items in an operation, is it better to call GrantUserItems() one time with x200 ItemIds in the list, or call ModifyItemUsesRequest four times with the +50 increment? I feel like the former (GrantUserItems), largely to limit the number of Server API calls, but wanted to confirm.

Thanks in advance for any help anyone can provide!

Comment

People who like this

0 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Oct 25, 2017 at 01:20 AM

Well first, it's important to realize that very large inventories and large inventory grants can take a significant amount of time to complete. Adding a bunch of a single stackable Item ID will be quick, since the items are pre-aggregated before the work to update the player inventory though, so given that you're referring to modifying the item uses, you shouldn't see issues with this (it's just good to bear that in mind).

Some details for the specific scenario you describe:

  • The grant call will take about the same amount of work in either case (due to the pre-aggregation I mentioned).
  • Calls that operate on an item instance ID are extremely efficient, since that's their index in the table (no table scan required).

So it's actually fairly close, but for the extra Server API calls (which do increase the overall "cost" somewhat).

But the most important point is that by breaking the operation up into multiple calls, you're running the risk of the first call (or two or three) succeeding, but then the other calls failing due to the player losing connectivity. In that case, you're in a bad state. So I'd recommend making it one call to grant the items.

Comment
John Peterson

People who like this

1 Show 1 · 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 John Peterson · Oct 25, 2017 at 01:35 AM 0
Share

Thanks, Brendan! I think that helps me, and it's good to know that you pre-aggregate the ItemIDs from the GrantItemsToUser list.

I should have mentioned that, in my case, all these items are Stackable (but I think you assumed as much ;-).

Good point, too, that, from a data integrity perspective, it's better to reduce the number of API calls. To that end, I'll do as you suggest and go with the GrantItemsToUser.

Thanks again!

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

    1 Person is following this question.

    avatar image

    Related Questions

    Add Hours/Minutes in Current Server Timestamp 1 Answer

    Any way to "reset" all CloudScript instances? 1 Answer

    Update Player Currency in Azure functions 1 Answer

    How to access the variables of cloud scripts in Unity's C# script ? 0 Answers

    Problem with CloudScript handler function returning string. 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