question

glen avatar image
glen asked

Entity Objects vs Entity Files

I've been reading through the new Entities documentation and am excited to start working with the new system. As your team is the one to have developed the system, I'm curious to know what your general use-case-scenarios are for Entity Objects vs Entity Files. In general, when is a better time to use an Object to save data vs a File? Do Objects load/update/process faster than Files? Would it be inefficient to use Files to save string based player data? Is it save to assume that one could save an image use Files?

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

·
pfnathan avatar image
pfnathan answered

Objects are size-limited and are all retrieved with a profile, whereas files are any size, but have to be downloaded separately. More details are here: https://api.playfab.com/docs/tutorials/entities/getting-started-entities,

Entity Objects allow you to read and write small JSON-serializable objects attached to an entity. Entity Files allow you to read and write files attached to an entity, in any format. If you get an entity profile the objects are always there with the profile but with size limited.

i.e) Let say you wanted to display name or level on Entity, you could make an EntityData object which has {Displayname: “ My Stash”, Level 50} and attach that to the profile, and then each time someone loaded that profile they would get the Displayname and level. However, if you want to have Player Icon then you would use a Entity file.

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

glen avatar image glen commented ·

Thanks for the info. Another thing I'm wondering about is client access to data. Right now we have data which a client can both read and write, data which the client can only read, and data which only the server can access. Will this type of data security continue with the Entity system?

P.S. If I should I wait to ask these questions until the system has been made available just let me know.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ glen commented ·

Yes, we replicate that now, we will be adding the UI to edit the policies for the entire game shortly, but if you look at the "SetObjects API" you can see how to attach a policy while saving an object that will let you replicate the existing behavior.

We have more documentation on the way in coming months.

0 Likes 0 ·
glen avatar image glen glen commented ·

Final question: do you guys have an ETA for when we'll be able to use this system in it's entirety? Are we talking days, weeks, months?

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ glen commented ·

You can use them right now; you may find that some UI is missing, but we are adding UI for what already exists as an API as of right now.

0 Likes 0 ·
Show more comments
plourdegui avatar image plourdegui commented ·

Our use case is as follow:

1. Periodically (every few seconds), save the player data as one big json string (potentially over 10 kb) to PlayFab.

2. Upon game startup, load the player data from Playfab.

Questions:

- Is this new API meant to be used as a replacement of the current client's "Player Data Management" API or does it serve a complementary function?

- Can we make use of the Entity File API to save our data in order to benefit from the absence of size restriction?

- Is there a considerable performance cost of using Files over Objects?

It would be great to have a section in the documentation to showcase a few typical use cases for both entity objects and entity files, as well as precise comparison as to when to use one over the other for storing data.

0 Likes 0 ·
pfnathan avatar image pfnathan ♦ plourdegui commented ·

You shouldn't be doing that in the existing system or the new one, a reason for that is; what you are suggesting is too high of a rate, you should be aiming to make only a few API calls per minute, a burst of call is fine as well, but a sustained constant rate of calls like that would be too much

a) It's a replacement but can be used in parallel if that fits your needs better.

b) Yes, but you will have trouble trying to save it every few seconds most likely.

c) Files are substantially slower to read and write from, most likely at 10kb and smaller you won't see any benefit unless you are mostly performing reads and very few writes. "Substantially" is subjective though, it won't take seconds, but it is slower.

We will be updating Group/Entity tutorial sections shortly; please look for them later.

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.