Trying to get my head around CloudKit transfer limits and it seems to be some confusion for many people.
Are records in the user's shared database counted against the user or public quota?
According to my usage in production, the requests and database storage is increasing but there shouldn't be any data within the public scope.
Any ideas?
Records in the shared database are counted against the owner's private quota.
Data in the shared database counts toward your app’s iCloud storage quota.
Related
I'm working with a real time chat app that can have hundreds of users in the same chat at the same time. My question is in regards to fetching the users' profiles from Firestore, and if there's a limit to the number of documents I should be fetching in a single call? I allow my users to preview how many people are present in a given chat, and so in order to do this I typically have to fetch all of the documents in my collection of users.
I typically recommend not retrieving more information than fits on a single screen/view within your app. Limiting yourself to a 'screenful' (or a few screenfuls) of information, ensures you neither rack up your database bill, nor your user's bandwidth bill needlessly.
If you have a use-case where you need to show a count, consider storing that actual count in the database. If you have to read a lot of documents to count them, you're wasting both your own money, and the user's bandwidth again. That's why the most common approach is to store a counter in the database, and then update with every write operation, and read only the counter if you need to display a count. There's even an example of this in the Firestore documentation on distributed counters.
Adding the following code to the AppDelegate will make the Firebase database available when the user is off-line:
FIRDatabase.database().persistenceEnabled = true
How can we make just some parts of the database available in off-line mode and some parts available just when the user is on-line?
Short answer: you can't. Firebase don't currently provide such a fine grained persistence scope API.
What you can do instead is decrease/increase the amount of disk space used by the persistence cache. By default, it will use up to 10MB of disk space to cache data (a small amount by today standards, by the way). This is controlled by the FIRDatabase.persistenceCacheSizeBytes property.
For instance, using a larger cache might hold more nodes from your desired subset... if you are lucky :)
Conversely, a smaller value might affect your network performance/cost in significant ways.
I searched across many threads and issues but I doesn't found the answer.
When I use the Realm Objects Server and the clients connects to the server, the whole DB is synced across all the clients?
In other words, if I have a public DB with millions of objects, relations, etc all the clients have a copy of the whole DB on their devices?
I'll need Realm sync feature but I don't know how to sync occurs. Is the sync incremental? Every user has the objects that device needs to make queries?
My app will increment the size every hour, and the sync feature of the Realm is perfect for me, but I have doubts about the size of DB over the time and how clients sync a lot of data.
Thanks in advance!
At present, yes. Public Realms are synchronized in their entirety to every client's device. The entire list will initially be downloaded when the client's device connects for the first time, and from that point on, any additional changes will be synchronized at the time they are made on the server.
That being said, all Realm files are compacted (ie, all empty allocated space is removed and all strings are condensed), and then compressed with gzip before being downloaded to the client, so as long as the public Realm doesn't contain large binary blobs, even very large files should come down quite quickly.
It's on the roadmap to add partial replication to the Realm Mobile Platform. This will allow only portions of a single Realm file to be synchronized to specific clients. However there are no concrete plans for when this will be released.
For the time being, the easiest thing to do would be to maintain the master list of data on the server, and copy only the desired data to each user's private Realm. However since this would require custom logic to be executed on the server, it would require the Professional or Enterprise editions of the Realm Mobile Platform.
I'm making a simple Swift meditation app and want to have a feature to allow users to see how many others have installed the app as well ("You're part of a community of 354 other meditators")
My current plan - save a "blank" record on first load to public DB in CloudKit.
Then - each client on login retrieves all the records and counts how many there are?
Is there a better solution. I could imagine this getting slow if there are lots of users...
Thanks!
In terms of your CloudKit example, as far as I'm aware there is no option to return the number of records, instead CloudKit just returns the actual records in batches (it decides how many to return). However, you may specify a limit of records for it to return.
If you did specify a limit, you would need to continually update it since once the number of records grows larger than the limit it will no longer retrieve them all and your count will be wrong.
This would be a bad idea probably since you will have to continually release app updates to increase the limit (unless you stored this value in some kind of other external DB which would then probably be preferable to CloudKit itself). Basically, CloudKit is probably not the best idea for this.
It would probably be much easier to use a different public DB setup. Either set up your own or use a service like 'Parse.com' which makes setting up and connecting to a public DB very simple. An additional benefit of doing it this way is you can run the count query on the server and just return the count value itself rather than returning all records and counting them locally - very inefficient.
I am investigating what may be the best choice of cloud database service would be for my app. I am closely looking at CloudKit, however one thing concerns me. The Public Database transfer limits being 250kb per day with an additional 5kb per user.
What is the best way to measure how much I am transferring in and out of my app? I see this as the biggest issue with CloudKit, as there are no analytics provided on this.
Unfortunately there aren't any analytics to view usage. If you notice that your users are bumping into the limits you should contact Apple and they'll work with you to bump the limits.
Note that if you use the private database that data is counted against the individual users quota and not against your app. Every iCloud user gets 5GB of storage for free (shared with backups, photo streams, etc), and users can purchase additional storage if they want.