question

pixeljump avatar image
pixeljump asked

All players updating a single player statistic?

So this seems a little bit cheeky... But I really wanted to store a global kill count. As there is no good solution on PlayFab right now to store a shared global variable I had to get a bit inventive.

I created a mock player called "Global Statistics". Every time a player update their own kill count statistic, the cloudscript also appends the kills to the Global Statistics player stat. This seems to be working just fine with my small amount of test players, but I have no idea if it can scale.

Two questions:

1. Have I found some kind of loophole which will be looked at as an abuse of service.

2. Will it scale?

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.

pixeljump avatar image pixeljump commented ·

3. Are statistic updates thread safe? I know they'll execute just fine but if two update at the very same time will it disregard one?

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

It's good that you ask, as no, this will not work at scale and yes, it would be considered abusive behavior (and so would get the title throttled or blocked). This has actually come up a fair number of times, the most recent being the other day:

https://community.playfab.com/questions/28253/using-single-variable-increment-for-every-user-uni.html

In the legacy (current) statistics and data models, you can have millions of clients reading/writing their own data, but trying to have millions (or even thousands) of players updating the same stat/data would cause performance issues.

The newer Entity model we've been rolling out is more flexible and, long term, will allow us to support something like this. For now, you would need to use a Redis Int or similar, as what you need is either an in-memory data system, or else a queued update request system, which can support a high volume of calls.

As to "thread safe", that really refers to multiple threads running on a single machine. Calls to the PlayFab service endpoints are distributed across a many machines, so conceptually I believe what you mean is "what happens if two concurrent calls try to update the same data/statistic", yes? If so, the answer is that in that case, you will most often get a concurrent edit error (again, in the legacy model).

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.

pixeljump avatar image pixeljump commented ·

Great. Thanks for the answer.

My best bet is to setup a cheap db with a few serverless functions then I suppose.

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.