question

oskar avatar image
oskar asked

Are event triggered calls to cloud script functions processed sequentially?

Hi,

I've set it up so that when a client sends an EndRound request this cloud script handler takes care of some magic, writes an event to Playstream and gives a response to client. However, I've deferred storing the level progress to a Rule that triggers only on successful EndRound's and calls a different cloud script handler that syncs and persists the level progress to player read only data. So far it has worked quite well.

Here comes the tricky part: We allow offline play which means that whenever a client comes online again it may have any number of EndRounds stored locally that it will try to sync to PlayFab backend. To avoid clients spamming backend with 20, 30, 40 requests (one per round played) we bundle them in fewer requests (currently up to 20 EndRounds per request) and cloud script loops through and takes care of them one after the other.

Now remember how each EndRound results in a PlayStream event that triggers other cloud script to store level progression? Level progression is also stored in bundles, sort of like episodes if you will, so different playstream calls (per individual level) may try to update the same object (different levels in same episode) in player read only data...

So my question is if there are any guarantees from PlayFab side of these calls triggered from PlayStream rules are being handled sequentially? Cause if there is any chance of parallellism I'm gonna have to re-think a lot of this I'm afraid...

I've done some light testing and it seems to work but I'm still worried and I'm not sure any amount of testing I can perform myself will completely take that worry away :)

Many thanks, Oskar

Player DataCloudScriptPlayStream
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

To be clear, when the client comes back online, what should happen is that the client should make a single call with the aggregated information from the offline play. In processing that, there should be a single instance of "magic" that takes care of whatever you're doing there (so, one call to add items or change VC, aggregating all the changes from all the rounds), and one event that contains the information on the rounds played. The script triggered off that should then also be making an aggregated change to the player read only data for the progress info. That would definitely work as you've intended. If you're trying to fire 20 events at a time and have each trigger a script, there is no guaranteed processing order for those events and scripts.

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.

oskar avatar image oskar commented ·

Thank you for the quick answer. Ok, so that's what I was afraid of. I guess I'll keep it as is for continuous online play but will have to make some substantial changes to how it works for the offline bundles.

0 Likes 0 ·

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.