question

pieter avatar image
pieter asked

Using TitleData for world stats

Hi all!

I was wondering if anyone could advice us on our current situation.
Searching the questions I did find some usefull information on a similar topic - but I am still not entirely convinced we're doing the right thing.

We're currently building a .io type game where users can fight either as a man or a monster. Those are the 2 default'teams'. Additionaly teams can be created in TitleData. The game automatically loads and sets up new and existing teams.

An user can change teams on the fly (in the main menu) - the team the user has selected is saved in its profile and stored in PlayerData. At the moment we don't see the need to create Shared Groups or something similar.

On each play (pressing play in the main menu) we execute a Cloudscript to update 'WorldData' in TitleData. This is a 'complex' JSON object. We count (thus add by 1) the amount of plays for a certain team when a user starts playing - additionally we would like to store e.g. deaths, kills here as well.

Everything is already working, both in the Game Manager and in-game. Theoratically, we could store/retrieve everything and show the user a 'pretty accurate' depiction of the current world situation. This is can even be sorted per region (SA, EU, etc.) So far so good and we're very happy with how this is currently set up and working.

However, I am wondering if this is the best way to go? I am not sure if we are burdening TitleData?
I didn't find any other solution that would fit our requirements and needs. I suspect that TitleData would be called a few times per second in the most succesfull scenario.

I do understand that multiple users could create inaccuracies when accessing and updating TitleData simultaneously, but that is ok.

Long story :)

Does any have any thoughts or ideas on this?

Thanks in advance!

-Pieter

Title 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.

1 Answer

·
brendan avatar image
brendan answered

Unfortunately, Title Data cannot be used this way. The Server API call to update Title Data is specifically designed for use with Scheduled Tasks that update Title Data when an event is starting or ending, or other similar globally-impacting changes. Title Data should never be written to as a result of a player action, as it is a sharded and cached resource. It has to be, in order for it to be able to be read by large numbers of players in a short period (otherwise, the calls would stack up as they're being serviced).

So for example, if you have a Title Data key with some data in it, when you update the value for that key, there's a short period (up to a few seconds) while that data is updated in all the shards. During that period, queries to the data may get either the old or new values, depending on the shard the caller hits. Also, attempting to write to Title Data too frequently will simply fail.

There's a much more extensive discussion on this topic here: https://community.playfab.com/questions/3843/use-shared-group-data-for-a-live-event-system.html. But simply put, a system which requires all players to be able to update it, and all players to be able to read it, would need to be custom-tailored to the need, as a generic system capable of doing that and keeping the data consistent would be incredibly expensive to operate.

So in general, for components that need data capabilities we do not yet support, you would need to use an external data table.

4 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.

sebastianengfer avatar image sebastianengfer commented ·

Hello @Brendan,


we are developing a quite simliar game like the thread creator and I'm interested in a solution for this use case?! We are now in 2020, I would love to know if Playfab has created a solution for that kind of stuff, like world stats etc.
I know, there ist this system called catalogs, where you can create items and stuff - but I don't think thats what we need... Am I right?
Is there now an integrated system in Playfab, where all players can write and read some world stats from?! Or is there an other way to achive this except to create an own database.
I'm looking forward to read from you!

Best regards
Sebastian

0 Likes 0 ·
brendan avatar image brendan sebastianengfer commented ·

The problem remains that what you're trying to do is have a single piece of data updated by every player in the game. For a popular game, this could mean a great many attempts to update that data at the same time.

In terms of newer functionality, we do have Groups, and Groups can have data (Entity Objects and Files). Those are available for use in cases where you have groups of players updating that data, but I will caution you that if you have many players trying to update the data at once, you will need to have backoff-and-retry logic on that update call, since only one call to update a specific data revision can succeed if there are multiple simultaneous requests. In a high CCU game, that could cause delays for some players.

It would still be better to separate the elements being written, and use a Redis Int for each of the numeric values. In-memory caches are far more efficient for this type of logic.

0 Likes 0 ·
pieter avatar image pieter commented ·

Thanks for your reply and the link. Can't believe I missed that.

I did a bit of rework and I think we should be good to go - until we switch to a external database.

Would something like this - a external database or another way to store this kind of data - be added to PlayFab?


-Pieter

-1 Like -1 ·
brendan avatar image brendan pieter commented ·

We'll be adding more data systems to PlayFab over time, but any case where data is coming from all players and is readable by all players will have to be tailor-made for the requirements, in order to keep the costs low enough to be reasonable. We do have a backlog item to add a data table that you can query from a simple API call, but you can actually connect a data table to your game via Cloud Script right now, using any database system that offers a Web API (like Azure Table Storage, AWS DynamoDB, or a MongoDB from mLab).

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.