question

doodahprod@hotmail.com avatar image
doodahprod@hotmail.com asked

SharedData and concurrent Requests

Hello,

I'm trying to figure out what's the best way to achieve this behavior on playfab. Please take in consideration that we expect more than 500000 Daily Users on mobiles, so the performance of this request is a big deal for us.

The behavior I'm looking is a bit like tinder :

------------------------------------------------------------------------------------------------------------------

1) Player can publish a set of items from my game

2) Player can see a set published by any other player with at least one published set

3) Player can rate that set

4) Player can not be presented with a set he already voted

5) If a player publish a new set of item, the older one is erased and all rating is lost

-----------------------------------------------------------------------------------------------------------------

I tried to figure out how to do this system and this is my plan. Using SharedData, every time a user publish a set, I'ld add a Key-Value with key as PlayfabId of user who published the room and value a JsonDictionary with keys as PlayfabId of users who already rated this set.

In a CloudScript I would then use a GetSharedGroupData with empty array as Keys to get only members. From this list I get a random PlayFabId, then call again GetSharedGroupData with that specific id as unique Key.

At this point, I have the JsonDictionary where I can check if the authentified user as already rated this room or not. If not, I return the set. If yes, I get another random PlayFabId and so on until I find a set available.


This doesn't seems so optimal, and I'm scared to turn in very low performance on this script as the users rate other's. Also, if two users rate at the same time a set, I'm scared that the concurrent request override each other's, resulting in one of the rating to not be taken in account.Do you have any advice for me, or maybe a better idea on how to do this ?

Thanks a lot.

 

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

You're right to be concerned, as that's not going to work. Not the user count - we already support far higher DAU levels, and we've tested to a million concurrent players (which would work out to something like 10-20 million DAU, depending on how you calculate it). The issue is that there are two primary types of general-purpose data in a backend service for online games:

1. Data which is stored across multiple database shards, allowing it to be accessed by all players. This spreads the load for concurrent requests out, and scales to millions of concurrent users. However, it is not something you'd write to from those millions of users - you update it as the owner of the title (so, Title Data and Publisher Data).

2. Data which is custom to the user, and which is only stored in one place. Since it's not sharded, you can't reliably scale this to be used by those millions of users, though a reasonable subset works fine. It's designed to be updated by users, but simply put, the reality of physics makes it so that this cannot be all users, since that would cause a "logjam" effect as you scale up.

Shared Group Data is type 2 - it's designed for a group of players to share and update, though potential collisions do have to be managed carefully. Given the default limits on usage for it in our free service, I wouldn't want to manage more than 100 players in one (and if you wanted to work out a contract with us which provides for a higher limit, I would still not want to go more than a few multiples higher).

What you need is something purpose-designed to the use case, or at least to a use case which is close to your actual design goals, so knowing more about that would be key. It sounds like what you want is a User Generated Content system. If that's what you're going for, we do not have a complete UGC service right now, though if we get enough feedback from developers who need that feature, that could get prioritized into our future updates. If you wanted to build a UGC service on top of our Content service right now, you would need to have custom servers - which you could use our hosting for, potentially - that take care of the key elements - managing reviews and ratings, featuring content from users, and providing the tools needed for your take-down processes. For the database of reviews, you could potentially use the MongoDB add-on we'll be providing soon. That would allow you to design a custom database interaction, while still sending events to your PlayStream to track on everything the players do.

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.