question

playfab@jannahquiz.com avatar image
playfab@jannahquiz.com asked

TitleData atomic increment

So I am building a quiz app. I want the difficulty of the questions be determined by life statistics. So everytime a user succeeds or fails in answering a question, I want to increment a counter for this question (using a question id).

If many users are answering at the same time, I will run into write conflicts. The easiest solution would be if the backend offers some atomic increment. Is that available? If not, is there a workaround for this situation??

3 comments
10 |1200

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

Ben Vissotzky avatar image Ben Vissotzky commented ·

@Brendan. Is using an external db still the best way to aggregate a statistic like this?

,

@Brendan. It has been a couple years since this post's answer. Has there been any update to Playfab that could accommodate all players being able to update one value as well as read same value? Or is an external DB still the best solution?

0 Likes 0 ·
brendan avatar image brendan Ben Vissotzky commented ·

For the specific goal of having all players in a game updating a single statistic, yes, you would need to use something like a Redis Int. No disk-based database would support this - it needs to be an in-memory data system.

0 Likes 0 ·
Ben Vissotzky avatar image Ben Vissotzky brendan commented ·

Awesome, thanks for the quick reply!

0 Likes 0 ·
brendan avatar image
brendan answered

It sounds like what you want is a single counter per question, which can be written to by all players - is that the case? If so, then no, I'm afraid we do not offer that currently. Our generic data systems are designed for the broad-use cases of data which is set up for the title and read by all players (sharded across many nodes, to prevent any delays in data retrieval), and data which is written to and read by a subset of users (non-shardable, as it must always be up to date for the most recent write). I would recommend adding this to our Feature Requests forum, as we prioritize in part based upon the aggregate need of our community, so that would allow others to "vote up" this feature if they need it.

The workaround for this right now would be to make use of an external database via Cloud Script. Any Web API enabled database, such as DynamoDB, Azure Table Storage, or MongoDB via mLabs would work, for example. We will have a pre-integrated MongoDB solution available later this year, as well.

10 |1200

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

playfab@jannahquiz.com avatar image
playfab@jannahquiz.com answered

Thanks for your answer! Can tell me a little more about the sharding?? (I love how Ultima Online invented this word)

How big is a geographic region a node belongs to? Is it the scale of countries or regions / continents? Or something more dynamic?

If a player changes a value via cloud script, how long should it take to propagate the change to all nodes?

Or is there some documentation somewhere describing this?

10 |1200

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

playfab@jannahquiz.com avatar image
playfab@jannahquiz.com answered

Another question:

Is there a limit to how many title data entries a game can have? If I have say 10k questions, for each I need two counters for each. Would playfab allow me to create this many? How about performance for retrieving values?

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

Sharding simply refers to replicating the data across multiple data stores, so that you don't have the problem of thousands of players trying to read from the same store at the same time - which causes delays. Instead, the same data is replicated many times, so that each store can serve a subset of those players.

Regions in the context of PlayFab are the AWS regions, which you can read about here: http://docs.aws.amazon.com/general/latest/gr/rande.html.

But again, the Title Data space is not something players would write to - it is meant as a store of data which you configure for all players in the game. It is not designed to aggregate inputs from multiple players, so regardless of the data propagation time, this would not be a way to sum up these values. What you're looking for is a way to sum up data inputs from all players, across your entire game. Since neither Title nor User data are appropriate for this, I would still recommend the external database route for this feature (for now - I'm sure we'll add something to support this in the future).

For completeness though, all our stated limits for our free service are here: https://playfab.com/limits.

10 |1200

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

playfab@jannahquiz.com avatar image
playfab@jannahquiz.com answered

Thanks! Your answer is much appreciated! :)

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.