A better approach to storing time series data from multiplayer Unity server

Hi! :blush:

I’ve recently started integrating Realm into my multiplayer Unity project. My task is to save the positions of all players (the number of players can be from 4 to 30) along with some information about the current player’s activity every 0.1 seconds. This information is sent by the game server and is not used in the game, so I just have to write it to the database. However, it is important to keep the same sampling frequency.

My question is what is a better approach to keep the stored data points evenly spaced?

Hopefully, my question makes sense and this is the right place to ask it.

Any recommendations and resources will come in handy!

Hi @Valerii, thanks for your message. Sorry for the late reply, your post flew under our radar :smile:

I think we don’t have any specific recommendation for your use case. Probably the best approach would be to store all these events in a concurrent queue and continuously dequeue it in a background thread that takes care of storing it in Realm.
Regarding your frequency limits… probably it would be better if you group multiple events in one write transaction instead of having one transaction per event, as it could be too much depending on the platforms in which the game will be run.

Let us know how it goes!

2 Likes

Hi @papafe, thank you for your reply! I have shelved the implementation of the solution that includes Realm and MongoDB and am using the PlayFab capacity for now. Hopefully, I will make it back to the Realm solution soon!

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.