Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Best architecture for offline-first, cloud-synced mobile app?
20 points by milohoffman on Jan 24, 2019 | hide | past | favorite | 7 comments
So I've been grappling with a technical design decision for a few days now and wanted to see what HN thinks, since I imagine there are a bunch of people who have run up against this problem and might have opinions/experience.

I've built an iOS app that uses Rails as a backend, this has worked well as a stack for me in the past, but the wrinkle is that this app now needs to be truly functional offline - I need to persist every object locally for offline use, but then also have that synced to the cloud for backup and to enable other features like sending emails and notifications containing users' content.

There are obviously plenty of straight-forward options to handle the local persistence (CoreData, SQLlite, Realm, etc.), and I'm happy to use any of them, but there seems to be no great option for persisting/syncing the local stuff on the cloud. Each of the options I've come across has significant drawbacks:

Realm Platform - prohibitively expensive (> $2000/year) if you want to access the server data to do anything other than communicate with a Realm client, also migrations are a pain

iCloud + CoreData - people might not have iCloud space or iCloud enabled

Google Cloud Firestore - in beta, some people experiencing issues with locally created objects not getting persisted, locked in to platform

Google Firebase Realtime - seems like this is effectively on the way to getting deprecated in favor of Firestore

Rolling my own solution where I write a background process to sync the client's data with my Rails server - lots of complex code, prone to bugs

Any opinions on this problem or things I should consider? Would be greatly appreciated!



1) Couchdb

2) AWS AppSync Client (not Amplify) + AWS AppSync service + Cognito + a few Lambdas + some db


CouchDB has the advantage of implementations for mobile (CouchBase Lite for iOS and Android) and web (PouchDB).


I just leave this link here. Quip is one of my favorite offline-first cross-platform app. They use leveldb (realm is also based on leveldb) on the client and use mysql on the server. Protocol buffers are used for communication although thats just a communication method.

https://medium.com/@btaylor/react-with-c-building-the-quip-m...


Have you checked out MongoDB Mobile/Stitch?

https://www.mongodb.com/cloud/stitch


No, never heard of this option, definitely going to check it out - thanks!


You could use Realm Object Server instead of signing up for Realm Platform.

Another option you can investigate is AWS AppSync.

You also can just configure your data layer to get from the cache if offline, and get from your Rails app if online. You can use the Reachability framework to get notifications when an Internet connection comes back online.


My understanding is that just "using Realm Object Server" means using Realm Platform Self Hosted, which starts at $2000/year. The hosted Realm Platform starts at $30 month, but I've read you need to upgrade to a similarly expensive $1500-2000 enterprise plan if you want to access the data from non-mobile-Realm clients. That is to say, I'm very open to just using Realm Database on the client for local persistence, because it's free and really nice to use, but don't think Realm for sync is viable.

AWS AppSync looks like it's worth investigating, thanks!

Agreed a custom data layer/cache might be the way to go, I think it gets a bit more complex once you have a bunch of objects being edited and deleted, and I've also spent some time with iOS background networking in the past and I know it can be buggy/frustratingly non-deterministic, which is why I'm reluctant.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: