Search code examples
realmrealm-mobile-platform

Calculate realm database size


I've implemented Realm database for offline data, but I'm thinking of using the syncing function with a server hosted, for example at Digital Ocean.

But the question is: how to get a good estimate of the size the online database?

The data is just strings and numbers, like a notepad app. I looked at the offline realm file and it's about 2MB large (which feels large. If I just write the data to file as a blob, it's around 50kb). Then it got me thinking, if that't the data size for each user, and I have around 500.000 users, then it's 1TB of data, and that costs too much to afford as a hosting service for a hobby project.

Or can I count around 50kb per user ending up in 10GB?

I don't want to roll out syncing and then I realize that I can't use syncing since I don't have enough of storage space on the server and needs to remove that feature.


Solution

  • You can probably expect such a size when syncing to the server. The server has to keep a log of all changes in the realms too, to be able to do joins and migrations automatically.

    Storing the data straight on disk is just a few bytes of characters, the realm file contains the data, including meta data from the RealmObject itself, indexes to search the data and more. So yes the realm file is a lot larger, but it also contains much more information.