question

Chris B. avatar image
Chris B. asked

Cloud Script arguement size

I am creating a multiplayer turn based game where I'm saving data up to playfab and this data can then be pulled at some point by the other player when they take their turn.

At first, I tried to use a sharedgroup to hold the game data and player data was to be used simply as a reference to the sharedGroup that held the game data. However, because my game data can be 30kb -100kb, I noticed this wouldn't work as sharedgroup key/values can only be 10kb each.

So, I switched to where each player maintains a sharedGroup that holds references to their active games and the game data is stored in their player data.

I have a single cloud script that makes 4 api calls to set up all this when a new game is started, however, I'm getting the CloudScriptFunctionArgumentSizeExceeded error.

What is the size limitation on arguements for cloudscript? I can't really reduce the data size, because the player gets to do some drawing and I have to capture that line data to know what to display for the opponent.

Thanks for any help you can provide.

10 |1200

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

brendan avatar image
brendan answered

The parameter input for Cloud Script is limited to 30KB as a base, though that can be increased on a per-title basis. We'll have the upgrade system available in the Game Manager either this week or next, at which point you'll be able to set it higher.

However, I should point out that at the point where you're managing 100KB for a single saved game, it's very possible that you'll also be exceeding the limit on total execution time. That'll also be in the upgrades available, but it's possible that you're doing enough that you may want to consider a dedicated server for your server-authoritative logic.

1 comment
10 |1200

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

esk avatar image esk commented ·

I still can't seem to increase the limit. I'm on the pay as you go plan, and have even tried launching the title, but the maximum remains at 30kb...

0 Likes 0 ·
Chris B. avatar image
Chris B. answered

Really, I don't plan to do any server logic. It's all storing data. I just needed a way to transfer data from person A to person B. I'm gathering data for the game and converting it from the data class to a json file, which is then sent as a string when person A finishes their turn and saving it to PlayFab. There is an update to both players to a smaller json string that I can fetch to let them know whose turn it is. (this also updates their game listing). I had it designed to do all the proper saves in a single cloudscript.

I designed a similar system for a different game, so I know the system works. My personal project just has a lot more data to send back and forth depending on what the players do.

I assume these upgrades come with cost? I'm working towards my first release and I'm just a single developer, which is why PlayFab seemed a good option, but while I work towards releases and hope for one (or many) to do well, I'm trying to keep my cost low. I might have to consider other projects and set this aside for now.

Thank you for the info. It does help me get a better idea of what my current limits are.

10 |1200

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

brendan avatar image
brendan answered

Correct, we designed the existing limits for our core free service, specifically so that we can keep it free. Usage above those limits will have a cost associated with them, but bear in mind that we're talking about AWS scale, so we're going to keep those prices as low as we can (while keeping them as simple as we can). You'll see when we release the upgrade system to the site shortly.

My recommendation, if you want to keep below the limits, would be to write the data you're talking about either to User Read Only Data or Shared Group Data with no players Added. That way, you can read it from the client without going through Cloud Script safely. For updates to the data, I would break it up into logical segments so that you can update parts of it as needed over the course of a player's session.

Of course, that said, I don't know the specifics of your game. If you want to get into a more detailed design discussion, you should send the specifics of your feature design to us at devrel@playfab.com, so that we can keep the specifics of your design confidential.

10 |1200

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

Chris B. avatar image
Chris B. answered

Am I mistaken on Shared Group Data. I still have to use Cloud script to write to it if I don't belong to it, right? I thought to write to it you either had to belong to the group or use a server api call and to read from it, it just had to be public if you didn't belong to the group.

My first design was to store small files in each player data that would contain the shared group name, and turn info. The game data itself (which is the main problem right now due to size) was to be stored in the shared group. This was how I did it on the other project.

But then I read a post about how shared group data can only be 10kb a piece, while player data can be up to 10 mb total. So I figured I could store the game data in the player data and each player would maintain a single shared group where the smaller file is stored. This allows them to grab all keys in the shared group without pulling huge amounts of game data that they might not need.

However, that's when I ran into the cloud script parameter size limit. Again I figured I'd have to use cloud script because one player can't directly update another players player data.

Currently, my cloud script is simply server api calls to do updates to the shared group and the opponents player data. 

10 |1200

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

brendan avatar image
brendan answered

Correct, you would still need Cloud Script to write to the Shared Group Data - that's why I'm saying you should write smaller chunks of data at a time, rather than trying to update the whole thing.

Also, I should point out that updating another player's user data from Cloud Script is not a safe operation, unless you're being careful to only ever have the players write to separate keys. A collision between two people writing to the same key will result in only one of those writes "winning", which could mean losing some information about the game being played. Even if the game is completely turn-based, it's still very important to be extra-careful about that possibility.

10 |1200

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

Chris B. avatar image
Chris B. answered

Correct, the updates will never clash as the only time you do a write is at the end of your turn. You currently can't even read the data until the smaller file says it's your turn, which then gives you an option to go read the game data and take your turn.

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.