question

Arnau Castillo avatar image
Arnau Castillo asked

Memory profile write when updating user data

Hi.

The cost of a profile write with for example UpdateUserData depends on the number of keys written. As long as each key doesn't surpass 1kb, one key = one tick = the meter count increases by one.

My question is:

How much memory in bytes does a key with 50 values like the one below have? Is it 4+50=54 bytes?

{"Gems": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}

What if the key has the number 1 repeated 996 times as a value? Is it 4+996=1000 bytes=Kb=one tick?

{"Gems": [1,1,1...,1]}

Thanks

Player Dataapisdatapricing
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

·
Made Wang avatar image
Made Wang answered

In PlayFab, both keys and values are stored as strings, such as { "Key": "Value" }.

So in your example, the size of the key is 4 bytes and the size of the value is 199 bytes, for a total of 203 bytes, which is a tick. If 1 is repeated 996 times as a value, then the key-value pair size is 1995 bytes, which is two ticks.

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.

Arnau Castillo avatar image Arnau Castillo commented ·

Could you explain why the size of the second key-value pair is 1995 bytes? I understand that you are summing up the quotes and the commas, so it is 49 commas + 100 quotes + 50 zeros= 199 bytes.

But with the second example I don't get where the 1995 bytes comes from. I thought that it would be 996 + 996*2 + 995 + 4.

0 Likes 0 ·
Made Wang avatar image Made Wang Arnau Castillo commented ·

To clarify, although you said the value is 50 zeros, you wrote 100 zeros in your example. So your example usually looks like this in key-value pairs:

{ "Gems": "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" }

So the second example is 996 one + 995 commas + 4 = 1995 bytes.

Another thing to be clear is that the format of the value is not explicitly required, you can add some symbols to the value at will, just make sure that it is converted to a string type in the final transmission.

0 Likes 0 ·
Arnau Castillo avatar image Arnau Castillo Made Wang commented ·

In my case I am not converting the values to strings. The value is a list with integers. Is this a problem? Does this increase the number of bytes or {"Gems": "0,0,0,0"} has the same number of bytes as {"Gems": [0,0,0,0]}?

0 Likes 0 ·
Show more comments

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.